Command not working
#1

as the title says my command is not working properly.
i had added hours as 3rd part but that is not working it is coming as reason
PHP код:
if(strcmp(cmd"/ban"true) == 0)
    {
        if(
IsPlayerConnected(playerid))
        {
            
tmp strtok(cmdtextidx);
            if(!
strlen(tmp))
            {
                
SendClientMessage(playeridCOLOR_SECURITY"Syntax: /ban (id/name) hours (reason)");
                return 
1;
            }
            new 
giveplayerid;
            new 
len;
            
giveplayerid ReturnUser(tmp);
            
len strvalEx(tmp);
            if(
IsPlayerNPC(giveplayerid)) return 1;
            if(
PInfo[playerid][AdminLevel] >= 1)
            {
                if(
IsPlayerConnected(giveplayerid))
                {
                    if(
giveplayerid != INVALID_PLAYER_ID)
                    {
                        new 
length strlen(cmdtext);
                        while ((
idx length) && (cmdtext[idx] <= ' '))
                        {
                            
idx++;
                        }
                        new 
offset idx;
                        new 
result[156];
                        while ((
idx length) && ((idx offset) < (sizeof(result) - 1)))
                        {
                            
result[idx offset] = cmdtext[idx];
                            
idx++;
                        }
                        
result[idx offset] = EOS;
                        if(!
strlen(result))
                        {
                            
SendClientMessage(playeridCOLOR_SECURITY"Syntax: /ban (id/name) (reason)");
                            return 
1;
                        }
                        new 
date,month,year;
                        
getdate(date,month,year);
                        new 
hour,minute,second;
                        
gettime(hour,minute,second);
                        
format(stringsizeof(string), "Administrator %s has banned %s due to %s",PlayerName(playerid), PlayerName(giveplayerid), (result));
                        
SendClientMessageToAll(COLOR_WHITEstring);
                        
PInfo[giveplayerid][Banned] = len;
                        
GettingBanned[giveplayerid] = 1;
                        new 
Name[MAX_PLAYER_NAME];
                        new 
plrIP[25];
                        new 
query[256];
                        
//new date2[128];
                        //format(date2, sizeof(date2), "%d/%d/%d", year,month,date);
                        
GetPlayerName(giveplayerid,Name,sizeof(Name));
                        
GetPlayerName(playerid,sendername,sizeof(sendername));
                        
GetPlayerIp(giveplayeridplrIPsizeof(plrIP));
                        
mysql_real_escape_string(Name,Name);
                        
mysql_real_escape_string((result),(result));
                        
mysql_real_escape_string(sendername,sendername);
                        
mysql_real_escape_string(plrIP,plrIP);
                        
format(query,sizeof(query),"INSERT INTO `bans` (Username, Reason, Administrator, IP, Date, Time) VALUES ('%s','%s','%s','%s','%d/%d/%d','%d:%d:%d')",Name,(result),sendername,plrIP,year,month,date,hour,minute,second);
                        
mysql_reconnect();
                        
mysql_query(query);
                        
AdminLog(playerid"/ban", (result), Name);
                        
Kick(giveplayerid);
                        return 
1;
                    }
                }
                else
                {
                    
format(stringsizeof(string), "Could not find player (%d)"giveplayerid);
                    
SendClientMessage(playeridCOLOR_ERRORstring);
                }
            }
            else
            {
                
SendClientMessage(playeridCOLOR_ERROR"You are not an administrator !");
            }
        }
        return 
1;
    }
    
    return 
SendClientMessage(playeridCOLOR_ERROR"Unknown command, please type /commands for a list of available commands to use.");

Reply
#2

anyone plz
++rep
Reply
#3

You would find this a lot easier with sscanf and zcmd... Just saying...


Where'd the code come from, and what have you done to it, as it doesn't seem like it's been copy/pasted/editted correctly.

Here's the reason I say it's copy-pasted... "SendClientMessage(playerid, COLOR_SECURITY, "Syntax: /ban (id/name) (reason)");"

That's missing the hour in it's feedback, and thus if you haven't done it correctly throughout the command then it WILL come out with the hour in the reason.
Reply
#4

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
You would find this a lot easier with sscanf and zcmd... Just saying...


Where'd the code come from, and what have you done to it, as it doesn't seem like it's been copy/pasted/editted correctly.

Here's the reason I say it's copy-pasted... "SendClientMessage(playerid, COLOR_SECURITY, "Syntax: /ban (id/name) (reason)");"

That's missing the hour in it's feedback, and thus if you haven't done it correctly throughout the command then it WILL come out with the hour in the reason.
Sendclientmessage i had done i thought of editing it after fixing these current bug
Sendclient message also has connection with the command parameters ?
Reply
#5

