Reading Cmds Problem.
#1

Hello all...

Have one problem idk what to do...

PHP код:
public OnPlayerCommandText(playeridcmdtext[])
{
    new 
string[256];
    new 
idx;
    new 
i;
    new 
playername[MAX_PLAYER_NAME];
    
string strtok(cmdtextidx);
    if(
ServerInfo[ReadCmds] == 1)
    {
        
GetPlayerName(playeridplayernamesizeof(playername));
        
format(stringsizeof(string), "*** %s (%d) typed: %s"playername,playerid,cmdtext);
        for(new 
0MAX_PLAYERSi++) //THIS LINE IS THE PROBLEM...
        
if(IsPlayerConnected(i))
        if( (
PlayerInfo[i][Level] > PlayerInfo[playerid][Level]) && (PlayerInfo[i][Level] > 1) && (!= playerid) )
        
IRC_GroupSay(gGroupID3IRC_MCHANNELstring);
        
SendClientMessage(igreystring); 
It just doesn't show when someone type any wrong cmd...how to fix it?
Thanks.
Reply
#2

That's not how a loop works. You might want to try the following and see if it works. Pay attention to the comments.

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new string[256];
    new idx;
    new i;
    new playername[MAX_PLAYER_NAME];
    string = strtok(cmdtext, idx);
    if(ServerInfo[ReadCmds] == 1)
    {
        GetPlayerName(playerid, playername, sizeof(playername));
        format(string, sizeof(string), "*** %s (%d) typed: %s", playername,playerid,cmdtext);
        for(new i = 0; i < MAX_PLAYERS; i++)
            {
                if(IsPlayerConnected(i)) //then do what?
                if( (PlayerInfo[i][Level] > PlayerInfo[playerid][Level]) && (PlayerInfo[i][Level] > 1) && (i != playerid) ) //then do what?
                IRC_GroupSay(gGroupID3, IRC_MCHANNEL, string);
                SendClientMessage(i, grey, string);
                return 1;
             }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)