SA-MP Forums Archive
MySQL queries question - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MySQL queries question (/showthread.php?tid=446815)



MySQL queries question - ReLoaD90 - 27.06.2013

Hey SA:MP community! I've got some little questions about MySQL as I'm a beginner.

So - I have a MySQL R7-based account system but I'm wondering - let's say I would have 100 players online at once on my server(dreams lol). How should I save the account information? Should I save ALL the data when the player disconnects? Should I save only one field every time the variable for that field changes? Like everytime a player's money changes I should execute a query which saves the `Money` field in the database?

How and when do you save data using MySQL on your SA:MP server?


Re: MySQL queries question - Nick_Phelps - 27.06.2013

Well... From my learnings you will have to define it all in the script + the mysql data and tell it to copy the players data to a table based on their stats...


Re: MySQL queries question - DobbysGamertag - 27.06.2013

I say, which is what i do, make a function to save data, set a timer. for say, every 10 mins, save the data. Then after every crucial (house buying, money transfers etc) use the function.

If you didn't understand:

SaveData(playerid)

pawn Код:
CMD:something(playerid,params[])
{
    Stuff
    SaveData(playerid);
    return 1;
}
So, (personally) my opinion, create a function, and call it each time you need, as mentioned above.