Adding money when player is offline? is this normal? [SOLVED]

Hi everyone I’m writing a script for a lottery that adds money to the player, I’m doing this through ESX.GetPlayerFromIdentifier (X) .addMoney (X), but I noticed when a player is not online it doesn’t work , as you can see in the photo I have a table with (player objects in it, requested via the database) player 1 is offline and player 2 is online, when I run the for loop with the player who is online (photo on the left can you can see that everything works in the console and also in game), but in the other photo on the right I use player 1 in the for loop which is not online and then the for loop does not work, it does not print the text after it which indicates that there is an error, so my question is, if you want to add money to someone who is offline, do you have to do this through a sql statement?

You can’t add money to offline players using these functions, as .addMoney reffers to xPlayer.addMoney (xPlayer reffers to source, a source only exists when a player is online, otherwise source doesn’t exists). What you’re doing now won’t work at all.

If you want to add money to an account when they’re offline, the easiest way to do that would be using a MySQL update query with a where clause on player identifier.

Because I see you’re Dutch, I’ll also explain in Dutch:
Je kan via deze manier geen geld geven, aangezien je hier werkt met een source (ID). Een source is enkel aanwezig wanneer een speler actief is binnen het netwerk, anders bestaat die niet.
Wanneer je offline geld wilt toevoegen aan een speler, zal je dit via een update query moeten doen die geld toevoegt bij de speler, met een where clause op (steam) identifier.

Thanks for the information, yes i speak dutch i’m from belgium, and indeed the players needs to be online for this, i quickly wrote a script that checks if a player is online or not, if he is online addmoney via esx function like i wrote in the code if he is not online, i’ll do an update query with his parameters, it all works now :wink:

Perfect, nice to hear :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.