Array must be indexed error.
#1

Hi, been trying something different with my script instead of making a bunch of different stocks and stuff to do some work I was using this.

pawn Код:
SendLocalMessage(playerid, 30.0, COLOR_PURPLE, "* %s has put away their cellphone.", (pMaskOn[playerid]) ? (PlayerData[playerid][pMask]) : (PlayerName(playerid, false)))
However I am getting this error ->

pawn Код:
C:\Desktop\new_0.1.5.pwn(11400) : error 033: array must be indexed (variable "PlayerName")
I will state that "PlayerName" is a stock that returns a player name and PlayerData[playerid][pMask] will return a string based on the name of their mask Eg: Masked_12345.

pMaskOn[playerid] is an Boolean either true or false. IF anyone knows how to fix this I'd greatly appreciate it, thanks.

Edit: I just worked around it by making a stock that returns a string, for some reason it wasn't detecting the PlayerData[playerid][pMask] being a string, thanks anyway.

Fix:

Код:
stock Mask(playerid) {
     new mask[24];
     format(mask, sizeof(mask), PlayerData[playerid][pMask]);
     return mask;
}
And then for the pMask Comparison change the PlayerData[playerid][pMask] to whatever you named your stock.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)