Show society money on hud ... I'm close to it..help

Hi guys,

I’m running a server and I’m trying to make it so when you’re the boss of a whitelisted job, it will display the society account money on the hud (the hud part is not really relevant since only obtaining the actual account money is what I’m trying to achieve right now…)

I know my basic function to determine if the player is the boss of the company works, you can see it in the screenshot below.

Here is the associated code for this part.

    	if data.job.grade_name == "boss" then
	--local society = "society_"..data.job.name
	--TriggerServerEvent('esx_addonaccount:getSharedAccount', society, function(account)
	SendNUIMessage({action = "setValue", key = "societymoney", value = " |  🏢 BOSS "})
	--end)
end

As soon as I remove the commented lines and make it like this :

    	if data.job.grade_name == "boss" then
	local society = "society_"..data.job.name
	TriggerServerEvent('esx_addonaccount:getSharedAccount', society, function(account)
       if account ~= nil then 
       account = account
	SendNUIMessage({action = "setValue", key = "societymoney", value = " |  🏢 "..account.money})
	end
        end)
end

Its not working and keep giving me error related to my trigger I use to get the society money info…

I don’t want a piece of code, I’d like some inputs \ guidance towards finding how to do it by myself.

Thanks !

Hi,

I’m not sure if you can use callback in TriggerServerEvent now, but I know you can do it with a special ESX function. I don’t use this framework but it’s something like:

ESX.TriggerServerCallback("eventName", function() ... end, pramas)

Do you think it could look like something similar to this :

if data.job.grade_name == "boss" then
	local society = "society_"..data.job.name

ESX.TriggerServerCallback("esx_addonaccoun:getSharedAccount", function(account)
    If account ~= nil then
     account = account
     SendNUIMessage({action= "setValue", key = "society money", value = "$ "..account.money})
     end
end, society)

end

Otherwise it means I have no idea what I should put in the function() part of this lol.

Thanks for your reply !

Yes like that, just try it :wink:

Of course I will try this !

I might have found another ServerCallback that returns the society money with esx_society directly…

I will try the one I just posted and see what happens first tho.

Thanks again

did it work?

Did it work? i have the same problem…

1 Like

Have you made it work?

does it work???

whats the name of that hud?

Um why are you doing account = account … You are saying this = this. It was already equal = this…
Do you intend for that to be something like local acct = account.

1 Like