• 注册后才能下载/购买插件!快来注册吧,注册即可免费下载 精翻插件 !【点我注册
  • RustSB.COM向广大野生Rust插件作者发出入驻邀请!详情请见[原创作者条约]
【XMRelationship·关系/师徒/宗门/造娃】

原创 【XMRelationship·关系/师徒/宗门/造娃】 1.1.0

1. 检查玩家队伍中是否有关系的玩家​

C#:
bool HasRelationshipInTeam(string playerIdString, string relationshipType = null)
功能:检查玩家当前队伍中是否有关系的玩家
参数
  • playerIdString: 玩家ID字符串
  • relationshipType: 关系类型(可选,如"老婆"、"老公"、"大哥"、"老弟"等,不传则检查任意关系)
返回值:true表示队伍中有关系的玩家,false表示没有
使用示例
C#:
// 检查玩家队伍中是否有任意关系的玩家
bool hasAnyRelationInTeam = XMRelationship?.Call<bool>("HasRelationshipInTeam", player.UserIDString) ?? false;
if (hasAnyRelationInTeam)
{
    Puts("玩家队伍中有关系伙伴!");
}

// 检查玩家队伍中是否有老婆
bool hasWifeInTeam = XMRelationship?.Call<bool>("HasRelationshipInTeam", player.UserIDString, "老婆") ?? false;
if (hasWifeInTeam)
{
    Puts("玩家队伍中有老婆!");
}

2. 检查玩家是否有指定关系​

C#:
bool HasSpecificRelationship(string playerIdString, string relationshipType)
功能:检查玩家是否有指定关系类型(无需检查队伍)
参数
  • playerIdString: 玩家ID字符串
  • relationshipType: 关系类型(如"老婆"、"老公"、"大哥"、"老弟"等)
返回值:true表示玩家有指定关系,false表示没有
使用示例
C#:
// 检查玩家是否有老公关系
bool hasHusband = XMRelationship?.Call<bool>("HasSpecificRelationship", player.UserIDString, "老公") ?? false;
if (hasHusband)
{
    Puts("玩家有老公关系!");
}

3. 检查玩家和指定玩家的亲密度​

C#:
int GetIntimacyLevel(string playerIdString, string partnerIdString)
功能:获取两个玩家之间的亲密度数值
参数
  • playerIdString: 玩家ID字符串
  • partnerIdString: 伙伴ID字符串
返回值:亲密度数值,如果没有关系返回-1
使用示例
C#:
// 获取两个玩家的亲密度
int intimacy = XMRelationship?.Call<int>("GetIntimacyLevel", player1.UserIDString, player2.UserIDString) ?? -1;
if (intimacy >= 0)
{
    Puts($"两个玩家的亲密度为:{intimacy}");
}
else
{
    Puts("两个玩家没有关系");
}

4. 扣除玩家和指定玩家亲密度​

C#:
bool DeductIntimacy(string playerIdString, string partnerIdString, int amount, string reason = "API调用")
功能:扣除两个玩家之间的亲密度
参数
  • playerIdString: 玩家ID字符串
  • partnerIdString: 伙伴ID字符串
  • amount: 扣除数量(必须大于0)
  • reason: 扣除原因(可选,默认为"API调用")
返回值:true表示扣除成功,false表示失败
使用示例
C#:
// 扣除亲密度
bool success = XMRelationship?.Call<bool>("DeductIntimacy", player1.UserIDString, player2.UserIDString, 10, "插件惩罚") ?? false;
if (success)
{
    Puts("成功扣除10点亲密度");
}

5. 增加玩家和指定玩家亲密度​

C#:
bool AddIntimacyLevel(string playerIdString, string partnerIdString, int amount, string reason = "API调用")
功能:增加两个玩家之间的亲密度
参数
  • playerIdString: 玩家ID字符串
  • partnerIdString: 伙伴ID字符串
  • amount: 增加数量(必须大于0)
  • reason: 增加原因(可选,默认为"API调用")
