Hello, this is my first post on this platform. I’ve been trying to use the esx_adminplus script(GitHub - ali-exacute/esx_adminplus: Administrator commands for ESX 1.2) but for some reason everytime that it looks for xPlayer that value is nil. Any idea why this could be? Thanks in advance.
Hello XPlayer must have a definition most of the time in a server.lua it is formulated like this
local xPlayer = ESX.GetPlayerFromId(source)
But your script must surely take information from another player then
In your server.lua
RegisterServerEvent('nametriggerserver')
AddEventHandler('nametriggerserver', function(source)
local xPlayer = ESX.GetPlayerFromId(source)
in your client.lua
local id = GetPlayerServerId(Player Target)
in client.lua when trigger server funtion
TriggerServerEvent('nametriggerserver', id)
Hello @Musstyy ,thanks for your reply. I am doing that exact same thing. I am using the legacyfuel script with no changes and I get this error: @LegacyFuel/source/fuel_server.lua attempt to index a nil value (local ‘xPlayer’). The code that is referring to is this one:
ESX = nil
if Config.UseESX then
TriggerEvent(‘esx:getSharedObject’, function(obj) ESX = obj end)
RegisterServerEvent('fuel:pay')
AddEventHandler('fuel:pay', function(price)
local xPlayer = ESX.GetPlayerFromId(source)
local amount = ESX.Math.Round(price)
print(price)
print(xPlayer)
if price > 0 then
xPlayer.removeMoney(amount)
end
end)
end
Did you try to delete this line if Config.UseESX then
?
Yup, I deleted that if statement and its still nil sadly.
Do you try this ?
That solves the error but it still lets me refuel the tank/jerry can without checking for my current money.
For check the money do that
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
if xPlayer.getMoney() >= price then
xPlayer.removeMoney(price)
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.