Invalid subscript
#1

Can someone tell me what's wrong with this code?

pawn Код:
format(var, 32, "OP10=%f\n", PlayerInfo[playerid][pOP1[0]]); fwrite(hFile, var); // Line 23201
            format(var, 32, "OP11=%f\n", PlayerInfo[playerid][pOP1[1]]); fwrite(hFile, var);
            format(var, 32, "OP12=%f\n", PlayerInfo[playerid][pOP1[2]]); fwrite(hFile, var);
            format(var, 32, "OP13=%f\n", PlayerInfo[playerid][pOP1[3]]); fwrite(hFile, var);
            format(var, 32, "OP14=%f\n", PlayerInfo[playerid][pOP1[4]]); fwrite(hFile, var);
            format(var, 32, "OP15=%f\n", PlayerInfo[playerid][pOP1[5]]); fwrite(hFile, var);
            format(var, 32, "OP16=%f\n", PlayerInfo[playerid][pOP1[6]]); fwrite(hFile, var);
            format(var, 32, "OP17=%f\n", PlayerInfo[playerid][pOP1[7]]); fwrite(hFile, var);
            format(var, 32, "OP18=%f\n", PlayerInfo[playerid][pOP1[8]]); fwrite(hFile, var);
I get the following errors:
Код:
C:\Users\Admin\Desktop\SAMP\gamemodes\csrp.pwn(23201) : error 028: invalid subscript (not an array or too many subscripts): "pOP1"
C:\Users\Admin\Desktop\SAMP\gamemodes\csrp.pwn(23201) : warning 215: expression has no effect
C:\Users\Admin\Desktop\SAMP\gamemodes\csrp.pwn(23201) : error 001: expected token: ";", but found "]"
C:\Users\Admin\Desktop\SAMP\gamemodes\csrp.pwn(23201) : error 029: invalid expression, assumed zero
C:\Users\Admin\Desktop\SAMP\gamemodes\csrp.pwn(23201) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
This is how I made a variable. It's inside a PlayerInfo enum:
pawn Код:
Float:pOP1[9],
Reply
#2

If not incorrect, since you have an array in an enum, the other array goes on the side of it, not inside of it.

Try this

pawn Код:
format(var, 32, "OP10=%f\n", PlayerInfo[playerid][pOP1][0]); fwrite(hFile, var);
format(var, 32, "OP11=%f\n", PlayerInfo[playerid][pOP1][1]); fwrite(hFile, var);
format(var, 32, "OP12=%f\n", PlayerInfo[playerid][pOP1][2]); fwrite(hFile, var);
format(var, 32, "OP13=%f\n", PlayerInfo[playerid][pOP1][3]); fwrite(hFile, var);
format(var, 32, "OP14=%f\n", PlayerInfo[playerid][pOP1][4]); fwrite(hFile, var);
format(var, 32, "OP15=%f\n", PlayerInfo[playerid][pOP1][5]); fwrite(hFile, var);
format(var, 32, "OP16=%f\n", PlayerInfo[playerid][pOP1][6]); fwrite(hFile, var);
format(var, 32, "OP17=%f\n", PlayerInfo[playerid][pOP1][7]); fwrite(hFile, var);
format(var, 32, "OP18=%f\n", PlayerInfo[playerid][pOP1][8]); fwrite(hFile, var);
Reply
#3

I didn't knew that. Thanks for help, it works now.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)