返回值:true表示增加成功,false表示失败
使用示例
C#:
// 增加亲密度
bool success = XMRelationship?.Call<bool>("AddIntimacyLevel", player1.UserIDString, player2.UserIDString, 20, "插件奖励") ?? false;
if (success)
{
    Puts("成功增加20点亲密度");
}

6. 获取玩家指定关系类型的伙伴名称​

string GetRelationshipPartnerNames(string playerIdString, string relationshipType)
功能:获取玩家指定关系类型的所有伙伴名称
参数
  • playerIdString: 玩家ID字符串
  • relationshipType: 关系类型(如"老婆"、"老公"、"师傅"、"徒弟"等)
返回值:伙伴名称列表,多个用"/"分隔,没有则返回null
使用示例
C#:
// 获取玩家的所有师傅
string masters = XMRelationship?.Call<string>("GetRelationshipPartnerNames", player.UserIDString, "师傅") ?? null;
if (!string.IsNullOrEmpty(masters))
{
    Puts($"玩家的师傅有:{masters}");
}
else
{
    Puts("玩家没有师傅");
}

// 获取玩家的所有老婆
string wives = XMRelationship?.Call<string>("GetRelationshipPartnerNames", player.UserIDString, "老婆") ?? null;
if (!string.IsNullOrEmpty(wives))
{
    Puts($"玩家的老婆有:{wives}");
}

7. 获取两个玩家之间的关系信息​

C#:
string GetRelationshipBetweenPlayers(string playerIdString, string targetIdString)
功能:获取两个玩家之间的具体关系信息
参数
  • playerIdString: 玩家ID字符串
  • targetIdString: 目标玩家ID字符串
返回值:关系信息字符串,格式:"玩家关系类型|伙伴关系类型",没有关系返回null
返回格式说明
  • 格式:"玩家关系类型|伙伴关系类型"
  • 例如:"老公|老婆" 表示玩家是老公,目标玩家是老婆
  • 例如:"大哥|老弟" 表示玩家是大哥,目标玩家是老弟
  • 例如:"师傅|徒弟" 表示玩家是师傅,目标玩家是徒弟
使用示例
C#:
// 获取两个玩家之间的关系
string relationship = XMRelationship?.Call<string>("GetRelationshipBetweenPlayers", player1.UserIDString, player2.UserIDString) ?? null;
if (!string.IsNullOrEmpty(relationship))
{
    string[] parts = relationship.Split('|');
    if (parts.Length >= 2)
    {
        string player1Role = parts[0];  // 玩家1的关系类型
        string player2Role = parts[1];  // 玩家2的关系类型

        Puts($"{player1.displayName}是{player1Role},{player2.displayName}是{player2Role}");

        // 在UI中显示玩家2的关系类型
        string displayText = $"{player2.displayName} ({player2Role})";
    }
}
else
{
    Puts("两个玩家之间没有关系");
}

// 实际应用:在队伍系统中显示队员关系
private string GetMemberDisplayName(BasePlayer viewer, BasePlayer member)
{
    string relationship = XMRelationship?.Call<string>("GetRelationshipBetweenPlayers",
        viewer.UserIDString, member.UserIDString) ?? null;

    if (!string.IsNullOrEmpty(relationship))
    {
        string[] parts = relationship.Split('|');
        if (parts.Length >= 2)
        {
            // 显示成员在查看者眼中的身份
            return $"{member.displayName} ({parts[1]})";
        }
    }
    return member.displayName;
}

8. 获取玩家的帮派名称和等级​

C#:
string GetPlayerGuildInfo(string playerIdString)
功能:获取玩家所在帮派的名称和等级信息
参数
  • playerIdString: 玩家ID字符串
返回值:帮派信息字符串,格式:"{帮派名称}Lv.{等级}",没有帮派返回null
返回格式说明
  • 格式:"{帮派名称}Lv.{等级}"
  • 例如:"龙门帮Lv.3" 表示玩家在龙门帮,帮派等级为3级
  • 例如:"青云宗Lv.1" 表示玩家在青云宗,帮派等级为1级
  • 如果玩家没有加入帮派,返回null
使用示例
C#:
// 获取玩家的帮派信息
string guildInfo = XMRelationship?.Call<string>("GetPlayerGuildInfo", player.UserIDString) ?? null;
if (!string.IsNullOrEmpty(guildInfo))
{
    Puts($"玩家所在帮派:{guildInfo}");
}
else
{
    Puts("玩家没有加入帮派");
}

// 在UI中显示帮派信息
private void ShowGuildInfo(BasePlayer player)
{
    string guildInfo = XMRelationship?.Call<string>("GetPlayerGuildInfo", player.UserIDString);
    string displayText = !string.IsNullOrEmpty(guildInfo) ? guildInfo : "暂无";
 
    // 在UI中显示
    AddInfo("宗门", displayText);
}

// 检查玩家是否有帮派
private bool HasGuild(BasePlayer player)
{
    string guildInfo = XMRelationship?.Call<string>("GetPlayerGuildInfo", player.UserIDString);
    return !string.IsNullOrEmpty(guildInfo);
}




Hook事件​

1. 玩家绑定关系时触发​

触发时机:当两个玩家成功绑定关系时
参数
  • playerIdString: 玩家ID字符串
  • partnerIdString: 伙伴ID字符串
  • playerRelationType: 玩家的关系类型
  • partnerRelationType: 伙伴的关系类型
使用示例
C#:
void OnXMRelationshipBound(string playerIdString, string partnerIdString, string playerRelationType, string partnerRelationType)
{
    var player = BasePlayer.Find(playerIdString);
    var partner = BasePlayer.Find(partnerIdString);
 
    Puts($"{player?.displayName} 和 {partner?.displayName} 绑定了关系:{playerRelationType} - {partnerRelationType}");
}

2. 玩家升级关系时触发​

C#:
void OnXMRelationshipUpgraded(string playerIdString, string partnerIdString, string oldPlayerRelationType, string oldPartnerRelationType, string newPlayerRelationType, string newPartnerRelationType)
触发时机:当两个玩家成功升级关系时
参数
  • playerIdString: 玩家ID字符串
  • partnerIdString: 伙伴ID字符串
  • oldPlayerRelationType: 旧的玩家关系类型
  • oldPartnerRelationType: 旧的伙伴关系类型
  • newPlayerRelationType: 新的玩家关系类型
  • newPartnerRelationType: 新的伙伴关系类型
使用示例
C#:
void OnXMRelationshipUpgraded(string playerIdString, string partnerIdString, string oldPlayerRelationType, string oldPartnerRelationType, string newPlayerRelationType, string newPartnerRelationType)
{
    var player = BasePlayer.Find(playerIdString);
    var partner = BasePlayer.Find(partnerIdString);
 
    Puts($"{player?.displayName} 和 {partner?.displayName} 关系升级:{oldPlayerRelationType}-{oldPartnerRelationType} → {newPlayerRelationType}-{newPartnerRelationType}");
}

3. 玩家解绑关系时触发​

C#:
void OnXMRelationshipUnbound(string playerIdString, string partnerIdString, string playerRelationType, string partnerRelationType, int intimacyLevel)
触发时机:当两个玩家解绑关系时
参数
  • playerIdString: 玩家ID字符串
  • partnerIdString: 伙伴ID字符串
  • playerRelationType: 玩家的关系类型
  • partnerRelationType: 伙伴的关系类型
  • intimacyLevel: 解绑时的亲密度
使用示例
C#:
void OnXMRelationshipUnbound(string playerIdString, string partnerIdString, string playerRelationType, string partnerRelationType, int intimacyLevel)
{
    var player = BasePlayer.Find(playerIdString);
    var partner = BasePlayer.Find(partnerIdString);
 
    Puts($"{player?.displayName} 和 {partner?.displayName} 解绑了关系:{playerRelationType}-{partnerRelationType},亲密度:{intimacyLevel}");
}