Here is example:
https://forums.alliedmods.net/showth...66#post1204466
This example is using sqlite (it's a file located in addons/amxmodx/data/sqlite3/<dbname>.sq3).
To make it work with mysql server you just need to change:
PHP Code:
public sql_init(){
SQL_SetAffinity("sqlite")
g_SqlTuple = SQL_MakeDbTuple("127.0.0.1","root","","test_db")
}
->
PHP Code:
public sql_init(){
SQL_SetAffinity("mysql")
g_SqlTuple = SQL_MakeDbTuple("server_ip","username","password","database_name")
}
Make sure you have proper modules enabled.
There are 4 console commands:
table_create - creates space in database where data can be stored (needs to be used only once)
table_save <number> - saves data (you can have any number of datas assigned to your current steamid)
table_load <number> - loads data that was previously saved with <number>
table_loadx - loads data of all numbers
There are many log_amx in code that will print to server console information about what was sent to sql and what was retrieved, so you can try many things and see what happens. Example: use any command with incorrect server ip or when mysql server is turned off, save/load without creating table, load data with number that was not saved previously etc.
__________________