Array element from lua

‘Jobs’ needs a string key to access it
and ‘grades’ needs a numerical index

Player .PlayerData .Jobs [job] .grades [grade] .name

TriggerClientEvent('chatMessage', source, "SYSTEM", "warning", "Baan: "..Player.PlayerData.job.label .. ' - ' ..Player.PlayerData.Jobs[job].grades[grade].name)


I’m assuming that somehow within your game engine, these values get parsed into PlayerData. That’ll depend on the functions contained within fivem, and that you’ve used them properly. Otherwise, to access the raw table data, it’s more like this:

print( QBShared.Jobs['police'].label )

Politie

print( QBShared.Jobs['police'].grades[0].name )

Politie – Student

print( QBShared.Jobs['police'].grades[0].payment )

200


if the game rearranges those during import into PlayerData, it might be

Player.PlayerData[job][grade].name

but it’s very likely it remains in the original syntax illustrated above.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top