[DUVIDA]Erro de comando
#1

Bom..eu to criando um GM .. comeзei do 0 e coloquei /creditos com os creditos .. mas toda vez que digito um comando no server aparece exatamente oq esta escrito nos creditos :

Код:
public OnPlayerCommandText(playerid, cmdtext[])

{
   
	new cmd[256];

	if(strcmp(cmd, "/creditos", true) == 0) {
	SendClientMessage(playerid, COLOR_AQUA,"{FFFFFF}Creditos do GM ^^");
	SendClientMessage(playerid, COLOR_AQUA,"{D15FEE}Gamemode {FF0000}FreeFlyght V1.0.");
	SendClientMessage(playerid, COLOR_VERMELHO,"{FFFF00}Coder: Gabriel.");
	SendClientMessage(playerid, COLOR_VERMELHO,"{00FFFF}Mapper:Pigon.");
    return 1;
	 }

    if(strcmp(cmd, "/dm1", true) == 0) {
    SendClientMessage(playerid, COLOR_AQUA,"{FFFFFF}Em Breve !  ^^");
    return 1;
	  }

    if(strcmp(cmd, "/dogfight", true) == 0) {
    SendClientMessage(playerid, COLOR_AQUA,"{FFFFFF}Em Breve ArenaDogFight !  ^^");
    return 1;
	  }

    if(strcmp(cmd, "/comandos", true) == 0) {
     SendClientMessage(playerid, COLOR_AQUA,"{FFFFFF}Arenas DM : /dm1 /dm2 /dm3 /dm4 /dm5");
     SendClientMessage(playerid, COLOR_AQUA,"{FFFFFF}/creditos e veja quem criou o servidor ^^");
     SendClientMessage(playerid, COLOR_AQUA,"{FFFFFF}/dogfight e va para a arena de dogfight  ^^");
     SendClientMessage(playerid, COLOR_AQUA,"{FFFFFF}/relato e fale com o admin   ^^");
     SendClientMessage(playerid, COLOR_AQUA,"{FFFFFF}Em Breve mais comandos !  ^^");
Reply
#2

e oque tu queria? explique-se melhor.
Reply
#3

eu digito o comando /dogfight e como nao ta pronto ainda .. aparece a mensagem : Em Breve Arena DogFight ! .. tipo oq eu tentei faser
Reply
#4

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])

{
        cmd=strtok(cmdtext,idx);
    new cmd[256];

    if(strcmp(cmd, "/creditos", true) == 0) {
    SendClientMessage(playerid, COLOR_AQUA,"{FFFFFF}Creditos do GM ^^");
    SendClientMessage(playerid, COLOR_AQUA,"{D15FEE}Gamemode {FF0000}FreeFlyght V1.0.");
    SendClientMessage(playerid, COLOR_VERMELHO,"{FFFF00}Coder: Gabriel.");
    SendClientMessage(playerid, COLOR_VERMELHO,"{00FFFF}Mapper:Pigon.");
    return 1;
     }

    if(strcmp(cmd, "/dm1", true) == 0) {
    SendClientMessage(playerid, COLOR_AQUA,"{FFFFFF}Em Breve !  ^^");
    return 1;
      }

    if(strcmp(cmd, "/dogfight", true) == 0) {
    SendClientMessage(playerid, COLOR_AQUA,"{FFFFFF}Em Breve ArenaDogFight !  ^^");
    return 1;
      }

    if(strcmp(cmd, "/comandos", true) == 0) {
     SendClientMessage(playerid, COLOR_AQUA,"{FFFFFF}Arenas DM : /dm1 /dm2 /dm3 /dm4 /dm5");
     SendClientMessage(playerid, COLOR_AQUA,"{FFFFFF}/creditos e veja quem criou o servidor ^^");
     SendClientMessage(playerid, COLOR_AQUA,"{FFFFFF}/dogfight e va para a arena de dogfight  ^^");
     SendClientMessage(playerid, COLOR_AQUA,"{FFFFFF}/relato e fale com o admin   ^^");
     SendClientMessage(playerid, COLOR_AQUA,"{FFFFFF}Em Breve mais comandos !  ^^");
Ou Veja se sua Public CommandText esta retornando 0.

@Edit

E SE NГO TIVER:
Coloque no fim do GM
pawn Код:
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
#5

dex aeu ver si entendi,
Temos um exemplo aqui:
eu digito /dofight
ai aparece o comandos /creditos ?
Reply
#6

pra que o uso da strtok -.-
Reply
#7

Tipo... ta dando erro que quando eu digito um comando /dogfight ou /abuuaigfgauegwi aparece A MESMA COISA ESCRITA NO /CREDITOS.. saco?
Reply
#8

Entao, eu tinha tido isso, coloquei sa porra ae
pawn Код:
cmd=strtok(cmdtext,idx);
Na Public e funfo ._.
Reply
#9

Explica direito ae pq sou novato nisso xD Colocou onde?
Reply
#10

Quote:
Originally Posted by Douglas_FusioN
Посмотреть сообщение
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])

