我正在努力在我的 FiveM 服务器上成功触发服务器事件。或者它可能被触发但服务器事件不正确。但是我没有收到任何错误,我不知道要修复什么...
服务器端
RegisterServerEvent('carwash:pay')
AddEventHandler('carwash:pay', function()
local _source = source
local price = 20
local identifier = GetPlayerIdentifier(_source)
MySQL.Async.fetchAll("SELECT * FROM economy WHERE identifier = @identifier", {
['@identifier'] = identifier
}, function(result)
if result >= 20 then
MySQL.Async.execute('UPDATE economy SET cash = cash - @price WHERE identifier = @identifier',
{ ['@identifier'] = identifier, ['@price'] = price }
)
end
end)
end)
客户端
TriggerServerEvent('carwash:pay')