SA-MP Forums Archive
Non-working command - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Non-working command (/showthread.php?tid=138278)



Non-working command - Packer5 - 01.04.2010

Код:
if (strcmp("/spyspec", cmdtext, true, 10) == 0)

{
	if (pInfo[playerid][pSpy] == 1)
	{
	  if (pInfo[playerid][pSpec] == 1)
	    {
	      TogglePlayerSpectating(playerid, 0);
	      pInfo[playerid][pSpec] = 0;
			}
			else
			{
			  pInfo[playerid][pSpec] = 1;
				new idx;
				new tmp[30];
				tmp = strtok(cmdtext, idx);
		    new otherplayer = strval(tmp);
		    if(IsPlayerConnected(otherplayer))
		    {
		      TogglePlayerSpectating(playerid, 1);
			  	PlayerSpectatePlayer(playerid, otherplayer); //if you want you can copy this command and change Ban to Kick to kick a player
		    }
		return 1;}
  }
  else
  {
		SendClientMessage(playerid, COLOR_RED, "** You need to be a spy to use that command");
	}
	return 1;
	}
if I do /spyspec 0, it gives me unknown command. However if I do /spyspec when I'm a spy, it specs ID 0.

I can't work out why



Re: Non-working command - [MWR]Blood - 01.04.2010

Well, its specs ID 0 because you do only /spyspec.Try /spyspec 1 or 2 or whatever...


Re: Non-working command - Last_Stand_Guardian - 01.04.2010

Classic strtok mistake xD ^^

Change:
pawn Код:
if (strcmp("/spyspec", cmdtext, true, 10) == 0)
to
pawn Код:
if(strcmp(cmd, "/spyspec", true) == 0)
I hope you have defined
pawn Код:
new cmd[256], idx;
and
pawn Код:
cmd = strtok(cmdtext, idx);
under
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])



Re: Non-working command - Packer5 - 01.04.2010

thanks