12.02.2016, 20:51
Only update what needs to be updated ==> if your server-variable changes, use a small query to update that value in the database too.
Don't update 100 values in the database when only 1 value changes.
For a file-system, yes, you NEED to do that, because you probably need to overwrite the entire file.
But you're using a DATABASE, which has the possibility to change value per value.
I always get furious when people use such huge queries for saving everything at once, and then they complain why it's so slow or they get silly errors, just because they didn't see a little mistake like a misplaced comma or whatever.
But they get those errors because their query is a huge block of text and you can't spot the error by just looking at it.
Split your query over your entire gamemode and use functions to make it easier.
http://forum.sa-mp.com/showpost.php?...31&postcount=5
This is an example from my own code.
Instead of using GivePlayerMoney, I'm using that function listed there.
It changes the values in the server-memory and it also updates the correct values in the database using a small query.
It's very easy to debug and easy to follow and you won't make mistakes that often.
It also uses threaded queries, so it doesn't slow down the script at all, not even when this function is called every second per player for example (that won't happen anyway because nobody's money should change that often).
Threaded queries are executed in the background and don't let your script wait until the query has been executed completely.
Don't update 100 values in the database when only 1 value changes.
For a file-system, yes, you NEED to do that, because you probably need to overwrite the entire file.
But you're using a DATABASE, which has the possibility to change value per value.
I always get furious when people use such huge queries for saving everything at once, and then they complain why it's so slow or they get silly errors, just because they didn't see a little mistake like a misplaced comma or whatever.
But they get those errors because their query is a huge block of text and you can't spot the error by just looking at it.
Split your query over your entire gamemode and use functions to make it easier.
http://forum.sa-mp.com/showpost.php?...31&postcount=5
This is an example from my own code.
Instead of using GivePlayerMoney, I'm using that function listed there.
It changes the values in the server-memory and it also updates the correct values in the database using a small query.
It's very easy to debug and easy to follow and you won't make mistakes that often.
It also uses threaded queries, so it doesn't slow down the script at all, not even when this function is called every second per player for example (that won't happen anyway because nobody's money should change that often).
Threaded queries are executed in the background and don't let your script wait until the query has been executed completely.