I can't even understand that at all...



What I see when I see things like this difference in the SendClientMessage is that you've simply copied that command from elsewhere, and edited it...

The reason you are having the issue if you have done this is because you haven't edited it correctly due to not knowing what you are doing.
Reply
#6

PHP код:
if(strcmp(cmd"/ban"true) == 0
    { 
        if(
IsPlayerConnected(playerid)) 
        { 
            
tmp strtok(cmdtextidx); 
            if(!
strlen(tmp)) 
            { 
                
SendClientMessage(playeridCOLOR_SECURITY"Syntax: /ban (id/name) hours (reason)"); 
                return 
1
            } 
            new 
giveplayerid
            new 
len
            
giveplayerid ReturnUser(tmp); 
            
len strvalEx(tmp); 
            if(
IsPlayerNPC(giveplayerid)) return 1
            if(
PInfo[playerid][AdminLevel] >= 1
            { 
                if(
IsPlayerConnected(giveplayerid)) 
                { 
                    if(
giveplayerid != INVALID_PLAYER_ID
                    { 
                        new 
length strlen(cmdtext); 
                        while ((
idx length) && (cmdtext[idx] <= ' ')) 
                        { 
                            
idx++; 
                        } 
                        new 
offset idx
                        new 
result[156]; 
                        while ((
idx length) && ((idx offset) < (sizeof(result) - 1))) 
                        { 
                            
result[idx offset] = cmdtext[idx]; 
                            
idx++; 
                        } 
                        
result[idx offset] = EOS
                        if(!
strlen(result)) 
                        { 
                            
SendClientMessage(playeridCOLOR_SECURITY"Syntax: /ban (id/name) (reason)"); 
                            return 
1
                        } 
                        new 
date,month,year
                        
getdate(date,month,year); 
                        new 
hour,minute,second
                        
gettime(hour,minute,second); 
                        
PInfo[giveplayerid][Banned] = len
                        
GettingBanned[giveplayerid] = 1
                        new 
Name[MAX_PLAYER_NAME]; 
                        new 
plrIP[25]; 
                        new 
query[256]; 
                        
//new date2[128]; 
                        //format(date2, sizeof(date2), "%d/%d/%d", year,month,date); 
                        
GetPlayerName(giveplayerid,Name,sizeof(Name)); 
                        
GetPlayerName(playerid,sendername,sizeof(sendername)); 
                        
GetPlayerIp(giveplayeridplrIPsizeof(plrIP)); 
                        
mysql_real_escape_string(Name,Name); 
                        
mysql_real_escape_string((result),(result)); 
                        
mysql_real_escape_string(sendername,sendername); 
                        
mysql_real_escape_string(plrIP,plrIP); 
                        
format(query,sizeof(query),"INSERT INTO `bans` (Username, Reason, Administrator, IP, Date, Time) VALUES ('%s','%s','%s','%s','%d/%d/%d','%d:%d:%d')",Name,(result),sendername,plrIP,year,month,date,hour,minute,second); 
                        
mysql_query(query); 
                        
AdminLog(playerid"/ban", (result), Name); 
                        
Kick(giveplayerid); 
                        
format(stringsizeof(string), "Administrator %s has banned %s due to %s",PlayerName(playerid), PlayerName(giveplayerid), (result)); 
                        
SendClientMessageToAll(COLOR_WHITEstring); 
                        return 
1
                    } 
                } 
                else 
                { 
                    
format(stringsizeof(string), "Could not find player (%d)"giveplayerid); 
                    
SendClientMessage(playeridCOLOR_ERRORstring); 
                } 
            } 
            return  
SendClientMessage(playeridCOLOR_ERROR"You are not an administrator !"); 
       } 
       return 
SendClientMessage(playeridCOLOR_ERROR"Unknown command, please type /commands for a list of available commands to use."); 

Reply
#7

stilll not working and i dont see any chnages u did to it ....
Reply
#8

Quote:
Originally Posted by bugmenotlol
Посмотреть сообщение
stilll not working and i dont see any chnages u did to it ....
He does that often.

He's moved the format, and Send Client Message further down, and removed the mysql_reconnect line entirely.

Not saying that it works or that it's good, he's simply bad for pasting up "fixes" that aren't fixes with no explanation.
Reply
#9

Quote:
Originally Posted by bugmenotlol
Посмотреть сообщение
stilll not working and i dont see any chnages u did to it ....
what the problem ?

did players still can join ?
Reply
#10

Quote:
Originally Posted by Yaa
Посмотреть сообщение
what the problem ?

did players still can join ?
it is not the problem.
The problem is;
The Syntac should be /ban playername/id hours reason
But it only gives /ban playername/id reason >>> Hours cannot be saved
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)