• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Plugin] Using MySQL R41-4
#1
Hello guys, I programmed some samp servers a long time ago and recently I started programming again just for fun.

However, I always programmed using a rescue system in '.ini' and I am creating a gamemode in mysql and I would like to clarify some doubts on the subject.



1 - Is it recommended and necessary to use mysql in the samp? What are its advantages over '.ini' rescue systems?



2 - In relation to saving data from the server and players in mysql, it is interesting to save the data of the player only when the player leaves the server, or to save this data for each operation that the player does (example: the player buys an item and then the game already saves that data)



Thanks for the attention of those who read this topic xD!



Sorry for my bad English, I used google translator for some things.
  Reply
#2
1) It's not necessary to use MySQL. In a lot of cases it's not even the best solution. How you store the data depends on the data you are storing, how frequently it will be accessed and modified, and the required access to that data. For example, will this data need to be fetched, updated, or displayed from another source; like a forum or control panel?



All these questions should be evaluated. Player data is usually stored in a database for its speed on large data sets and overall flexibility. However if you want to store server configuration settings, that would be better suited in a configuration text file.



2) This also depends on the data. Something that will update frequently (kills, deaths, etc) should be stored in memory and written to the database later. Everything else (passwords, security questions, etc) should be updated immediately.
  Reply
#3
(2021-01-13, 04:49 AM)Bakr Wrote: 1) It's not necessary to use MySQL. In a lot of cases it's not even the best solution. How you store the data depends on the data you are storing, how frequently it will be accessed and modified, and the required access to that data. For example, will this data need to be fetched, updated, or displayed from another source; like a forum or control panel?



All these questions should be evaluated. Player data is usually stored in a database for its speed on large data sets and overall flexibility. However if you want to store server configuration settings, that would be better suited in a configuration text file.



2) This also depends on the data. Something that will update frequently (kills, deaths, etc) should be stored in memory and written to the database later. Everything else (passwords, security questions, etc) should be updated immediately.

I'm not so sure about 2...?

I'm pretty sure MySQL can easily handle thousands of UPDATE queries per second on a server that's running 2 core CPU :)



So, I recommend using MySQL over file-based systems for all of the user data and updating them the same moment they change.



MySQL has A LOT of useful features too, like event scheduler, triggers, views,...tl;dr: SQL is much bigger and much more complex language than Pawn so you'll be amazed what you can do without even having any performance impacts on the samp server itself.



For example, let's say you need to look for all of the items owned by offline player - John. That'd be a simple 1-line SELECT query and without any effort you'd have ALL of the data you need whereas INI'd take a lot of effort just to open every file (because the player is offline) and match it up using Pawn VM (like using strcmp to see if the player is item's owner) (which is much much slower than the SQL)
Using Pawn.CMD?

If you're doing so, this is the very first sign that you absolutely shouldn't utilize your all powerful P-Code knowledge in any of the scripting discussion topics.
  Reply
#4
(2021-01-13, 07:07 AM)Pinch Wrote: I'm not so sure about 2...?

I'm pretty sure MySQL can easily handle thousands of UPDATE queries per second on a server that's running 2 core CPU :)

This is true. But why over utilize something when it's not necessary?



(2021-01-13, 07:07 AM)Pinch Wrote:

So, I recommend using MySQL over file-based systems for all of the user data and updating them the same moment they change.



MySQL has A LOT of useful features too, like event scheduler, triggers, views,...tl;dr: SQL is much bigger and much more complex language than Pawn so you'll be amazed what you can do without even having any performance impacts on the samp server itself.



For example, let's say you need to look for all of the items owned by offline player - John. That'd be a simple 1-line SELECT query and without any effort you'd have ALL of the data you need whereas INI'd take a lot of effort just to open every file (because the player is offline) and match it up using Pawn VM (like using strcmp to see if the player is item's owner) (which is much much slower than the SQL)

This goes back to point 1 - it depends on the data and how it will be used.
  Reply
#5
If you don''t know why you need mysql you prob. don't need it.

If you don't plan on having 50 players or so online you'r fine using ".ini"
Actually scratch that i know project that have ~200 players and use ini...

You should learn it and use it cuz it will be useful in the future.

I persionally use a mix of ".ini" SQL, MySQL.

Basic config/info files - ini
Things that i don't need to know about in ACP - SQL ( World objects, House objects for ex )
Things that i need for Admin Controll Panel/User Controll panel - MySQL ( User data, job data, business data etc etc )
  Reply


Forum Jump: