Doesn't Detect IP.
#1

I am trying to make an AKA(As Known As) command but it doesnt detect IP so when i type /aka it doesnt show any client message.. like AKA: vassilis

mysql_log
Код:
[DEBUG] mysql_format - connection: 1, len: 60, format: "SELECT `Username` from `players` WHERE `IP` = '%s'"
 [DEBUG] mysql_tquery - connection: 1, query: "SELECT `Username` from `players` WHERE `IP` = '
'", callback: "CheckAka", format: "i"
[DEBUG] CMySQLQuery::Execute[CheckAka] - starting query execution
 [DEBUG] CMySQLQuery::Execute[CheckAka] - query was successfully executed within 1.230 milliseconds
[DEBUG] CMySQLResult::CMySQLResult() - constructor called
[DEBUG] Calling callback "CheckAka"..
 [DEBUG] cache_get_data - connection: 1
 [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
Command:
PHP код:
CMD:aka(playeridparams[])
{
    new 
query[60],pIP[16];
    
mysql_format(mysqlquerysizeof(query),"SELECT `Username` from `players` WHERE `IP` = '%s'",  GetPlayerIp(playerid,pIP,sizeof(pIP)));
    
    
mysql_tquery(mysqlquery"CheckAka""i"playerid);
    return 
1;
}
function 
CheckAka(playerid)
{    
    new 
rowsfields
    
cache_get_data(rowsfieldsmysql);
    
    if(
rows)
    {
        
cache_get_field_content(rows"Username"Name[playerid]);
        
SendFM(playerid, -1"AKA: %s",Name[playerid]);
    }
    return 
1;

Reply
#2

Look here how to use
https://sampwiki.blast.hk/wiki/GetPlayerIp
Reply
#3

Basically GetPlayerIp returns 1 on success and 0 on failure.So what you doing is wrong logically.
You can do it like this way.
PHP код:
CMD:aka(playeridparams[]) 

    new 
query[60],pIP[16]; 
    
GetPlayerIp(playerid,pIP,sizeof(pIP));
    
mysql_format(mysqlquerysizeof(query),"SELECT `Username` from `players` WHERE `IP` = '%s'"pIP ); 
     
    
mysql_tquery(mysqlquery"CheckAka""i"playerid); 
    return 
1

Reply
#4

Quote:
Originally Posted by Sreyas
Посмотреть сообщение
Basically GetPlayerIp returns 1 on success and 0 on failure.So what you doing is wrong logically.
You can do it like this way.
PHP код:
CMD:aka(playeridparams[]) 

    new 
query[60],pIP[16]; 
    
GetPlayerIp(playerid,pIP,sizeof(pIP));
    
mysql_format(mysqlquerysizeof(query),"SELECT `Username` from `players` WHERE `IP` = '%s'"pIP ); 
     
    
mysql_tquery(mysqlquery"CheckAka""i"playerid); 
    return 
1

Still doesnt work..
PHP код:
[17:40:29] [DEBUGmysql_format connection1len60format"SELECT `Username` from `players` WHERE `IP` = '%s'"
[17:40:29] [DEBUGmysql_tquery connection1query"SELECT `Username` from `players` WHERE `IP` = ''"callback"CheckAka"format"i"
[17:40:29] [DEBUGCMySQLQuery::Execute[CheckAka] - starting query execution
[17:40:29] [DEBUGCMySQLQuery::Execute[CheckAka] - query was successfully executed within 0.784 milliseconds
[17:40:30] [DEBUGCMySQLResult::CMySQLResult() - constructor called
[17:40:30] [DEBUGCalling callback "CheckAka"..
[
17:40:30] [DEBUGcache_get_data connection1
[17:40:30] [DEBUGCMySQLResult::~CMySQLResult() - deconstructor called 
PHP код:
CMD:aka(playeridparams[])
{
    new 
query[60],pIP[16];
    
GetPlayerIp(playerid,pIP,sizeof(pIP));
    
mysql_format(mysqlquerysizeof(query),"SELECT `Username` from `players` WHERE `IP` = '%s'"pIP);
    
    
mysql_tquery(mysqlquery"CheckAka""i"playerid);
    return 
1;
}
function 
CheckAka(playerid)
{    
    new 
rowsfields
    
cache_get_data(rowsfieldsmysql);
    
    if(
rows)
    {
        
cache_get_field_content(rows"Username"Name[playerid]);
        
SendFM(playerid, -1"AKA: %s",Name[playerid]);
    }
    return 
1;

Reply
#5

Thats strange you can do the following things

1.Check the database fields and its data type(just a try).
2. Debug the value of ip using printf

PHP код:
CMD:aka(playeridparams[]) 

    new 
query[60],pIP[16]; 
    
GetPlayerIp(playerid,pIP,sizeof(pIP)); 
    
printf("ip is %s",pIP);    
    
mysql_format(mysqlquerysizeof(query),"SELECT `Username` from `players` WHERE `IP` = '%s'"pIP); 
      
    
mysql_tquery(mysqlquery"CheckAka""i"playerid); 
    return 
1

function 
CheckAka(playerid
{     
    new 
rowsfields;  
    
cache_get_data(rowsfieldsmysql); 
     
    if(
rows
    { 
        
cache_get_field_content(rows"Username"Name[playerid]); 
        
SendFM(playerid, -1"AKA: %s",Name[playerid]); 
    } 
    return 
1

Note: you can add more console messages for deep debug.
Reply
#6

Increase the cells of query.
Reply
#7

If you copy the query to notepad and fill in the full length of an IP address, your query is too short:
SELECT `Username` from `players` WHERE `IP` = '123.123.123.123'

This query counts 63 characters and you also need a null char to end the string, so your query needs to be at least 64 chars long, 60 is too short.
Reply
#8

Quote:
Originally Posted by AmigaBlizzard
Посмотреть сообщение
If you copy the query to notepad and fill in the full length of an IP address, your query is too short:
SELECT `Username` from `players` WHERE `IP` = '123.123.123.123'

This query counts 63 characters and you also need a null char to end the string, so your query needs to be at least 64 chars long, 60 is too short.
Mine -_-
Reply
#9

Updated query size.
How it will print each name that is under the same IP?
It prints only the first it finds.
For example i have at ID 1 MrJohnnz
and at ID 2 Username [GT]Ryder with the same ip but it shows me only the first one .
PHP код:
function CheckAka(playerid)
{    
    new 
rowsfields
    
cache_get_data(rowsfieldsmysql);
    
    if(
rows)
    {
        
cache_get_field_content(0"Username"Name[playerid]);
        
SendFM(playerid, -1"AKA: %s",Name[playerid]);
    }
    return 
1;

Reply
#10

Quote:
Originally Posted by vassilis
Посмотреть сообщение
Updated query size.
How it will print each name that is under the same IP?
It prints only the first it finds.
For example i have at ID 1 MrJohnnz
and at ID 2 Username [GT]Ryder with the same ip but it shows me only the first one .
PHP код:
function CheckAka(playerid)
{    
    new 
rowsfields
    
cache_get_data(rowsfieldsmysql);
    
    if(
rows)
    {
        
cache_get_field_content(0"Username"Name[playerid]);
        
SendFM(playerid, -1"AKA: %s",Name[playerid]);
    }
    return 
1;

Loop
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)