@@ -60,7 +60,7 @@ AddEventHandler('playerSpawned', function()
6060 Citizen .Wait (1 )
6161 end
6262
63- local playerPed = GetPlayerPed ( - 1 )
63+ local playerPed = PlayerPedId ( )
6464
6565 -- Restore position
6666 if ESX .PlayerData .lastPosition ~= nil then
@@ -134,7 +134,7 @@ AddEventHandler('skinchanger:modelLoaded', function()
134134end )
135135
136136AddEventHandler (' esx:restoreLoadout' , function ()
137- local playerPed = GetPlayerPed ( - 1 )
137+ local playerPed = PlayerPedId ( )
138138
139139 RemoveAllPedWeapons (playerPed , true )
140140
206206
207207RegisterNetEvent (' esx:addWeapon' )
208208AddEventHandler (' esx:addWeapon' , function (weaponName , ammo )
209- local playerPed = GetPlayerPed ( - 1 )
209+ local playerPed = PlayerPedId ( )
210210 local weaponHash = GetHashKey (weaponName )
211211
212212 GiveWeaponToPed (playerPed , weaponHash , ammo , false , false )
215215
216216RegisterNetEvent (' esx:removeWeapon' )
217217AddEventHandler (' esx:removeWeapon' , function (weaponName , ammo )
218- local playerPed = GetPlayerPed ( - 1 )
218+ local playerPed = PlayerPedId ( )
219219 local weaponHash = GetHashKey (weaponName )
220220
221221 RemoveWeaponFromPed (playerPed , weaponHash )
@@ -239,12 +239,12 @@ AddEventHandler('esx:teleport', function(pos)
239239
240240 RequestCollisionAtCoord (pos .x , pos .y , pos .z )
241241
242- while not HasCollisionLoadedAroundEntity (GetPlayerPed ( - 1 )) do
242+ while not HasCollisionLoadedAroundEntity (PlayerPedId ( )) do
243243 RequestCollisionAtCoord (pos .x , pos .y , pos .z )
244244 Citizen .Wait (1 )
245245 end
246246
247- SetEntityCoords (GetPlayerPed ( - 1 ), pos .x , pos .y , pos .z )
247+ SetEntityCoords (PlayerPedId ( ), pos .x , pos .y , pos .z )
248248
249249end )
250250
@@ -300,7 +300,7 @@ AddEventHandler('esx:playEmote', function(emote)
300300
301301 Citizen .CreateThread (function ()
302302
303- local playerPed = GetPlayerPed ( - 1 )
303+ local playerPed = PlayerPedId ( )
304304
305305 TaskStartScenarioInPlace (playerPed , emote , 0 , false );
306306 Citizen .Wait (20000 )
313313RegisterNetEvent (' esx:spawnVehicle' )
314314AddEventHandler (' esx:spawnVehicle' , function (model )
315315
316- local playerPed = GetPlayerPed ( - 1 )
316+ local playerPed = PlayerPedId ( )
317317 local coords = GetEntityCoords (playerPed )
318318
319319 ESX .Game .SpawnVehicle (model , coords , 90.0 , function (vehicle )
325325RegisterNetEvent (' esx:spawnObject' )
326326AddEventHandler (' esx:spawnObject' , function (model )
327327
328- local playerPed = GetPlayerPed ( - 1 )
328+ local playerPed = PlayerPedId ( )
329329 local coords = GetEntityCoords (playerPed )
330330 local forward = GetEntityForwardVector (playerPed )
331331 local x , y , z = table.unpack (coords + forward * 1.0 )
384384RegisterNetEvent (' esx:pickupWeapon' )
385385AddEventHandler (' esx:pickupWeapon' , function (weaponPickup , weaponName ,ammo )
386386
387- local ped = GetPlayerPed ( - 1 )
387+ local ped = PlayerPedId ( )
388388 local playerPedPos = GetEntityCoords (ped , true )
389389 CreateAmbientPickup (GetHashKey (weaponPickup ), playerPedPos .x + 2.0 , playerPedPos .y , playerPedPos .z + 0.5 , 0 , ammo , 1 , false , true )
390390
@@ -394,7 +394,7 @@ RegisterNetEvent('esx:spawnPed')
394394AddEventHandler (' esx:spawnPed' , function (model )
395395
396396 model = (tonumber (model ) ~= nil and tonumber (model ) or GetHashKey (model ))
397- local playerPed = GetPlayerPed ( - 1 )
397+ local playerPed = PlayerPedId ( )
398398 local coords = GetEntityCoords (playerPed )
399399 local forward = GetEntityForwardVector (playerPed )
400400 local x , y , z = table.unpack (coords + forward * 1.0 )
@@ -403,7 +403,7 @@ AddEventHandler('esx:spawnPed', function(model)
403403
404404 RequestModel (model )
405405
406- while not HasModelLoaded (model ) do
406+ while not HasModelLoaded (model ) do
407407 Citizen .Wait (1 )
408408 end
409409
@@ -415,22 +415,16 @@ end)
415415
416416RegisterNetEvent (' esx:deleteVehicle' )
417417AddEventHandler (' esx:deleteVehicle' , function ()
418+ local playerPed = PlayerPedId ()
419+ local vehicle = ESX .Game .GetVehicleInDirection ()
418420
419- local playerPed = GetPlayerPed (- 1 )
420- local coords = GetEntityCoords (playerPed )
421-
422- if IsPedInAnyVehicle (playerPed , false ) then
423-
424- local vehicle = GetVehiclePedIsIn (playerPed , false )
425- ESX .Game .DeleteVehicle (vehicle )
426-
427- elseif IsAnyVehicleNearPoint (coords .x , coords .y , coords .z , 5.0 ) then
428-
429- local vehicle = GetClosestVehicle (coords .x , coords .y , coords .z , 5.0 , 0 , 71 )
430- ESX .Game .DeleteVehicle (vehicle )
431-
432- end
421+ if IsPedInAnyVehicle (playerPed , false ) then
422+ vehicle = GetVehiclePedIsIn (playerPed , false )
423+ end
433424
425+ if DoesEntityExist (vehicle ) then
426+ ESX .Game .DeleteVehicle (vehicle )
427+ end
434428end )
435429
436430
@@ -457,7 +451,7 @@ Citizen.CreateThread(function()
457451
458452 Citizen .Wait (1 )
459453
460- local playerPed = GetPlayerPed ( - 1 )
454+ local playerPed = PlayerPedId ( )
461455 local loadout = {}
462456 local loadoutChanged = false
463457
@@ -566,7 +560,7 @@ Citizen.CreateThread(function()
566560
567561 Citizen .Wait (0 )
568562
569- local playerPed = GetPlayerPed ( - 1 )
563+ local playerPed = PlayerPedId ( )
570564 local coords = GetEntityCoords (playerPed )
571565
572566 -- if there's no nearby pickups we can wait a bit to save performance
@@ -607,7 +601,7 @@ Citizen.CreateThread(function()
607601
608602 if ESX ~= nil and ESX .PlayerLoaded and PlayerSpawned then
609603
610- local playerPed = GetPlayerPed ( - 1 )
604+ local playerPed = PlayerPedId ( )
611605 local coords = GetEntityCoords (playerPed )
612606
613607 if not IsEntityDead (playerPed ) then
@@ -626,7 +620,7 @@ Citizen.CreateThread(function()
626620
627621 Citizen .Wait (1000 )
628622
629- local playerPed = GetPlayerPed ( - 1 )
623+ local playerPed = PlayerPedId ( )
630624
631625 if IsEntityDead (playerPed ) and PlayerSpawned then
632626 PlayerSpawned = false
0 commit comments