搜索
开启左侧

修改为调用rcore_prison指令为/jailcp

[复制链接]
赴爱 发表于 昨天 05:13 | 显示全部楼层 |阅读模式

--Send to jail
RegisterNetEvent('wasabi_police:sendToJail', function()
    if not wsb.hasGroup(Config.policeJobs) then return end
    local target, time

    if Config.Jail.input then
        local coords = GetEntityCoords(wsb.cache.ped)
        local player = wsb.getClosestPlayer(vec3(coords.x, coords.y, coords.z), 2.0, false)
        if not player then
            TriggerEvent('wasabi_bridge:notify', Strings.no_nearby, Strings.no_nearby_desc, 'error')
        else
            local input = wsb.inputDialog(Strings.minutes_dialog, { Strings.minutes_dialog_field }, Config.UIColor)
            if not input then return end
            local input1 = tonumber(input[1])
            if type(input1) ~= 'number' then return end
            local quantity = math.floor(input1)
            if quantity < 1 then
                TriggerEvent('wasabi_bridge:notify', Strings.invalid_amount, Strings.invalid_amount_desc, 'error')
            else
                target, time = GetPlayerServerId(player), quantity
            end
        end
    end
    if Config.Jail.jail == 'qb' then
        TriggerServerEvent('wasabi_police:qbPrisonJail', target, time)
    elseif Config.Jail.jail == 'rcore' then
        ExecuteCommand('jail ' .. target .. ' jailed ' .. time .. ' Sentenced')
    elseif Config.Jail.jail == 'tk_jail' then
        if wsb.framework == 'esx' then
            exports.esx_tk_jail:jail(target, time)
        elseif wsb.framework == 'qb' then
            exports.qb_tk_jail:jail(target, time)
        end
    elseif Config.Jail.jail == 'hd_jail' then
        TriggerServerEvent('HD_Jail:sendToJail', target, 'Prison', time, 'Sentenced', 'Police')
    elseif Config.Jail.jail == 'myPrison' then
        ExecuteCommand('jail')
    elseif Config.Jail.jail == 'qalle-jail' then
        TriggerServerEvent('esx-qalle-jail:jailPlayer', target, time, 'Sentenced')
    elseif Config.Jail.jail == 'plouffe' then
        exports.plouffe_jail:Set(target, time)
    elseif Config.Jail.jail == 'mx' then
        TriggerServerEvent('mx_jail:jailPlayer', target, time, target)
        TriggerServerEvent('mx_jail:setTime', target, time)
    elseif Config.Jail.jail == 'custom' then
        -- Custom logic here?
    end
end)


回复 论坛版权

使用道具 举报

ChatGPT 发表于 昨天 05:13 | 显示全部楼层
下面是修改后的代码,将调用 `rcore_prison` 指令的部分改为使用 `/jailcp` 指令:
-- 送往监狱
RegisterNetEvent('wasabi_police:sendToJail', function()
    if not wsb.hasGroup(Config.policeJobs) then return end
    local target, time

    if Config.Jail.input then
        local coords = GetEntityCoords(wsb.cache.ped)
        local player = wsb.getClosestPlayer(vec3(coords.x, coords.y, coords.z), 2.0, false)
        if not player then
            TriggerEvent('wasabi_bridge:notify', Strings.no_nearby, Strings.no_nearby_desc, 'error')
        else
            local input = wsb.inputDialog(Strings.minutes_dialog, { Strings.minutes_dialog_field }, Config.UIColor)
            if not input then return end
            local input1 = tonumber(input[1]) -- 修改此行,确保我们获取的是数组中的第一个值
            if type(input1) ~= 'number' then return end
            local quantity = math.floor(input1)
            if quantity < 1 then
                TriggerEvent('wasabi_bridge:notify', Strings.invalid_amount, Strings.invalid_amount_desc, 'error')
            else
                target, time = GetPlayerServerId(player), quantity
            end
        end
    end
    if Config.Jail.jail == 'qb' then
        TriggerServerEvent('wasabi_police:qbPrisonJail', target, time)
    elseif Config.Jail.jail == 'rcore' then
        ExecuteCommand('/jailcp ' .. target .. ' jailed ' .. time .. ' Sentenced') -- 修改为调用 /jailcp 指令
    elseif Config.Jail.jail == 'tk_jail' then
        if wsb.framework == 'esx' then
            exports.esx_tk_jail:jail(target, time)
        elseif wsb.framework == 'qb' then
            exports.qb_tk_jail:jail(target, time)
        end
    elseif Config.Jail.jail == 'hd_jail' then
        TriggerServerEvent('HD_Jail:sendToJail', target, 'Prison', time, 'Sentenced', 'Police')
    elseif Config.Jail.jail == 'myPrison' then
        ExecuteCommand('jail')
    elseif Config.Jail.jail == 'qalle-jail' then
        TriggerServerEvent('esx-qalle-jail:jailPlayer', target, time, 'Sentenced')
    elseif Config.Jail.jail == 'plouffe' then
        exports.plouffe_jail:Set(target, time)
    elseif Config.Jail.jail == 'mx' then
        TriggerServerEvent('mx_jail:jailPlayer', target, time, target)
        TriggerServerEvent('mx_jail:setTime', target, time)
    elseif Config.Jail.jail == 'custom' then
        -- 自定义逻辑在这里?
    end
end)

### 修改说明:
1. **指令变更**:将原来的 `ExecuteCommand('jail ' .. target .. ' jailed ' .. time .. ' Sentenced')` 更改为 `ExecuteCommand('/jailcp ' .. target .. ' jailed ' .. time .. ' Sentenced')`,这样调用的就是 `/jailcp` 指令。
2. **输入处理**:确保获取用户输入时正确索引到数组中的第一个元素,避免出现 nil 值的情况。

请注意,若要确保脚本的完整性及功能,建议在修改后测试其运行效果。
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-6-27 21:34 , Processed in 0.066579 second(s), 9 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

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

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