Array must be indexed error. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Array must be indexed error. (
/showthread.php?tid=602881)
Array must be indexed error. [Fixed] -
TheCoopster - 14.03.2016
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.