AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   SQL_MakeDbTuple port? (https://forums.alliedmods.net/showthread.php?t=207083)

Backstabnoob 01-29-2013 12:50

SQL_MakeDbTuple port?
 
How do you change it?

PHP Code:

static cell AMX_NATIVE_CALL SQL_MakeDbTuple(AMX *amxcell *params)
{
    
SQL_Connection *sql = new SQL_Connection;
    
int len;

    
char *host =  strdup(MF_GetAmxString(amxparams[1], 0, &len));

    
char *strchr(host':');
    if (
p)
    {
        
sql->port atoi(p+1);
        *
'\0';
    } else {
        
sql->port 0;
    }

    
sql->host host;
    
sql->user strdup(MF_GetAmxString(amxparams[2], 0, &len));
    
sql->pass strdup(MF_GetAmxString(amxparams[3], 0, &len));
    
sql->db strdup(MF_GetAmxString(amxparams[4], 0, &len));
    if (
params[0] / sizeof(cell) >= 5)
    {
        
sql->max_timeout static_cast<unsigned int>(params[5]);
    }

    
unsigned int num MakeHandle(sqlHandle_ConnectionFreeConnection);

    return 
num;


This looks like it should work, but it changes the host to default internal IP of the server when the port is added.

Edit: Nevermind, this is from the newer SQLx version (it's most likely bugged in the old one).

AngeIII 01-29-2013 13:38

Re: SQL_MakeDbTuple port?
 
should work.
char *host = strdup(MF_GetAmxString(amx, params[1], 0, &len));
get the second param
for example like this "123.123.132.133" or "123.123.123.123:12312"
if substring after ":" founded that you provide the port
so
if(p)
set the sql->port.
else port->0 // uses default port

..

PHP Code:

new Handle:SQL_Tuple
new Handle:SQL_Connection
/*...*/
public plugin_cfg()
{
     
SQL_Tuple SQL_MakeDbTuple("123.123.123.132:2501","db_user","db_pase","db_name"
     new 
errerror[256]
     
SQL_Connection SQL_Connect(SQL_Tupleerrerrorcharsmax(error)) 
     if(
SQL_Connection != Empty_Handle)
     {
        
log_amx("[SQLx connect ok]")
     }
     else
     {
        
log_amx("[SQLX sql error] %s ",error)
        
pause("a")
     }
}
     
/*...*/ 



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

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