AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help on sqlx (https://forums.alliedmods.net/showthread.php?t=144497)

Excelenton 12-04-2010 17:42

Help on sqlx
 
I am from Argentina (I speak Spanish) and wanted to know if someone could explain a little about how to use sqlx since I have a zombie server and need to build a system for recording and saving accounts through ammo packs if anyone sqlx I could explain a bit like appreciate it.

Fedcomp 12-04-2010 19:19

Re: Help on sqlx
 
Global:
PHP Code:

new Handle:g_h_Sql 

Connect to db:
PHP Code:

g_h_Sql SQL_MakeDbTuple("127.0.0.1""dbuser""dbpass""dbname"

Exec query:
PHP Code:

new s_Query[128], s_Name[32]

get_user_name(ids_Namecharsmax(s_Name))
format(s_Querycharsmax(s_Query), "SELECT steam_id FROM table WHERE name='%s'"s_Name)
SQL_ThreadQuery(g_h_Sql"Handle_Query"s_Query

Read results:
PHP Code:

public Handle_Query(i_FailStateHandle:h_Querys_Error[], i_Errcodes_Data[], i_DataSizeFloat:f_QueueTime)
{
    if (
i_FailState == TQUERY_CONNECT_FAILED)
        
set_fail_state("Could not connect to database.")
    else if (
i_FailState == TQUERY_QUERY_FAILED)
        
set_fail_state("Query failed.")
    else if (
i_Errcode)
        
log_amx("Error on query: %s"s_Error)
    else
        if (
SQL_NumResults(h_Query))
        {
            new 
i_SteamIDs_SteamID[32]
            
            
i_SteamID SQL_FieldNameToNum(h_Query"steam_id")
            
            while (
SQL_MoreResults(h_Query))
            {
                
SQL_ReadResult(h_Queryi_SteamIDs_SteamIDcharsmax(s_SteamID))
            
                if (
equal(s_SteamID"STEAM_0:0:123456")){
                   
// action example 
                
}
                
SQL_NextRow(h_Query)
            }
        }


use search to more


All times are GMT -4. The time now is 11:20.

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