{
        cmd=strtok(cmdtext,idx);
    new cmd[256];

    if(strcmp(cmd, "/creditos", true) == 0) {
    SendClientMessage(playerid, COLOR_AQUA,"{FFFFFF}Creditos do GM ^^");
    SendClientMessage(playerid, COLOR_AQUA,"{D15FEE}Gamemode {FF0000}FreeFlyght V1.0.");
    SendClientMessage(playerid, COLOR_VERMELHO,"{FFFF00}Coder: Gabriel.");
    SendClientMessage(playerid, COLOR_VERMELHO,"{00FFFF}Mapper:Pigon.");
    return 1;
     }

    if(strcmp(cmd, "/dm1", true) == 0) {
    SendClientMessage(playerid, COLOR_AQUA,"{FFFFFF}Em Breve !  ^^");
    return 1;
      }

    if(strcmp(cmd, "/dogfight", true) == 0) {
    SendClientMessage(playerid, COLOR_AQUA,"{FFFFFF}Em Breve ArenaDogFight !  ^^");
    return 1;
      }

    if(strcmp(cmd, "/comandos", true) == 0) {
     SendClientMessage(playerid, COLOR_AQUA,"{FFFFFF}Arenas DM : /dm1 /dm2 /dm3 /dm4 /dm5");
     SendClientMessage(playerid, COLOR_AQUA,"{FFFFFF}/creditos e veja quem criou o servidor ^^");
     SendClientMessage(playerid, COLOR_AQUA,"{FFFFFF}/dogfight e va para a arena de dogfight  ^^");
     SendClientMessage(playerid, COLOR_AQUA,"{FFFFFF}/relato e fale com o admin   ^^");
     SendClientMessage(playerid, COLOR_AQUA,"{FFFFFF}Em Breve mais comandos !  ^^");
Ou Veja se sua Public CommandText esta retornando 0.

@Edit

E SE NГO TIVER:
Coloque no fim do GM
pawn Код:
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;
}
Substitua o codigo que vocк colocou ali em cima por este. (o 1 ali '-')
Se nгo tiver no seu GM coloque no final o segundo codigo.
Reply
#11

gscoder poderia me explicar direito oque deseja tu me deixo confuso ;s
Reply
#12

Код:
C:\Users\Gabriel\Downloads\samp03dsvr_R2_win32\gamemodes\GM1.pwn(908) : error 017: undefined symbol "cmd"
C:\Users\Gabriel\Downloads\samp03dsvr_R2_win32\gamemodes\GM1.pwn(908) : error 017: undefined symbol "idx"
C:\Users\Gabriel\Downloads\samp03dsvr_R2_win32\gamemodes\GM1.pwn(1265) : warning 219: local variable "string" shadows a variable at a preceding level
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.


Coloquei la no fim do gm :
Код:
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
#13

Histire, Ex:
Ele criou o cmd /creditos, agora todo comando que ele usa executa o cmd /creditos.
Tendeu?
Reply
#14

No comeзo da Public:
pawn Код:
new cmd[20], idx;
Reply
#15

Apague o new cmd no comeзo da public OnPlayerCommandText

em seguida coloque isso:

pawn Код:
new cmd[256],tmp[128],idx;
cmd = strtok(cmdtext,idx);
e nos comandos, vc usa:

exemplo:

pawn Код:
if(strcmp(cmd, "/comando", true) == 0)
    {
            tmp = strtok(cmdtext,idx);
           if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_GRAD2, "USE: /comando[Id Do Jogador]");
           SendClientMessage(strval(tmp),-1,"mensagem");
    }
Reply
#16

Problema Resolvido ! Obrigado

Pra quem tem interesse em ver como ficou com o problema resolvido :

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[20], idx;
    cmd=strtok(cmdtext,idx);
  
    if(strcmp(cmd, "/creditos", true) == 0) {
    SendClientMessage(playerid, COLOR_AQUA,"{FFFFFF}Creditos do GM ^^");
    SendClientMessage(playerid, COLOR_AQUA,"{D15FEE}Gamemode {FF0000}FreeFlyght V1.0.");
    SendClientMessage(playerid, COLOR_VERMELHO,"{FFFF00}Coder: Gabriel.");
    SendClientMessage(playerid, COLOR_VERMELHO,"{00FFFF}Mapper:Pigon.");
    return 1;
     }

    if(strcmp(cmd, "/dm1", true) == 0) {
    SendClientMessage(playerid, COLOR_AQUA,"{FFFFFF}Em Breve !  ^^");
    return 1;
      }

    if(strcmp(cmd, "/dogfight", true) == 0) {
    SendClientMessage(playerid, COLOR_AQUA,"{FFFFFF}Em Breve ArenaDogFight !  ^^");
    return 1;
      }

    if(strcmp(cmd, "/comandos", true) == 0) {
     SendClientMessage(playerid, COLOR_AQUA,"{FFFFFF}Arenas DM : /dm1 /dm2 /dm3 /dm4 /dm5");
     SendClientMessage(playerid, COLOR_AQUA,"{FFFFFF}/creditos e veja quem criou o servidor ^^");
     SendClientMessage(playerid, COLOR_AQUA,"{FFFFFF}/dogfight e va para a arena de dogfight  ^^");
     SendClientMessage(playerid, COLOR_AQUA,"{FFFFFF}/relato e fale com o admin   ^^");
     SendClientMessage(playerid, COLOR_AQUA,"{FFFFFF}Em Breve mais comandos !  ^^");
	 return 1;
	 }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)