#1

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

I think you checking text from the integer.

Show if(PlayerInfo[playerid][pFaction]) variable
Reply
#3

My pFaction is defined as:

pFaction[60];
Reply
#4

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

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

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

Try to remove the quotes.

Or do this way:

PHP код:
new str[128];
format(str128"%s"Los Santos Police Department);

if(
PlayerInfo[playerid][pFaction] != str)  return SendClientMessage(playerid,COLOR_GREY,"You're not allowed to use this command."); 
Reply
#8

You can not compare strings with the standard comparison operators.
Furthermore you can not use a string as an index for an array...
Reply
#9

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.");
Reply
#10

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."); 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)