[Ajuda] Como passo esse cmd zcmd pra strcmp?
#1

Galera me ajude passa esse codigo pra strcmp?

Код:
if(sscanf(params,"dd",id1,id2)) return SendClientMessage(playerid,COR_JEFF2,"Uso: /x1 [id1] [id2]");
Obrigado, se puderem me ajudar
Reply
#2

Quote:
Originally Posted by zCyan
Посмотреть сообщение
Galera me ajude passa esse codigo pra strcmp?

Код:
if(sscanf(params,"dd",id1,id2)) return SendClientMessage(playerid,COR_JEFF2,"Uso: /x1 [id1] [id2]");
Obrigado, se puderem me ajudar
Isso nгo й cmd em zcmd, й sscanf
Reply
#3

Quote:
Originally Posted by IlanZ
Посмотреть сообщение
Isso nгo й cmd em zcmd, й sscanf
Tlg pow, mais como faзo esse sisteminha de x1 [id] [id2] em strcmp?
Reply
#4

Uma dъvida, por que quer usar strcmp em 2017?
Reply
#5

para nгo usar sscanf terб q usar strtok, um pouco inferior mas com a mesma funcгo.

Quote:
Originally Posted by renatog
Посмотреть сообщение
Uma dъvida, por que quer usar strcmp em 2017?
Talvez porquк nem todos tenham o mesmo gosto. Eu particularmente nгo gosto de zCMD, sscanf, dof2 e nem por isso julgo quem usa.
Reply
#6

PHP код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new 
cmd[128], tmp[128], idx, idx2;
    
cmd = strtok(cmdtext, idx);

    if(!
strcmp(cmd, "/x1", true))
    {
        
tmp = strtok(cmdtext, idx);
        new 
tmp2[128];
        
tmp2 = strtok(cmdtext, idx);

        if (!
strlen(tmp) || !strlen(tmp2)) return SendClientMessage(playerid, 0xFF0000FF, "Uso: /x1 [id1] [id2]");
        new 
id1 = strval(tmp);
        new 
id2 = strval(tmp2);

        
// faзa o que quiser com os 2 ids

        
return 1;
    }
    return 
0;
}

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
#7

Amigo te aconselho a utilizar ZCMD й bem mais pratico de utilizar, vocк nгo vai ter tanta dor de cabeзa.
Reply
#8

Quote:
Originally Posted by renatog
Посмотреть сообщение
Uma dъvida, por que quer usar strcmp em 2017?
Verdade
Reply
#9

Quote:
Originally Posted by HardWar
Посмотреть сообщение
PHP код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new 
cmd[128], tmp[128], idx, idx2;
    
cmd = strtok(cmdtext, idx);
    if(!
strcmp(cmd, "/x1", true))
    {
        
tmp = strtok(cmdtext, idx);
        new 
tmp2[128];
        
tmp2 = strtok(cmdtext, idx);
        if (!
strlen(tmp) || !strlen(tmp2)) return SendClientMessage(playerid, 0xFF0000FF, "Uso: /x1 [id1] [id2]");
        new 
id1 = strval(tmp);
        new 
id2 = strval(tmp2);
        
// faзa o que quiser com os 2 ids
        
return 1;
    }
    return 
0;
}
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;
} 
Obrigado Mano
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)