Raised This Month: $ Target: $400
 0% 

SQL_MakeDbTuple port?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 01-29-2013 , 12:50   SQL_MakeDbTuple port?
Reply With Quote #1

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).

Last edited by Backstabnoob; 01-29-2013 at 12:52.
Backstabnoob is offline
AngeIII
Senior Member
Join Date: Sep 2007
Location: Latvia
Old 01-29-2013 , 13:38   Re: SQL_MakeDbTuple port?
Reply With Quote #2

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")
     }
}
     
/*...*/ 
__________________
skype: pavle_ivanof
-=ThQ=-
PRIVATE SUPPORT = PAID SUPPORT

Last edited by AngeIII; 01-29-2013 at 13:42.
AngeIII is offline
Send a message via Skype™ to AngeIII
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 20:41.


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