Raised This Month: $ Target: $400
 0% 

[SQL] Simple plugin.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 12-22-2011 , 07:25   Re: [SQL] Simple plugin.
Reply With Quote #1

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.
__________________
Impossible is Nothing
Sylwester is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:00.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode