-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: (BasicItem\client\main.lua) accessing undefined variable
- Loading branch information
1 parent
1eb13fa
commit 2d0ee2f
Showing
1 changed file
with
62 additions
and
58 deletions.
There are no files selected for viewing
120 changes: 62 additions & 58 deletions
120
server-data/resources/[esx_addons]/BasicItem/client/main.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,82 @@ | ||
local closestDistance, closestPlayer = {}, {} | ||
local closestDistance, closestPlayer, playerReceiveCard = {}, {}, {} | ||
|
||
ESX = exports["es_extended"]:getSharedObject() | ||
|
||
RegisterNetEvent("IDCARD:USE") | ||
AddEventHandler("IDCARD:USE", function() | ||
closestPlayer, closestDistance = ESX.Game.GetClosestPlayer() | ||
if closestDistance ~= -1 and closestDistance <= 2.0 then | ||
ESX.ShowNotification((_LConfig.playerReceiveCard):format(GetPlayerName(closestPlayer))) | ||
TriggerServerEvent("jsfour-idcard:open", GetPlayerServerId(PlayerId()), GetPlayerServerId(closestPlayer)) | ||
else | ||
ESX.ShowNotification(_LConfig.nobodyFound) | ||
TriggerServerEvent("jsfour-idcard:open", GetPlayerServerId(PlayerId()), GetPlayerServerId(PlayerId())) | ||
end | ||
Wait(1) | ||
closestPlayer, closestDistance = ESX.Game.GetClosestPlayer() | ||
if closestDistance ~= -1 and closestDistance <= 2.0 then | ||
ESX.ShowNotification((_LConfig.playerReceiveCard):format(GetPlayerName(closestPlayer))) | ||
TriggerServerEvent("jsfour-idcard:open", GetPlayerServerId(PlayerId()), GetPlayerServerId(closestPlayer)) | ||
else | ||
ESX.ShowNotification(_LConfig.nobodyFound) | ||
TriggerServerEvent("jsfour-idcard:open", GetPlayerServerId(PlayerId()), GetPlayerServerId(PlayerId())) | ||
end | ||
Wait(1) | ||
end) | ||
|
||
RegisterNetEvent("DMVCARD:USE") | ||
AddEventHandler("DMVCARD:USE", function() | ||
closestPlayer, closestDistance = ESX.Game.GetClosestPlayer() | ||
if closestDistance ~= -1 and closestDistance <= 2.0 then | ||
ESX.ShowNotification((playerReceiveCard):format(GetPlayerName(closestPlayer))) | ||
TriggerServerEvent("jsfour-idcard:open", GetPlayerServerId(PlayerId()), GetPlayerServerId(closestPlayer), "driver") | ||
else | ||
ESX.ShowNotification(_LConfig.nobodyFound) | ||
TriggerServerEvent("jsfour-idcard:open", GetPlayerServerId(PlayerId()), GetPlayerServerId(PlayerId()), "driver") | ||
end | ||
Wait(1) | ||
closestPlayer, closestDistance = ESX.Game.GetClosestPlayer() | ||
if closestDistance ~= -1 and closestDistance <= 2.0 then | ||
ESX.ShowNotification((playerReceiveCard):format(GetPlayerName(closestPlayer))) | ||
TriggerServerEvent("jsfour-idcard:open", GetPlayerServerId(PlayerId()), GetPlayerServerId(closestPlayer), "driver") | ||
else | ||
ESX.ShowNotification(_LConfig.nobodyFound) | ||
TriggerServerEvent("jsfour-idcard:open", GetPlayerServerId(PlayerId()), GetPlayerServerId(PlayerId()), "driver") | ||
end | ||
Wait(1) | ||
end) | ||
|
||
RegisterNetEvent("WCARD:USE") | ||
AddEventHandler("WCARD:USE", function() | ||
closestPlayer, closestDistance = ESX.Game.GetClosestPlayer() | ||
if closestDistance ~= -1 and closestDistance <= 2.0 then | ||
ESX.ShowNotification((playerReceiveCard):format(GetPlayerName(closestPlayer))) | ||
TriggerServerEvent("jsfour-idcard:open", GetPlayerServerId(PlayerId()), GetPlayerServerId(closestPlayer), "weapon") | ||
else | ||
ESX.ShowNotification(_LConfig.nobodyFound) | ||
TriggerServerEvent("jsfour-idcard:open", GetPlayerServerId(PlayerId()), GetPlayerServerId(PlayerId()), "weapon") | ||
end | ||
Wait(1) | ||
closestPlayer, closestDistance = ESX.Game.GetClosestPlayer() | ||
if closestDistance ~= -1 and closestDistance <= 2.0 then | ||
ESX.ShowNotification((playerReceiveCard):format(GetPlayerName(closestPlayer))) | ||
TriggerServerEvent("jsfour-idcard:open", GetPlayerServerId(PlayerId()), GetPlayerServerId(closestPlayer), "weapon") | ||
else | ||
ESX.ShowNotification(_LConfig.nobodyFound) | ||
TriggerServerEvent("jsfour-idcard:open", GetPlayerServerId(PlayerId()), GetPlayerServerId(PlayerId()), "weapon") | ||
end | ||
Wait(1) | ||
end) | ||
|
||
RegisterNetEvent("JOBCARD:USE") | ||
AddEventHandler("JOBCARD:USE", function(user) | ||
closestPlayer, closestDistance = ESX.Game.GetClosestPlayer() | ||
ESX = exports["es_extended"]:getSharedObject() | ||
ESX.PlayerData = ESX.GetPlayerData() | ||
closestPlayer, closestDistance = ESX.Game.GetClosestPlayer() | ||
ESX = exports["es_extended"]:getSharedObject() | ||
ESX.PlayerData = ESX.GetPlayerData() | ||
|
||
local userData = user[1] | ||
local name = userData.firstname | ||
local name2 = userData.lastname | ||
local userData = user[1] | ||
local name = userData.firstname | ||
local name2 = userData.lastname | ||
|
||
if closestDistance ~= -1 and closestDistance <= 2.0 then | ||
ESX.ShowNotification(TranslateCap("you_have_licensed"):format(GetPlayerName(closestPlayer))) | ||
for job, info in pairs(_LConfig.jobs) do | ||
if ESX.PlayerData.job.name == job then | ||
local msg = info.message | ||
local DataPlayer = ESX.PlayerData | ||
TriggerServerEvent("JOBCARD:MSG", GetPlayerServerId(closestPlayer), msg, name, name2, DataPlayer) | ||
return | ||
end | ||
end | ||
local msg = _LConfig.defaultJobMessage | ||
local DataPlayer = ESX.PlayerData | ||
TriggerServerEvent("JOBCARD:MSG", GetPlayerServerId(closestPlayer), msg, name, name2, DataPlayer) | ||
else | ||
ESX.ShowNotification(_LConfig.nobodyFound) | ||
for job, info in pairs(_LConfig.jobs) do | ||
if ESX.PlayerData.job.name == job then | ||
ESX.ShowNotification((info.message):format(name, name2, ESX.PlayerData.job.label, ESX.PlayerData.job.grade_label)) | ||
return | ||
end | ||
end | ||
ESX.ShowNotification((_LConfig.defaultJobMessage):format(name, name2, ESX.PlayerData.job.label, ESX.PlayerData.job.grade_label)) | ||
end | ||
Wait(1) | ||
if closestDistance ~= -1 and closestDistance <= 2.0 then | ||
ESX.ShowNotification(TranslateCap("you_have_licensed"):format(GetPlayerName(closestPlayer))) | ||
for job, info in pairs(_LConfig.jobs) do | ||
if ESX.PlayerData.job.name == job then | ||
local msg = info.message | ||
local DataPlayer = ESX.PlayerData | ||
TriggerServerEvent("JOBCARD:MSG", GetPlayerServerId(closestPlayer), msg, name, name2, DataPlayer) | ||
return | ||
end | ||
end | ||
local msg = _LConfig.defaultJobMessage | ||
local DataPlayer = ESX.PlayerData | ||
TriggerServerEvent("JOBCARD:MSG", GetPlayerServerId(closestPlayer), msg, name, name2, DataPlayer) | ||
else | ||
ESX.ShowNotification(_LConfig.nobodyFound) | ||
for job, info in pairs(_LConfig.jobs) do | ||
if ESX.PlayerData.job.name == job then | ||
ESX.ShowNotification( | ||
(info.message):format(name, name2, ESX.PlayerData.job.label, ESX.PlayerData.job.grade_label) | ||
) | ||
return | ||
end | ||
end | ||
ESX.ShowNotification( | ||
(_LConfig.defaultJobMessage):format(name, name2, ESX.PlayerData.job.label, ESX.PlayerData.job.grade_label) | ||
) | ||
end | ||
Wait(1) | ||
end) |