SA-MP Forums Archive
expected token: "]", but found "-identifier-" - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: expected token: "]", but found "-identifier-" (/showthread.php?tid=100759)



expected token: "]", but found "-identifier-" - _Ben_[Fux-c.co.il RP] - 06.10.2009

format(lastname[playerid], sizeof(lastname[playerid]), "%s", sendername);

Whats the problem here?

gamemodes\larp.pwn(15851) : error 001: expected token: "]", but found "-identifier-"
gamemodes\larp.pwn(15851) : warning 215: expression has no effect
gamemodes\larp.pwn(15851) : error 001: expected token: ";", but found "]"
gamemodes\larp.pwn(15851) : error 029: invalid expression, assumed zero
gamemodes\larp.pwn(15851) : fatal error 107: too many error messages on one line


Re: expected token: "]", but found "-identifier-" - jyrno42 - 06.10.2009

You can't do sizeof on multi-dimensional arrays, just use a value there.


Re: expected token: "]", but found "-identifier-" - _Ben_[Fux-c.co.il RP] - 06.10.2009

So how should I do it works ?


Re: expected token: "]", but found "-identifier-" - Correlli - 06.10.2009

Something like this:
pawn Код:
format(lastname[playerid], MAX_PLAYER_NAME, "%s", sendername);
or:
pawn Код:
format(lastname[playerid], sizeof(lastname), "%s", sendername);



Re: expected token: "]", but found "-identifier-" - _Ben_[Fux-c.co.il RP] - 06.10.2009

Working

Thanks .


Re: expected token: "]", but found "-identifier-" - MenaceX^ - 06.10.2009

Show on the way this: lastname[playerid]
I'm afraid you didn't do it good so only 1 word can enter.


Re: expected token: "]", but found "-identifier-" - Dabombber - 06.10.2009

RTFM?

Quote:
With multi-dimensional arrays, the sizeof operator can return the number
of elements in each dimension. For the last (minor) dimension, an element
will again be a cell, but for the major dimension(s), an element is a sub-array.
In the following code snippet, observe that the syntax sizeof matrix refers
to the major dimension of the two-dimensional array and the syntax sizeof
matrix[] refers to the minor dimension of the array. The values that this
snippet prints are 3 and 2 (for the major and minor dimensions respectively):
pawn Код:
new matrix[3][2] = { { 1, 2 }, { 3, 4 }, { 5, 6 } };
printf("%d %d", sizeof(matrix), sizeof(matrix[]));



Re: expected token: "]", but found "-identifier-" - Nero_3D - 06.10.2009

Quote:
Originally Posted by Dabombber
RTFM?

Quote:
With multi-dimensional arrays, the sizeof operator can return the number
of elements in each dimension. For the last (minor) dimension, an element
will again be a cell, but for the major dimension(s), an element is a sub-array.
In the following code snippet, observe that the syntax sizeof matrix refers
to the major dimension of the two-dimensional array and the syntax sizeof
matrix[] refers to the minor dimension of the array. The values that this
snippet prints are 3 and 2 (for the major and minor dimensions respectively):
pawn Код:
new matrix[3][2] = { { 1, 2 }, { 3, 4 }, { 5, 6 } };
printf("%d %d", sizeof(matrix), sizeof(matrix[]));
fine or fucking manual ? ^^ actually you didnt need to post that
Just let the unknowing be unknowing