AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SQL] Simple plugin. (https://forums.alliedmods.net/showthread.php?t=174567)

Ex3cuTioN 12-22-2011 06:25

[SQL] Simple plugin.
 
I really don't understand this SQL connection between cs server and a web server.
Can anyone make a simple plugin with:
-when i type in chat /sql to send a message with my name,ip,steamid to the web server?

I'll find it easy to learn if i have an example.

Sylwester 12-22-2011 07:25

Re: [SQL] Simple plugin.
 
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.

Ex3cuTioN 12-23-2011 03:49

Re: [SQL] Simple plugin.
 
Thank you.


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

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