Skip to content

Commit

Permalink
fix: (BasicItem\client\main.lua) accessing undefined variable
Browse files Browse the repository at this point in the history
  • Loading branch information
bitpredator committed Apr 7, 2024
1 parent 1eb13fa commit 2d0ee2f
Showing 1 changed file with 62 additions and 58 deletions.
120 changes: 62 additions & 58 deletions server-data/resources/[esx_addons]/BasicItem/client/main.lua
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)

0 comments on commit 2d0ee2f

Please sign in to comment.