SA-MP Forums Archive
Help with making a /spec cmds - 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: Help with making a /spec cmds (/showthread.php?tid=82871)



Help with making a /spec cmds - tomnidi - 21.06.2009

Код:
if(strcmp(cmd,"/spectate",true) == 0)
	{
		if(IsPlayerConnected(playerid))
	  {
    	tmp = strtok(cmdtext, idx);
			if(PlayerInfo[playerid][pAdmin] < 1)
			{
				SendClientMessage(playerid,COLOR_WHITE,"SERVER: Unknown command.");
				return 0;
			}
			if(!strlen(tmp))
			{
				SendClientMessage(playerid,COLOR_WHITE,"[USAGE]: /spectate [id]");
				return 1;
			}
			giveplayerid = strlen(tmp);
			if(!IsPlayerConnected(giveplayerid) && gPlayerLogged[giveplayerid] == 1)
			{
				SendClientMessage(playerid,COLOR_WHITE,"[SERVER]: Given player is not Connected or not logged in.");
				return 1;
			}
			if(playerid == giveplayerid)
			{
				SendClientMessage(playerid,COLOR_WHITE,"[SERVER]: You cannot spectate youself.");
				return 1;
			}
			if(PlayerInfo[playerid][Spectating] == 1
			{
				SendClientMessage(playerid,COLOR_WHITE,"[SERVER]: You are already spectating");
				return 1;
			}
			TogglePlayerSpectating(playerid,1);
			PlayerSpectatePlayer(playerid,giveplayerid);
			SetPlayerInterior(playerid,GetPlayerInterior(giveplayerid));
			PlayerInfo[playerid][Spectating] = giveplayerid;
		}
		return 1;
	}
Errors:

C:\Documents and Settings\Tom\щемзп дтбегд\samp02Xserver.win32OLD\gamemodes\crp.pwn(11 897) : error 033: array must be indexed (variable "Spectating")
C:\Documents and Settings\Tom\щемзп дтбегд\samp02Xserver.win32OLD\gamemodes\crp.pwn(11 905) : error 033: array must be indexed (variable "Spectating")

Any idieas?


Re: Help with making a /spec cmds - MadeMan - 21.06.2009

Are you missing ")" at the end of

Код:
if(PlayerInfo[playerid][Spectating] == 1



Re: Help with making a /spec cmds - Chivava - 21.06.2009

2 things...

MadeMan do you mean like : if(PlayerInfo[playerid][Specating] == 1) ?
And where do i has to put this, does it has to be a special place in .PWN ?


Re: Help with making a /spec cmds - Correlli - 21.06.2009

Quote:
Originally Posted by Chivava
2 things...

MadeMan do you mean like : if(PlayerInfo[playerid][Specating] == 1) ?
And where do i has to put this, does it has to be a special place in .PWN ?
It needs to be under OnPlayerCommandText callback, all commands must be there.


Re: Help with making a /spec cmds - tomnidi - 21.06.2009

Quote:
Originally Posted by MadeMan
Are you missing ")" at the end of

Код:
if(PlayerInfo[playerid][Spectating] == 1
I closed the line and it still the same error


Re: Help with making a /spec cmds - MadeMan - 21.06.2009

Do you use variable "Spectating" only in PlayerInfo[playerid][Spectating] or somewhere else too?


Re: Help with making a /spec cmds - Klutty - 21.06.2009

Quote:
Originally Posted by Pawn-lang.pdf
033 array must be indexed (variable name)
An array as a whole cannot be used in a expression; you must
indicate an element of the array between square brackets.



Re: Help with making a /spec cmds - tomnidi - 21.06.2009

Quote:
Originally Posted by Klutty
Quote:
Originally Posted by Pawn-lang.pdf
033 array must be indexed (variable name)
An array as a whole cannot be used in a expression; you must
indicate an element of the array between square brackets.
And how can I do that?


Re: Help with making a /spec cmds - MadeMan - 21.06.2009

How is your variable "Spectating" declared in the beginning of your script?


Re: Help with making a /spec cmds - dice7 - 21.06.2009

Just delete [spectating]