What causes array must be indexed (variable "")?
#1

So I'm currently learning how to use bool,

I'm now trying to disable commands while a player is in lobby, and also when the player receives the login dialog, (Because you can press f6 to avoid the dialog(any dialog) and you get the chat bar and you can type commands such as /arena and stuff.)

So what I've added at the top of the script

Код:
new bool:Spawned[MAX_PLAYERS];
And on some few call backs such as OnPlayerConnect(and more), I've added this
Код:
Spawned[playerid] = false;
.

Now on my lobby code for example I'm experiencing this error:

Код:
C:\Users\yan\Desktop\SA-MP Server\gamemodes\DBv1.pwn(620) : error 033: array must be indexed (variable "Spawned")
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
and Here's the line:

Код:
  {
    if(Spawned == false) return SendClientMessage(playerid, -1, "{c3c3c3}(INFO) You can't use any commands while in lobby, Type /back.");
  }
Full code:

Код:
CMD:lobby(playerid,params[])
{
  PlayerTotalKills[playerid] = 0; // variable that setts the current player's killing spree to 0.
  AFK[playerid] = false;
  AFK[playerid] = 0;
  new interiorID = GetPlayerInterior(playerid);
  new Float:health;
  GetPlayerHealth(playerid, health);
  if(health  > 90)
  {
	 SetPlayerPos(playerid, -975.975708,1060.983032,1345.671875);
	 SetPlayerInterior(playerid,10);
	 SetPlayerVirtualWorld(playerid,10);
	 SetPlayerHealth(playerid, 9999);
	 ResetPlayerWeapons(playerid);
	 SendClientMessage(playerid, -1, "{EFB509}(INFO) You have teleported to the lobby! In order to go back use /back.");
	 AFKTime[playerid] = false;
  }
  else
  {
    if(interiorID == 0) return SendClientMessage(playerid, -1, "{c3c3c3}(INFO) Atleast 90hp is required in order to go to lobby.");
  }
  {
    if(interiorID == 10) return SendClientMessage(playerid, -1, "{c3c3c3}You are already in the lobby! Use /back to return playing.");
  }
  {
    if(Spawned == false) return SendClientMessage(playerid, -1, "{c3c3c3}(INFO) You can't use any commands while in lobby, Type /back.");
  }
  return 1;
}
Reply
#2

pawn Код:
Spawned == false
Well, you want Spawned state of the current player, and Spawned is an array of players spawned status, so... Access it at playerid index?
Reply
#3

I don't get you, By the way I've edited it to

Код:
new bool:inLobby[128];
Код:
CMD:lobby(playerid,params[])
{
  PlayerTotalKills[playerid] = 0; // variable that setts the current player's killing spree to 0.
  AFK[playerid] = false;
  AFK[playerid] = 0;
  new interiorID = GetPlayerInterior(playerid);
  new Float:health;
  GetPlayerHealth(playerid, health);
  if(health  > 90)
  {
	 SetPlayerPos(playerid, -975.975708,1060.983032,1345.671875);
	 SetPlayerInterior(playerid,10);
	 SetPlayerVirtualWorld(playerid,10);
	 SetPlayerHealth(playerid, 9999);
	 ResetPlayerWeapons(playerid);
	 SendClientMessage(playerid, -1, "{EFB509}(INFO) You have teleported to the lobby! In order to go back use /back.");
	 AFKTime[playerid] = false;
  }
  else
  {
    if(interiorID == 0) return SendClientMessage(playerid, -1, "{c3c3c3}(INFO) Atleast 90hp is required in order to go to lobby.");
  }
  {
    if(interiorID == 10) return SendClientMessage(playerid, -1, "{c3c3c3}You are already in the lobby! Use /back to return playing.");
  }
  {
    if(inLobby == false) return SendClientMessage(playerid, -1, "{c3c3c3}(INFO) You can't use any commands while in lobby, Type /back.");
  }
  return 1;
}
It saved me some other errors,

But that still appears
Код:
C:\Users\yan\Desktop\SA-MP Server\gamemodes\DBv1.pwn(621) : error 033: array must be indexed (variable "inLobby")
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Reply
#4

All You need is to :
change :
Код:
  if(inLobby == false) return SendClientMessage(playerid, -1, "{c3c3c3}(INFO) You can't use any commands while in lobby, Type /back.");
To :
Код:
  if(inLobby[playerid] == false) return SendClientMessage(playerid, -1, "{c3c3c3}(INFO) You can't use any commands while in lobby, Type /back.");
If There is more errors please tell me
Reply
#5

I've fixed it, I had to change the bool from;

Код:
new bool:inLobby[128]l
to
Код:
new bool:inLobby;
Reply
#6

Quote:
Originally Posted by ivndosos
Посмотреть сообщение
I've fixed it, I had to change the bool from;

Код:
new bool:inLobby[128]l
to
Код:
new bool:inLobby;
Edit
Код:
new bool:Spawned[MAX_PLAYERS];
To
Код:
new bool:Spawned;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)