SA-MP Forums Archive
Something about MySQL - 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: Something about MySQL (/showthread.php?tid=580100)



Something about MySQL - Sime30 - 02.07.2015

Hey guys

So I have a single question regarding MySQL.

Can you edit some numbers/words in a field WHILE that database is open and running along with a server?

Example 1: A player is connected and playing. Can you edit some things in his account? Will it stay saved(In my opinion it should not) and will it cause a bug doing so?

Example 2: A player is not connected. Can you edit some things in his account? Will it cause a bug?


For all these years I have been editing MySQL database by first shutting down the server and then editing the database. I don't know why but I always thought you can't edit something while is opened.

All answers appreciated!



Re: Something about MySQL - Diovis - 02.07.2015

Yes BUT, you must be able to update whatever you just changed in real time

For example, let's say you have a column for health, you can update the value and then use something like SetPlayerHealth to update it in game as well

And you can edit whatever you want on their offline account, as when they connect, it will request the information from the database and load it in so it would be the same as if they logged out and it saved


Re: Something about MySQL - Sime30 - 02.07.2015

Okay, I get it.
Basically, it's better doing stuff while they are offline because fields can be overwritten by them while they are in game. So no bugs should pop up while I edit an opened database?


Re: Something about MySQL - Diovis - 02.07.2015

Quote:
Originally Posted by Sime30
Посмотреть сообщение
Okay, I get it.
Basically, it's better doing stuff while they are offline because fields can be overwritten by them while they are in game. So no bugs should pop up while I edit an opened database?
That's not quite how it works, i'm trying to find an easy way to explain this to you

Alright let's say the player is in game, and they receive 500 dollars. It will update that value and store it temporarily, then when the player disconnects, it will save all those values in the MySQL database. That's why sometimes when player/server crashes it doesn't save properly and their accounts are set back.

It's all a matter of which one saves last, if you edit a value, and the player is online but then he/she logs off, it will overwrite it with that last save from the server


Re: Something about MySQL - Sime30 - 02.07.2015

Yes, I know that. "THE LAST ONE WINS" haha

I got that even though I may seemed like I didn't. Only thing is, I've seen bugs coming that way on some servers. They edited a live running database and crap happened


Re: Something about MySQL - Sime30 - 02.07.2015

So is it then okay to edit an offline account/data that is not currently being used in a running database?


Re: Something about MySQL - Diovis - 02.07.2015

Quote:
Originally Posted by Sime30
Посмотреть сообщение
So is it then okay to edit an offline account/data that is not currently being used in a running database?
Should be fine, yes, to prevent any problems, don't edit big things while the server is running, like businesses


Re: Something about MySQL - Sime30 - 02.07.2015

Thanks , you've been of great help