hey guys , i have a problem with this code ...
Citizen.CreateThread(function()
while true do
Citizen.Wait(500)
local x,y,z = table.unpack(GetEntityCoords(GetPlayerPed(-1), true))
local nearby = {}
for _,ped in pairs(GetNearbyPeds(x,y,z,100.0)) do
if DoesEntityExist(ped) and IsPedDeadOrDying(ped, 1) then
if GetPedSourceOfDeath(ped) == GetPlayerPed(-1) then
exports.XNLRankBar:Exp_XNL_AddPlayerXP(100)
TriggerServerEvent('AddXp', 100)
end
end
end
end
end)
i am making a zombie server and i can't figure out how to make players gain xp from killing zombies
( i have xnlrank bar in my server which is working perfectly with these two lines that make players earn xp )
exports.XNLRankBar:Exp_XNL_AddPlayerXP(100)
TriggerServerEvent('AddXp', 100)
I get an error "attempt to call a nil value ( global 'GetNearbyPeds' ) can you fix the code guys ?
um i also tried using this , i don't get errors and everything is fine but the xp and money are not coming .
Citizen.CreateThread(function ()
while true do
Citizen.Wait(1000)
local playerPed = PlayerPedId()
local targetPed = Citizen.InvokeNative(GetHashKey("u_m_y_zombie_01"), PlayerId(), Citizen.ReturnResultAnyway()) if HasEntityBeenDamagedByEntity(targetPed, playerPed, 1) then
if DoesEntityExist(targetPed) and IsPedDeadOrDying(targetPed, 1) then
if GetPedSourceOfDeath(targetPed) == GetPlayerPed(-1) then
exports.XNLRankBar:Exp_XNL_AddPlayerXP(100)
TriggerServerEvent('AddXp', 100)
local xPlayer = ESX.GetPlayerFromId(source)
xPlayer.addMoney(900) end
end
end
end
end)
all of this is not working -> i found a way to make things work -> check the solution