所以当我尝试在商店买东西时,它只是给我这个错误。如何解决这个问题?代码:
RegisterServerEvent('esx_shops:buyItem')
AddEventHandler('esx_shops:buyItem', function(itemName, amount, zone)
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
local sourceItem = xPlayer.getInventoryItem(itemName)
amount = ESX.Round(amount)
-- is the player trying to exploit?
if amount < 0 then
print('esx_shops: ' .. xPlayer.identifier .. ' attempted to exploit the shop!')
return
end
错误:
SCRIPT ERROR: @esx_supermarket/server/main.lua:68: attempt to index a nil value (local 'xPlayer')