@@ -417,6 +417,10 @@ if not Config.CustomInventory then
417417 if itemType == " item_standard" then
418418 local sourceItem = sourceXPlayer .getInventoryItem (itemName )
419419
420+ if not sourceItem then
421+ return
422+ end
423+
420424 if itemCount < 1 or sourceItem .count < itemCount then
421425 return sourceXPlayer .showNotification (TranslateCap (" imp_invalid_quantity" ))
422426 end
@@ -453,6 +457,10 @@ if not Config.CustomInventory then
453457 end
454458
455459 local _ , weapon = sourceXPlayer .getWeapon (itemName )
460+ if not weapon then
461+ return
462+ end
463+
456464 local _ , weaponObject = ESX .GetWeapon (itemName )
457465 itemCount = weapon .ammo
458466 local weaponComponents = ESX .Table .Clone (weapon .components )
@@ -485,6 +493,9 @@ if not Config.CustomInventory then
485493 end
486494
487495 local _ , weapon = sourceXPlayer .getWeapon (itemName )
496+ if not weapon then
497+ return
498+ end
488499
489500 if not targetXPlayer .hasWeapon (itemName ) then
490501 sourceXPlayer .showNotification (TranslateCap (" gave_weapon_noweapon" , targetXPlayer .name ))
@@ -511,12 +522,19 @@ if not Config.CustomInventory then
511522 local playerId = source
512523 local xPlayer = ESX .GetPlayerFromId (playerId )
513524
525+ if not xPlayer then
526+ return
527+ end
528+
514529 if itemType == " item_standard" then
515530 if not itemCount or itemCount < 1 then
516531 return xPlayer .showNotification (TranslateCap (" imp_invalid_quantity" ))
517532 end
518533
519534 local xItem = xPlayer .getInventoryItem (itemName )
535+ if not xItem then
536+ return
537+ end
520538
521539 if itemCount > xItem .count or xItem .count < 1 then
522540 return xPlayer .showNotification (TranslateCap (" imp_invalid_quantity" ))
@@ -532,6 +550,9 @@ if not Config.CustomInventory then
532550 end
533551
534552 local account = xPlayer .getAccount (itemName )
553+ if not account then
554+ return
555+ end
535556
536557 if itemCount > account .money or account .money < 1 then
537558 return xPlayer .showNotification (TranslateCap (" imp_invalid_amount" ))
@@ -547,6 +568,10 @@ if not Config.CustomInventory then
547568 if not xPlayer .hasWeapon (itemName ) then return end
548569
549570 local _ , weapon = xPlayer .getWeapon (itemName )
571+ if not weapon then
572+ return
573+ end
574+
550575 local _ , weaponObject = ESX .GetWeapon (itemName )
551576 -- luacheck: ignore weaponPickupLabel
552577 local weaponPickupLabel = " "
@@ -569,6 +594,11 @@ if not Config.CustomInventory then
569594 RegisterNetEvent (" esx:useItem" , function (itemName )
570595 local source = source
571596 local xPlayer = ESX .GetPlayerFromId (source )
597+
598+ if not xPlayer then
599+ return
600+ end
601+
572602 local count = xPlayer .getInventoryItem (itemName ).count
573603
574604 if count < 1 then
@@ -581,6 +611,10 @@ if not Config.CustomInventory then
581611 RegisterNetEvent (" esx:onPickup" , function (pickupId )
582612 local pickup , xPlayer , success = Core .Pickups [pickupId ], ESX .GetPlayerFromId (source )
583613
614+ if not xPlayer then
615+ return
616+ end
617+
584618 if not pickup then return end
585619
586620 local playerPickupDistance = # (pickup .coords - xPlayer .getCoords (true ))
623657ESX .RegisterServerCallback (" esx:getPlayerData" , function (source , cb )
624658 local xPlayer = ESX .GetPlayerFromId (source )
625659
660+ if not xPlayer then
661+ return
662+ end
663+
626664 cb ({
627665 identifier = xPlayer .identifier ,
628666 accounts = xPlayer .getAccounts (),
@@ -646,6 +684,10 @@ end)
646684ESX .RegisterServerCallback (" esx:getOtherPlayerData" , function (_ , cb , target )
647685 local xPlayer = ESX .GetPlayerFromId (target )
648686
687+ if not xPlayer then
688+ return
689+ end
690+
649691 cb ({
650692 identifier = xPlayer .identifier ,
651693 accounts = xPlayer .getAccounts (),
0 commit comments