Non-working command
#1

Код:
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
Reply
#2

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

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[])
Reply
#4

thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)