[Ajuda] Comando
#1

Olб a todos, fiz um comando em sscanf e zcmd, quero passar para strcmp, se alguйm puder me ajudar, grato desde jб...
Eu sei que a velocidade do sscanf com o zcmd й mil vezes mais rбpido mas й que eu preciso desse comando em strcmp

Cуdigo:
PHP код:
CMD:pedirevento(playeridparams[])
{
    new 
peTexto[64];
    new 
peName[MAX_PLAYER_NAME];
    new 
peString[128];
    if(
sscanf(params"s"peTexto)) return SendClientMessage(playeridCORX1"| ERRO | Uso: /pedirevento [Modalidade]");
    if((
Evento1(playerid)) || (Evento2(playerid)) || (IsPlayerAdmin(playerid)))
    
GetPlayerName(playeridpeNamesizeof(peName));
    
format(peStringsizeof(peString), "| PEDIDO | %s - [ID: %d] estб pedindo o evento: %s"peNameplayeridpeTexto);
    
SendClientMessage(playerid, -1peString);
    return 
true;

Obrigado desde jб.
Reply
#2

Strcmp
Код:
strcmp(const string1[], const string2[], bool:ignorecase=false, length=cellmax)
Compare a string1 (comando/text) com string2 (comando/text), depois em ignorecase coloque true e length й opcional.
Reply
#3

@Edit:
Na verdade eu queria aprender sscanf e zcmd, atй estava tentando fazer alguns comandos e tal.
Mas depois que coloquei o comando na gamemode (strcmp) alguns comandos retornavam UNKNOWN, queria saber como corrigir isto :/
Reply
#4

Quote:
Originally Posted by GuilhermeW
Посмотреть сообщение
@Edit:
Na verdade eu queria aprender sscanf e zcmd, atй estava tentando fazer alguns comandos e tal.
Mas depois que coloquei o comando na gamemode (strcmp) alguns comandos retornavam UNKNOWN, queria saber como corrigir isto :/
Se vc for usar zcmd, todos os comandos do gm tem que ser em zcmd
Reply
#5

Eu queria fazer o comando: /pedirevento [Texto] apenas para admins logados na rcon, se alguйm puder fazer por strcmp e me mandar, jб tentei diversas vezes mas nгo consegui, sei que й algo bбsico mas ainda estou aprendendo

Sу pra constar, eu sei fazer em sscanf e zcmd, mas queria aprender em strcmp, estou tentando buscar exemplos para aprender com strcmp...
Reply
#6

Aqui esta amigo pode ser usado como fs se quiser

PHP код:
#include a_samp
public OnPlayerCommandText(playeridcmdtext[])
{
    new 
cmd[100], idx;
    
cmd strtok(cmdtextidx);
    if (
strcmp("/pedirevento"cmdtrue) == 0)
    {
    new 
tmp1[20], peString[144];
    
tmp1 strtok(cmdtextidx);
    if (!
strlen(tmp1)) return SendClientMessage(playerid, -1"{FF0000}Uso: /pedirevento \"Modalidade\"");
    
format(peStringsizeof(peString), "| PEDIDO | %s - [ID: %d] estб pedindo o evento: %s"pName(playerid), playeridtmp1);
       for(new 
iGetMaxPlayers(); i++)
    {
        if(
IsPlayerConnected(i) && IsPlayerAdmin(i))
        {
        
SendClientMessage(playerid, -1peString);
        }
    }
     return 
1;
}
    return 
0;
}
stock pName(playerid)
{
    static 
name[24];
    
GetPlayerName(playeridname24);
    return 
name;
}
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;

Aqui so o comando
PHP код:
if (strcmp("/pedirevento"cmdtrue) == 0)
    {
    new 
peTexto[64];
    new 
peName[MAX_PLAYER_NAME];
    new 
peString[128];
    
peTexto strtok(cmdtextidx);
    
    if (!
strlen(peTexto)) return SendClientMessage(playerid, -1"{FF0000}Uso: /pedirevento \"Modalidade\"");
    
GetPlayerName(playeridpeNamesizeof(peName));
    if (!
strlen(peTexto)) return SendClientMessage(playerid, -1"{FF0000}Uso: /pedirevento \"Modalidade\"");
    
format(peStringsizeof(peString), "| PEDIDO | %s - [ID: %d] estб pedindo o evento: %s"peNameplayeridpeTexto);
       for(new 
iGetMaxPlayers(); i++)
    {
        if(
IsPlayerConnected(i) && IsPlayerAdmin(i))
        {
        
SendClientMessage(playerid, -1peString);
        }
    }
    return 
true;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)