Error -
bartje01 - 29.06.2011
Hey all.
pawn Код:
if(PlayerInfo[playerid][pFaction] != "Los Santos Police Department") return SendClientMessage(playerid,COLOR_GREY,"You're not allowed to use this command.");
Seriously never sure about this error.
Код:
C:\Users\Bart\Desktop\infinityrp\gamemodes\infinityrp.pwn(650) : error 033: array must be indexed (variable "-unknown-")
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
1 Error.
Re: Error -
Raimis_R - 29.06.2011
I think you checking text from the integer.
Show if(PlayerInfo[playerid][pFaction]) variable
Re: Error -
bartje01 - 29.06.2011
My pFaction is defined as:
pFaction[60];
AW: Error -
Blowfish - 29.06.2011
You can not compare strings with the normal comparision operators like ==, !=, <, >, <= and >=.
What you need to use is strcmp or strncmp. Anyway this way of checking the players fraction or team or
whatever is not performing very well. I's a lot faster, and also less memory consuming, to just
store an integer id.
To your error:
What exactly are you storing in pFaction?
Re: Error -
bartje01 - 29.06.2011
In the pFaction is the name of the faction you are in stored.
pawn Код:
if(strcmp(PlayerInfo[playerid][pFaction] != "Los Santos Police Department")) return SendClientMessage(playerid,COLOR_GREY,"You're not allowed to use this command.");
Still same error
AW: Error -
Blowfish - 29.06.2011
Take a look at the "Array" and "Two Dimensional Arrays" section of this tutorial:
http://wiki.alliedmods.net/Pawn_Tutorial#Arrays
http://wiki.alliedmods.net/Pawn_Tuto...nsional_Arrays and you will understand what your mistake is.
Re: Error -
Shadoww5 - 29.06.2011
Try to remove the quotes.
Or do this way:
PHP код:
new str[128];
format(str, 128, "%s", Los Santos Police Department);
if(PlayerInfo[playerid][pFaction] != str) return SendClientMessage(playerid,COLOR_GREY,"You're not allowed to use this command.");
AW: Error -
Blowfish - 29.06.2011
You can not compare strings with the standard comparison operators.
Furthermore you can not use a string as an index for an array...
Re: Error -
Sasino97 - 29.06.2011
Quote:
Originally Posted by bartje01
Hey all.
pawn Код:
if(PlayerInfo[playerid][pFaction] != "Los Santos Police Department") return SendClientMessage(playerid,COLOR_GREY,"You're not allowed to use this command.");
Seriously never sure about this error.
Код:
C:\Users\Bart\Desktop\infinityrp\gamemodes\infinityrp.pwn(650) : error 033: array must be indexed (variable "-unknown-")
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
1 Error.
|
pawn Код:
if(strcmp(PlayerInfo[playerid][pFaction], "Los Santos Police Department", true) != 0) return SendClientMessage(playerid,COLOR_GREY,"You're not allowed to use this command.");
AW: Error -
Blowfish - 29.06.2011
Okay...
So this is one out of many possible solutions for your problem and by far not the best.
PHP код:
enum playerInfoE {
pMoney,
balh,
blah,
pFaction
}
new playerInfo[MAX_PLAYERS][playerInfoE];
PHP код:
enum {
TEAM_ID_LSPD = 1,
TEAM_ID_LOS_VAGOS,
/* and so on */
}
PHP код:
if(playerInfo[playerid][pFaction] != TEAM_ID_LSPD)
return SendClientMessage(playerid,COLOR_GREY,"You're not allowed to use this command.");