Jump to content

How to learn MTA-MySQL module?


Recommended Posts

Hello. :)

I want to learn to use MTA-MySQL module.

In the forum, I searched this topic: viewtopic.php?f=148&t=42067&hilit=mysql

But the topicstarter write:

This is outdated. It is recommended you use the internal db* functions instead

Is this tutorial not actual? I don't searched no more tutorials about MTA-MySQL. So how to learn this module?

I don't want to use db functions, because I read that it is slow (with big amount of query).

Thank you :)

Link to comment

It is MySQL also. Set first argument to "mysql". There are examples on wiki.

dbConnect 
-- Example from wiki: 
test_db = dbConnect("mysql", "dbname=frank;host=1.2.3.4", "username", "password", "share=1") 

Link to comment

Ok, thank you, I decided to use db functions.

But I have new question:

Why need to use elementData for players, if there is a database?

For example:

I need to save a value of player money. There is a column 'money' in the db 'players'. On server starts, it connects to db. Then player join to the server, with setPlayerMoney I set value from db. Then player spend his money, we use setPlayerMoney and set new value into db.

Link to comment

The scenario you mentioned is okay with the flow you suggested. Now imagine play time, there are no native functions to manipulate play time. Are you going to query the database each time the play time is updated? I hope not.

You can use element data as a session storage, when the player leaves, you can get the element data and save it into an SQL database.

You can also use tables instead of element data, with each player as the key, it's more efficient this way.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...