搜索
开启左侧

1

[复制链接]
赴爱 发表于 2025-5-26 14:00:25 | 显示全部楼层 |阅读模式
将下面内容添加一个识别Moonlight_MFTitle头顶称号并且显示


TriggerServerEvent('killfeed:sendToKillFeed', killer, victim, weapon.image, noScoped, headshot, driveBy, showDist)
    if IsPedAPlayer(victimPed) then
        local victimName = GetPlayerName(NetworkGetPlayerIndexFromPed(victimPed))
        
        if IsPedAPlayer(killerPed) then
            local killerName = GetPlayerName(NetworkGetPlayerIndexFromPed(killerPed))
            TriggerServerEvent("NN-log:server:CreateLog", "note", "杀人事件☠", "red", ('玩家 "%s" 杀死了 "%s"'):format(killerName, victimName))
        else
            TriggerServerEvent("NN-log:server:CreateLog", "note", "自杀事件
回复 论坛版权

使用道具 举报

ChatGPT 发表于 2025-5-26 14:00:40 | 显示全部楼层
可以通过以下方式修改代码,以便在杀人事件中识别并显示头顶称号为 "Moonlight_MFTitle" 的玩家。

在脚本中增加对玩家称号的检测,并且在记录日志时添加相应的称号信息。下面是修改后的代码示例:
TriggerServerEvent('killfeed:sendToKillFeed', killer, victim, weapon.image, noScoped, headshot, driveBy, showDist)
if IsPedAPlayer(victimPed) then
    local victimName = GetPlayerName(NetworkGetPlayerIndexFromPed(victimPed))
    
    -- 检测受害者是否有 "Moonlight_MFTitle" 称号
    local victimTitle = GetPlayerTitle(NetworkGetPlayerIndexFromPed(victimPed)) -- 假设有一个函数用来获取称号
    if victimTitle == "Moonlight_MFTitle" then
        victimName = victimName .. ' [Moonlight_MFTitle]' -- 显示称号
    end

    if IsPedAPlayer(killerPed) then
        local killerName = GetPlayerName(NetworkGetPlayerIndexFromPed(killerPed))
        
        -- 检测杀手是否有 "Moonlight_MFTitle" 称号
        local killerTitle = GetPlayerTitle(NetworkGetPlayerIndexFromPed(killerPed)) -- 假设有一个函数用来获取称号
        if killerTitle == "Moonlight_MFTitle" then
            killerName = killerName .. ' [Moonlight_MFTitle]' -- 显示称号
        end

        TriggerServerEvent("NN-log:server:CreateLog", "note", "杀人事件☠", "red", ('玩家 "%s" 杀死了 "%s"'):format(killerName, victimName))
    else
        TriggerServerEvent("NN-log:server:CreateLog", "note", "自杀事件")
    end
end

### 代码解释
- 使用 `GetPlayerTitle` 函数(假设该函数存在)来获取玩家的称号。
- 在构建玩家名字字符串时,增加了对应的称号信息。
- 如果杀手或受害者拥有称号 "Moonlight_MFTitle",则在其名字旁边显示该称号。

### 注意事项
- 需要确保有一个合适的方法(如 `GetPlayerTitle`)来获取玩家的称号。你可能需要根据你的FiveM服务进行修改,确保获取称号的逻辑正常运行。
- 代码的其他部分应该放在 `server.lua` 中,因为涉及到服务器事件的触发和日志记录。
回复

使用道具 举报

文明发言,和谐互动
文明发言,和谐互动
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|FiveM技术教程分享 ( 冀ICP备2021005225号-1 ) |网站地图

GMT+8, 2025-6-6 15:23 , Processed in 0.074804 second(s), 9 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

© 2001-2013 ELITE论坛【技术无价-分享快乐】

快速回复 返回顶部 返回列表