SA-MP Forums Archive
Onde estб o erro? =S - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: Onde estб o erro? =S (/showthread.php?tid=178299)



Onde estб o erro? =S [resolvido] - xyu3xx - 21.09.2010

Bem, eu tenho o seguinte cуdigo.


Код:
new idx, tmp[128];
    
    if (!strcmp("/ddd", cmdtext, true)) {
        tmp = strtok(cmdtext, idx);
        SetWeather(strval(tmp));
        return 1;
    }
Nгo funciona.

Acho que o problema й com o meu strtok. Alguem tem a funcao funcionando pra me passar por favor?


Re: Onde estб o erro? =S - [BEP]AcerPilot - 21.09.2010

Antes de todos os comandos:
pawn Код:
new idx;
new cmd[256];
cmd = strtok(cmdtext, idx);
E o comando:
pawn Код:
if(strcmp(cmd, "/ddd", true) == 0)
{
new tmp[256];
new clima;
tmp = strtok(cmdtext, idx);
clima = strval(tmp);
SetWeather(clima);
return 1;
}



Re: Onde estб o erro? =S [ RESOLVIDO] - xyu3xx - 21.09.2010

Ah entendi. O Meu problema entгo era a comparaзгo do strcmp.
Eu fiz o contrбrio da sua.
troquei aqui o cmdtext com o ddd. Fora isso tava legal. Obrigado Acer.
Код:
 if (!strcmp(cmdtext, "/ddd", true)) {
        tmp = strtok(cmdtext, idx);
        SetWeather(strval(tmp));
        return 1;
    }



Re: Onde estб o erro? =S - [BEP]AcerPilot - 21.09.2010

Olha outra melhoria:
pawn Код:
if(strcmp(cmd, "/ddd", true) == 0)
{
new tmp[256];
new clima;
tmp = strtok(cmdtext, idx);
clima = strval(tmp);
if(!strlen(tmp))
{
     SendClientMessage(playerid, COR, "Uso: /ddd [clima]");
     return 1;
}
SetWeather(clima);
return 1;
}



Re: Onde estб o erro? =S - xyu3xx - 21.09.2010

Como estou com o servidor em closed beta ainda, eu to fazendo comandos bem curtos e sem restriзгo, eu adaptei assim.


Код:
public OnPlayerCommandText(playerid, cmdtext[]) {
	new idx;
	
	if(!strcmp(strtok(cmdtext, idx), "/ddd", true)) {
		SetWeather(strval(strtok(cmdtext, idx)));
		return 1;
	}
}
Muito obrigado pela ajuda!