things like PlayerJob[MAX_PLAYERS] sadly doesn’t work here, as player ids are sort-of unique. (If you join the server with ID 1 and leave, the server won’t see ID 1 until you restart it)
Do I need functions on each client.lua
Not if you don’t make them local, BUT the functions are resource-bound. If you have a notification function, you will need that notification function in each resource.
Could someone explain how it works in LUA with saving global variables and passing these between clients?
I was trying to do this, via means of PlayerLoading
When you say events to send that data?
How would I do this:
local playerid = source
local adminlevel = exports.PlayerLoading:GetPlayerAdminLevel(playerId)
TriggerClientEvent('chat:addMessage', playerid, {
args = { 'print 1' }
})
print('print 1')
if adminlevel < 1 then
TriggerClientEvent('chat:addMessage', playerid, {
args = { 'You are not authorized to use this command.' }
})
return
end
At present I am loading the admin level with PlayerLoading:
local pData = {
PlayerName = name,
AdminLevel = 0,
Job = 0, -- Set the initial admin level to 0 (non-admin)
-- Add more player data parameters as needed
}
if name == "Grant" then
pData.AdminLevel = 1
end
PlayerData[playerid] = pData -- Store the player data in the global table
print('Admin Level: ' .. PlayerData[playerid].AdminLevel)
This is causing great issue, passing between resources.