[Ajuda] Comando /limparchat com motivo
#1

E ai galera, й o seguinte, eu tinha um comando /limparchat que nгo precisava colocar o motivo, mas ai resolvi colocar motivo, estб dando tudo certo, ta limpando o Chat e ta pedindo pra colocar o motivo, porйm, nгo estб aparecendo o motivo na mensagem "motivo:" serб que vocкs podem me ajudar?

PHP код:
    if(strcmp(cmd"/lchat"true) == || strcmp(cmd"/limparchat"true) == 0)
    {
        if(
IsPlayerConnected(playerid))
        {
            if(
PlayerInfo[playerid][pAdmin] < 3)
            {
                
SendClientMessage(playeridCOLOR_GREY"Vocк nгo й um admin!");
                return 
true;
            }
             
tmp strtok(cmdtextidx);
            if(!
strlen(tmp))
            {
                
SendClientMessage(playeridCOLOR_GRAD2"USE: /limparchat [motivo]");
                return 
true;
            }
              if(
admtrampando[playerid] < && PlayerInfo[playerid][pAdmin] != DONO)
            {
                
SendClientMessage(playeridCOLOR_GRAD1" Vocк nгo estб em modo Admin USE: /jogar");
                return 
true;
            }
            for(new 
i=0i<MAX_PLAYERSi++)
            {
                if(
IsPlayerConnected(i)) ClearChatbox(i100);
            }
            new 
result[64];
            
format(stringsizeof(string), "O admin %s limpou o chat, motivo: %s"PlayerName(playerid), result);
            
SendClientMessageToAll(COLOR_WHITEstring);
        }
        return 
true;
    } 
Reply
#2

Quote:
Originally Posted by WiliHacking
Посмотреть сообщение
E ai galera, й o seguinte, eu tinha um comando /limparchat que nгo precisava colocar o motivo, mas ai resolvi colocar motivo, estб dando tudo certo, ta limpando o Chat e ta pedindo pra colocar o motivo, porйm, nгo estб aparecendo o motivo na mensagem "motivo:" serб que vocкs podem me ajudar?

PHP код:
    if(strcmp(cmd"/lchat"true) == || strcmp(cmd"/limparchat"true) == 0)
    {
        if(
IsPlayerConnected(playerid))
        {
            if(
PlayerInfo[playerid][pAdmin] < 3)
            {
                
SendClientMessage(playeridCOLOR_GREY"Vocк nгo й um admin!");
                return 
true;
            }
             
tmp strtok(cmdtextidx);
            if(!
strlen(tmp))
            {
                
SendClientMessage(playeridCOLOR_GRAD2"USE: /limparchat [motivo]");
                return 
true;
            }
              if(
admtrampando[playerid] < && PlayerInfo[playerid][pAdmin] != DONO)
            {
                
SendClientMessage(playeridCOLOR_GRAD1" Vocк nгo estб em modo Admin USE: /jogar");
                return 
true;
            }
            for(new 
i=0i<MAX_PLAYERSi++)
            {
                if(
IsPlayerConnected(i)) ClearChatbox(i100);
            }
            new 
result[64];
            
format(stringsizeof(string), "O admin %s limpou o chat, motivo: %s"PlayerName(playerid), result);
            
SendClientMessageToAll(COLOR_WHITEstring);
        }
        return 
true;
    } 
pawn Код:
new result[64];
            format(string, sizeof(string), "O admin %s limpou o chat, motivo: %s", PlayerName(playerid), result);
            SendClientMessageToAll(COLOR_WHITE, string);
como assim ? vc ta colocando esse "result" vazio '-' nao ira aparecer nada mesmo, de qualquer forma, espere alguem que entenda responder, eu sу entendo ZCMD sscanf, ( vocк deveria aprender isso tbm, й mais facio ^^ )
Reply
#3

