Little problem
#1

so can anyone let me know whats the problem with this


Basically it doesnt work, if you ban someones IP it will still let them play normaly. The check doesnt work
PHP код:
new myIP[16];
    
GetPlayerIp(playeridmyIPsizeof(myIP));
    if(
IPBanned(myIP)) {
        
Kick(playerid);
        return 
true;
    }
IPBanned(const str[])
{
    new 
query[85],Cache:result,rows;
    
mysql_format(mysqlquerysizeof(query), "SELECT `IP` FROM `ipbanned` WHERE `IP` = '%e' LIMIT 1",str);
    
result mysql_query(mysqlquery);
    if((
rows cache_num_rows()))
    {
        
rows cache_get_row_int(00);
        
cache_delete(result);
        return 
rows;
    }
    
cache_delete(result);
    return 
rows;

Reply
#2

add this under OnPlayerConnect(playerid)

Код:
    if(IPBanned(myIP)) { 
        Kick(playerid); 
        return true; 
    }
Reply
#3

As I said above, its not working and yes I have it under OnPlayerConnect.
Reply
#4

Because you're sending %e..
Try below code.
PHP код:
IPBanned(const str[]) {
    new 
query[85],Cache:result,rows;
    
mysql_format(mysqlquerysizeof(query), "SELECT `IP` FROM `ipbanned` WHERE `IP` = '%s' LIMIT 1",str);
    
result mysql_query(mysqlquery);
    if((
rows cache_num_rows())) {
        
rows cache_get_row_int(00);
        
cache_delete(result);
        return 
rows;
    }
    
cache_delete(result);
    return 
rows;

Reply
#5

I tried the system, it displays info correctly in the SQL log also...
PHP код:
[19:51:30] [DEBUGmysql_format connection1len85format"SELECT `IP` FROM `ipbanned` WHERE `IP` = '%s' LIMIT 1"
[19:51:30] [DEBUGmysql_query connection1query"SELECT `IP` FROM `ipbanned` WHERE `IP` = '127.0.0.1' LIMIT 1"use_cachetrue 
Reply
#6

I don't get the issue then
Because You're saying what I gave you works
Reply
#7

Quote:
Originally Posted by Prokill911
Посмотреть сообщение
I don't get the issue then
Because You're saying what I gave you works
Same thing happends.
PHP код:
[21:38:52] [DEBUGmysql_format connection1len85format"SELECT `IP` FROM `ipbanned` WHERE `IP` = '%s' LIMIT 1"
[21:38:52] [DEBUGmysql_query connection1query"SELECT `IP` FROM `ipbanned` WHERE `IP` = '127.0.0.1' LIMIT 1"use_cachetrue 
It does work loading wise, but it doesnt tell player that their IP is banned etc.

PHP код:
new myIP[16];
    
GetPlayerIp(playeridmyIPsizeof(myIP));
    if(
IPBanned(myIP)) {
        
Msg(playerid,COLOR_RED,"IP banned");
        return 
true;
    } 
Full log
PHP код:
[21:43:07] [DEBUGmysql_format connection1len85format"SELECT `IP` FROM `ipbanned` WHERE `IP` = '%s' LIMIT 1"
[21:43:07] [DEBUGmysql_query connection1query"SELECT `IP` FROM `ipbanned` WHERE `IP` = '127.0.0.1' LIMIT 1"use_cachetrue
[21:43:07] [DEBUGCMySQLQuery::Execute starting query execution
[21:43:07] [DEBUGCMySQLQuery::Execute query was successfully executed within 184.578 milliseconds
[21:43:07] [DEBUGCMySQLResult::CMySQLResult() - constructor called
[21:43:07] [DEBUGCMySQLHandle::SaveActiveResult cache saved (id1)
[
21:43:07] [DEBUGcache_get_row_count connection1
[21:43:07] [DEBUGcache_delete cache_id1connection1
[21:43:07] [DEBUGCMySQLResult::~CMySQLResult() - deconstructor called
[21:43:07] [DEBUGCMySQLHandle::DeleteSavedResult result deleted 
Reply
#8

BUMP
Reply
#9

i think that u are trying to get IP as int using cache_get_row_int try cache_get_row instead
Reply
#10

Try this :
PHP код:
IPBanned(const str[]) 

    new 
query[85],Cache:result,rows;
    
// you dont really need to select anything if you just need to check if ip is there
    // you can just use row count to see if ip exists or not
    // notice change in query here and always use %e
    
mysql_format(mysqlquerysizeof(query), "SELECT NULL FROM `ipbanned` WHERE `IP` = '%e' LIMIT 1",str); 
    
result mysql_query(mysqlquery); 
    
rows cache_num_rows();
    
cache_delete(result); 
    return 
rows

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)