[AJUDA] Problemas no OnPlayerCommandText -
PawninG - 28.09.2010
O que estб acontecendo й o seguinte, qualquer comando que eu digito, ele executa a aзгo do primeiro comando, que no caso й o /comandos, exemplo, eu digito /morrer, ele aparece as mensagens do comando /comandos.
Public OnPlayerCommandText completa abaixo:
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256];
if(strcmp(cmd, "/comandos", true) == 0 || strcmp(cmd, "/cmds", true) == 0)
{
if(IsPlayerConnected(playerid))
{
SendClientMessage(playerid, COR_BRANCO,"_______________________________________");
SendClientMessage(playerid, COR_AZULCLARO, "/morrer ---------------------------");
SendClientMessage(playerid, COR_AZULCLARO, "-----------------------------------");
SendClientMessage(playerid, COR_BRANCO,"_______________________________________");
}
return 1;
}
if(strcmp(cmdtext, "/morrer", true) == 0)
{
SetPlayerHealth(playerid, 0);
return 1;
}
return 1;
}
Re: [AJUDA] Problemas no OnPlayerCommandText -
PawninG - 28.09.2010
UP, alguem ajuda..
Re: [AJUDA] Problemas no OnPlayerCommandText - [BEP]AcerPilot - 28.09.2010
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new idx;
new cmd[256];
cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/comandos", true) == 0 || strcmp(cmd, "/cmds", true) == 0)
{
if(IsPlayerConnected(playerid))
{
SendClientMessage(playerid, COR_BRANCO,"_______________________________________");
SendClientMessage(playerid, COR_AZULCLARO, "/morrer ---------------------------");
SendClientMessage(playerid, COR_AZULCLARO, "-----------------------------------");
SendClientMessage(playerid, COR_BRANCO,"_______________________________________");
return 1;
}
}
if(strcmp(cmdtext, "/morrer", true) == 0)
{
SetPlayerHealth(playerid, 0);
return 1;
}
return 0;
}
OnPlayerCommandText precisa de return 0 e vocк tinha colocado return 1.
Re: [AJUDA] Problemas no OnPlayerCommandText -
PawninG - 28.09.2010
Quote:
Originally Posted by [BEP]AcerPilot
OnPlayerCommandText precisa de return 0 e vocк tinha colocado return 1.
|
Continuo dando a mesma coisa.. executando a aзгo do comando /comandos.
Re: [AJUDA] Problemas no OnPlayerCommandText - [BEP]AcerPilot - 28.09.2010
Tenta esse:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new idx;
new cmd[256];
cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/comandos", true) == 0 || strcmp(cmd, "/cmds", true) == 0)
{
if(IsPlayerConnected(playerid))
{
SendClientMessage(playerid, COR_BRANCO,"_______________________________________");
SendClientMessage(playerid, COR_AZULCLARO, "/morrer ---------------------------");
SendClientMessage(playerid, COR_AZULCLARO, "-----------------------------------");
SendClientMessage(playerid, COR_BRANCO,"_______________________________________");
return 1;
}
}
if(strcmp(cmd, "/morrer", true) == 0)
{
SetPlayerHealth(playerid, 0);
return 1;
}
return 0;
}
Re: [AJUDA] Problemas no OnPlayerCommandText -
Dr_Pawno - 28.09.2010
nada a ve o return 0;/return 1; no fim do OnPlayerCommandText. Se tive o return 1; no fim do gamemode n vai manda a msg: "SERVER: Unknown command." se o cmd tive errado. Se tive o 0 aparece se tive errado.
Re: [AJUDA] Problemas no OnPlayerCommandText - [BEP]AcerPilot - 28.09.2010
Mas o certo й ter ou return 0; ou um return SendClientMessage na public, senгo o cуdigo nгo vai checar se o comando estб em outro script (como filterscripts). Tem isso na wiki da public, sу olhar lб.
Re: [AJUDA] Problemas no OnPlayerCommandText -
PawninG - 28.09.2010
Quote:
Originally Posted by [BEP]AcerPilot
Tenta esse:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[]) { new idx; new cmd[256]; cmd = strtok(cmdtext, idx); if(strcmp(cmd, "/comandos", true) == 0 || strcmp(cmd, "/cmds", true) == 0) { if(IsPlayerConnected(playerid)) { SendClientMessage(playerid, COR_BRANCO,"_______________________________________"); SendClientMessage(playerid, COR_AZULCLARO, "/morrer ---------------------------"); SendClientMessage(playerid, COR_AZULCLARO, "-----------------------------------"); SendClientMessage(playerid, COR_BRANCO,"_______________________________________"); return 1; } } if(strcmp(cmd, "/morrer", true) == 0) { SetPlayerHealth(playerid, 0); return 1; } return 0; }
|
Funcionou, problema resolvido.