0

您好,一旦触发此事件并检查级别并给我正确的奖励,问题是 xplayer.blablabla 在 1 次单击中多次随机运行,有人知道有什么问题吗?

RegisterServerEvent('battlepass:rewardskteolekaramele')
AddEventHandler('battlepass:rewardskteolekaramele', function()
    local _source = source
    local xPlayer = ESX.GetPlayerFromId(source)
    local identifier = xPlayer.identifier
    MySQL.Async.fetchAll("SELECT level FROM levelxp_table WHERE identifier = @identifier", {
        ["identifier"] = GetPlayerIdentifiers(source)[1]},
        function(attributeti)
        print(attributeti[1].level)
        local resultar = attributeti[1].level
        if  attributeti[1].level == 1 or resultar == 11 or resultar == 21 or resultar == 31  or resultar == 41 or resultar == 51 or resultar == 61 or resultar == 71 or resultar == 81 or resultar == 91  then
            xPlayer.addMoney(50000)

        elseif  attributeti[1].level == 2 or resultar == 12 or resultar == 22 or resultar == 32 or resultar == 42 or resultar == 52 or resultar == 62 or resultar == 72 or resultar == 82 or resultar == 92   then
            xPlayer.addInventoryItem("WEAPON_FENNEC", 1)

            elseif  attributeti[1].level == 3 or resultar == 13 or resultar == 23 or  resultar == 33 or resultar == 43 or resultar == 53 or resultar == 63 or resultar == 73 or resultar == 83 or resultar == 93 then
            xPlayer.addAccountMoney('bitcoin_money', 10)



        end
    end)
    end)
4

1 回答 1

0

运行两次的不是if语句,而是事件。
我不确定这段代码到底是做什么的,因为 Lua 不是我的主要语言,但我确实有一些经验。

尝试在事件开始时放置一个print("event ran")。这样,您将能够判断if是运行两次的语句还是实际事件。

于 2021-12-21T05:19:01.637 回答