SA-MP Forums Archive
[help] STRCMP - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [help] STRCMP (/showthread.php?tid=595797)



[help] STRCMP - Hayden_Almeida - 08.12.2015

My sub command is not working:

Код:
if(strcmp("/retirar", cmdtext, true) == 0)
{
	if(IsPlayerConnected(playerid))
    {
		new x_Emprego[256];
		x_Emprego = strtok(cmdtext,idx);
		if(!strlen(x_Emprego))
		{
			SendClientMessage(playerid,COLOR_AMARELO_FORTE,"|================ BLF - Retirar =================|");
			return 1;
		}
		else if(strcmp(x_Emprego,"armas",true) == 0)
		{
		    if(togDebug[playerid] == 1) { SendClientMessage(playerid, COLOR_DEBUG, "Debug: 123"); }
		    tmp = strtok(cmdtext,idx);
			if(!strlen(tmp)) return SendClientMessage(playerid,COLOR_WHITE,"USE: /retirar armas [ID do Jogador]");
			new targetID;
			targetID = ReturnUser(tmp);

			new Float:posx, Float:posy, Float:posz;
			GetPlayerPos(targetID, posx,posy,posz);
			new alvo[MAX_PLAYER_NAME];
			GetPlayerName(targetID, alvo,sizeof(alvo));

            if(togDebug[playerid] == 1) { SendClientMessage(playerid, COLOR_DEBUG, "Debug: 124"); }
			if(!IsPlayerConnected(targetID)) return SendClientMessage(playerid, COLOR_AVISO, "Jogador nгo encontrado!");
			if(togDebug[playerid] == 1) { SendClientMessage(playerid, COLOR_DEBUG, "Debug: 125"); }
			if(targetID == playerid) return SendClientMessage(playerid, COLOR_AVISO, "Vocк nгo pode se retirar armas.");
			if(!IsPlayerInRangeOfPoint(playerid, 1.5, posx,posy,posz)) return SendClientMessage(playerid, COLOR_WHITE,"Jogador muito longe para retirar as Armas dele.");
			if(GetPlayerWeapon(playerid) <= 1)
			{
				if(GetPlayerSpecialAction(targetID) == SPECIAL_ACTION_HANDSUP || Algemado[targetID] == true)
                {
                    if(GetPlayerWeapon(targetID) <= 1)
					{
					    ResetPlayerWeapons(targetID);
					}
					else SendClientMessage(playerid, COLOR_AVISO,"Essa pessoa estб com alguma arma na mгo.");
                }
                else SendClientMessage(playerid, COLOR_AVISO,"Jogador nгo estб com as mгos pro alto.");
			}
			else SendClientMessage(playerid, COLOR_AVISO,"Vocк estб com alguma arma na mгo. Fique sem arma na mгo e tente novamente.");
		}
		else { SendClientMessage(playerid, COLOR_AVISO,"??????"); }
	}
	return SendClientMessage(playerid, COLOR_AVISO,"222");
}
Its only executing up to lines:
Код:
SendClientMessage(playerid,COLOR_AMARELO_FORTE,"|================ BLF - Retirar =================|");
return 1;
This line is not beeing executed:
Код:
else if(strcmp(x_Emprego,"armas",true) == 0)
The Usage of the command:
Код:
/retirar armas [Target ID]



Re: [help] STRCMP - Jefff - 08.12.2015

before
pawn Код:
if(strcmp("/retirar", cmdtext, true) == 0)
must be
pawn Код:
cmd = strtok(cmdtext,idx);
then
pawn Код:
if(strcmp("/retirar", cmd, true) == 0)
or without strtok

pawn Код:
if(strcmp("/retirar", cmdtext, true, 8) == 0) // set cmd lenght ("/retirar" - 8 chars)



Re: [help] STRCMP - Hayden_Almeida - 08.12.2015

Quote:
Originally Posted by Jefff
Посмотреть сообщение
before
pawn Код:
if(strcmp("/retirar", cmdtext, true) == 0)
must be
pawn Код:
cmd = strtok(cmdtext,idx);
then
pawn Код:
if(strcmp("/retirar", cmd, true) == 0)
or without strtok

pawn Код:
if(strcmp("/retirar", cmdtext, true, 8) == 0) // set cmd lenght ("/retirar" - 8 chars)
Thanks. The problem was the Lenght "8".