Eu nгo uso e nem pretendo usar strrok, mas acho que isso resolve.
PHP код:
if(strcmp(cmd"/lchat"true) == || strcmp(cmd"/limparchat"true) == 0
    { 
        if(
IsPlayerConnected(playerid)) 
        { 
            if(
PlayerInfo[playerid][pAdmin] < 3
            { 
                
SendClientMessage(playeridCOLOR_GREY"Vocк nгo й um admin!"); 
                return 
true
            } 
             
tmp strtok(cmdtextidx); 
            if(!
strlen(tmp)) 
            { 
                
SendClientMessage(playeridCOLOR_GRAD2"USE: /limparchat [motivo]"); 
                return 
true
            } 
              if(
admtrampando[playerid] < && PlayerInfo[playerid][pAdmin] != DONO
            { 
                
SendClientMessage(playeridCOLOR_GRAD1" Vocк nгo estб em modo Admin USE: /jogar"); 
                return 
true
            } 
            for(new 
i=0i<MAX_PLAYERSi++) 
            { 
                if(
IsPlayerConnected(i)) ClearChatbox(i100); 
            } 
            
format(stringsizeof(string), "O admin %s limpou o chat, motivo: %s"PlayerName(playerid), tmp); 
            
SendClientMessageToAll(COLOR_WHITEstring); 
        } 
        return 
true
    } 
Reply
#4

Quote:
Originally Posted by RiqueP
Посмотреть сообщение
Eu nгo uso e nem pretendo usar strrok, mas acho que isso resolve.
PHP код:
if(strcmp(cmd"/lchat"true) == || strcmp(cmd"/limparchat"true) == 0
    { 
        if(
IsPlayerConnected(playerid)) 
        { 
            if(
PlayerInfo[playerid][pAdmin] < 3
            { 
                
SendClientMessage(playeridCOLOR_GREY"Vocк nгo й um admin!"); 
                return 
true
            } 
             
tmp strtok(cmdtextidx); 
            if(!
strlen(tmp)) 
            { 
                
SendClientMessage(playeridCOLOR_GRAD2"USE: /limparchat [motivo]"); 
                return 
true
            } 
              if(
admtrampando[playerid] < && PlayerInfo[playerid][pAdmin] != DONO
            { 
                
SendClientMessage(playeridCOLOR_GRAD1" Vocк nгo estб em modo Admin USE: /jogar"); 
                return 
true
            } 
            for(new 
i=0i<MAX_PLAYERSi++) 
            { 
                if(
IsPlayerConnected(i)) ClearChatbox(i100); 
            } 
            
format(stringsizeof(string), "O admin %s limpou o chat, motivo: %s"PlayerName(playerid), tmp); 
            
SendClientMessageToAll(COLOR_WHITEstring); 
        } 
        return 
true
    } 
sera que ele tem q formatar a string assim ?
format(string, sizeof(string), "O admin %s limpou o chat, motivo: %s", PlayerName(playerid), idx);

isso й, se idx foi criado como uma string nй, tipo new idx[128];

ta meio confuso
Reply
#5

@RiqueP estб funcionando, porйm, quando й digitado uma mensagem com espaзo (Ex: /limparchat Por que eu quero) nгo aparece a mensagem toda e sim a primeira palavra que no caso foi a 'Por'

@Andinho Faz um pouquinho de tempo que nгo mexo na minha GM, mas creio que esteja definido assim: new idx;
Reply
#6

PHP код:
if(strcmp(cmd"/lchat"true) == || strcmp(cmd"/limparchat"true) == 0

    if(
IsPlayerConnected(playerid)) 
    { 
        if(
PlayerInfo[playerid][pAdmin] < 3
        { 
            
SendClientMessage(playeridCOLOR_GREY"Vocк nгo й um admin!"); 
            return 
true
        } 
        
tmp strrest(cmdtextidx); 
        if(!
strlen(tmp)) 
        { 
            
SendClientMessage(playeridCOLOR_GRAD2"USE: /limparchat [motivo]"); 
            return 
true
        } 
          if(
admtrampando[playerid] < && PlayerInfo[playerid][pAdmin] != DONO
        { 
            
SendClientMessage(playeridCOLOR_GRAD1" Vocк nгo estб em modo Admin USE: /jogar"); 
            return 
true
        } 
        for(new 
i=0i<MAX_PLAYERSi++) 
        { 
            if(
IsPlayerConnected(i)) ClearChatbox(i100); 
        } 
        
format(stringsizeof(string), "O admin %s limpou o chat, motivo: %s"PlayerName(playerid), tmp); 
        
SendClientMessageToAll(COLOR_WHITEstring); 
    } 
    return 
true

Sу coloque esta stock abaixo se vocк nгo tiver ela em seu gamemode ou include!
Primeiro vocк compila, se der erro do tipo: error 017: undefined symbol "strrest", ai vocк adiciona ela no final de seu gamemode!
PHP код:
stock strrest(const string[], &index)
{
    new 
length strlen(string);
    while ((
index length) && (string[index] <= ' '))
    {
        
index++;
    }
    new 
offset index;
    new 
result[128];
    while ((
index length) && ((index offset) < (sizeof(result) - 1)))
    {
        
result[index offset] = string[index];
        
index++;
    }
    
result[index offset] = EOS;
    return 
result;

Reply
#7

Glederson_dom ainda estб com o mesmo erro, aparece apenas a primeira palavra, caso й digitado tudo junto, exemplo: "Porqueeuquislimpa" ai aparece, mas separado nгo. Sobre a stock, jб existe, porйm em outro nome, mas й a mesma coisa.

PHP код:
stock strtok(const string[], &index)
{
    new 
length strlen(string);
    while ((
index length) && (string[index] <= ' '))
    {
        
index++;
    }
    new 
offset index;
    new 
result[20];
    while ((
index length) && (string[index] > ' ') && ((index offset) < (sizeof(result) - 1)))
    {
        
result[index offset] = string[index];
        
index++;
    }
    
result[index offset] = EOS;
    return 
result;

Reply
#8

Quote:
Originally Posted by Andinho
Посмотреть сообщение
sera que ele tem q formatar a string assim ?
format(string, sizeof(string), "O admin %s limpou o chat, motivo: %s", PlayerName(playerid), idx);

isso й, se idx foi criado como uma string nй, tipo new idx[128];

ta meio confuso
Se eu nгo me engano, idx costuma ser declarada com o tipo inteiro.

@Topic

Procura algum script de admin por exemplo e usa ele como base. Eu particularmente nгo vi necessidade de strtok por conta do sscanf. De qualquer forma, use oque lhe bem entender.
Reply
#9

Resolvi o problema, obrigado por tentarem ajudar.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)