SearchBan [MySQL]
#1

The command:

PHP код:
CMD:sban(playeridparams[])
{
    new 
n[24], admin[24], IP[16], reason[56], Day[2], Year[4], Month[2], Hour[2], Minute[2], Second[2];
    if(
pAdmin[playerid] < 2) return SendClientMessage(playerid0xCD0000FF"Invalid command. Please use {FFF8CF}/cmds {CD0000}to list all available commands.");
     if(
sscanf(params"s[24]"n)) return SendClientMessage(playerid, -1"{0008F7}USAGE: {FFFFFF}/SBAN NAME");
     new 
query[200];
    
format(querysizeof(query),"SELECT Admin,Player,Reason,IP,Day,Month,Year,Hour,Minute,Second FROM `Bans` WHERE `Player`='%s'"n);
    
mysql_query(query);
    
mysql_store_result();
    new 
rows mysql_num_rows();
    if(
rows == 1)
    {
          while(
mysql_fetch_row(query))
          {
            
mysql_fetch_field_row(admin"Admin");
            
mysql_fetch_field_row(IP"IP");
            
mysql_fetch_field_row(reason"Reason");
            
mysql_fetch_field_row(Day"Day");
            
mysql_fetch_field_row(Month"Month");
            
mysql_fetch_field_row(Year"Year");
            
mysql_fetch_field_row(Hour"Hour");
            
mysql_fetch_field_row(Minute"Minute");
            
mysql_fetch_field_row(Second"Second");
          }
        new 
string[224], name[24];
        
GetPlayerName(playeridnamesizeof(name));
        
format(string,sizeof(string),"{0008F7}[Administration]: {FF0095}%s {C90076}have used {FF0095}SBAN"name);
        
SendToAdmins(-1string);
        
format(stringsizeof(string), "{9384CF}Account: %s Banned by %s on %d:%d:%d the %d/%d/%d for %s"nadminHourMinuteSecondDay,MonthYearreason);
        
SendClientMessage(playerid, -1string);
    }
    if(!
rows)
    {
        
SendClientMessage(playerid0xCD0000FF"Account no banned or not exists");
    }
    return 
1;

This loop isn't getting info from database right way

PHP код:
while(mysql_fetch_row(query))
          {
            
mysql_fetch_field_row(admin"Admin");
            
mysql_fetch_field_row(IP"IP");
            
mysql_fetch_field_row(reason"Reason");
            
mysql_fetch_field_row(Day"Day");
            
mysql_fetch_field_row(Month"Month");
            
mysql_fetch_field_row(Year"Year");
            
mysql_fetch_field_row(Hour"Hour");
            
mysql_fetch_field_row(Minute"Minute");
            
mysql_fetch_field_row(Second"Second");
          } 
Why? and how to fix it?
Reply
#2

Bump
Reply
#3

Quote:
Originally Posted by Shinja
Посмотреть сообщение
The command:

PHP код:
CMD:sban(playeridparams[])
{
    new 
n[24], admin[24], IP[16], reason[56], Day[2], Year[4], Month[2], Hour[2], Minute[2], Second[2];
    if(
pAdmin[playerid] < 2) return SendClientMessage(playerid0xCD0000FF"Invalid command. Please use {FFF8CF}/cmds {CD0000}to list all available commands.");
     if(
sscanf(params"s[24]"n)) return SendClientMessage(playerid, -1"{0008F7}USAGE: {FFFFFF}/SBAN NAME");
     new 
query[200];
    
format(querysizeof(query),"SELECT Admin,Player,Reason,IP,Day,Month,Year,Hour,Minute,Second FROM `Bans` WHERE `Player`='%s'"n);
    
mysql_query(query);
    
mysql_store_result();
    new 
rows mysql_num_rows();
    if(
rows == 1)
    {
          while(
mysql_fetch_row(query))
          {
            
mysql_fetch_field_row(admin"Admin");
            
mysql_fetch_field_row(IP"IP");
            
mysql_fetch_field_row(reason"Reason");
            
mysql_fetch_field_row(Day"Day");
            
mysql_fetch_field_row(Month"Month");
            
mysql_fetch_field_row(Year"Year");
            
mysql_fetch_field_row(Hour"Hour");
            
mysql_fetch_field_row(Minute"Minute");
            
mysql_fetch_field_row(Second"Second");
          }
        new 
string[224], name[24];
        
GetPlayerName(playeridnamesizeof(name));
        
format(string,sizeof(string),"{0008F7}[Administration]: {FF0095}%s {C90076}have used {FF0095}SBAN"name);
        
SendToAdmins(-1string);
        
format(stringsizeof(string), "{9384CF}Account: %s Banned by %s on %d:%d:%d the %d/%d/%d for %s"nadminHourMinuteSecondDay,MonthYearreason);
        
SendClientMessage(playerid, -1string);
    }
    if(!
rows)
    {
        
SendClientMessage(playerid0xCD0000FF"Account no banned or not exists");
    }
    return 
1;

This loop isn't getting info from database right way
What do you mean by this?

What is it returning? Or are you referring to how the information didn't show up "right away" - in terms of how long it takes to display?
Reply
#4

Already fixed. Thanks!
Reply


Forum Jump:


Users browsing this thread: