Help with making a /spec cmds
#1

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

Are you missing ")" at the end of

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

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 ?
Reply
#4

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.
Reply
#5

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
Reply
#6

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

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.
Reply
#8

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?
Reply
#9

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

Just delete [spectating]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)