error 001: expected token: "]", but found "-identifier- -
ax1 - 25.11.2016
Код HTML:
enum PlayerData
{
ID,
Name[MAX_PLAYER_NAME]
};
new Player[MAX_PLAYERS][PlayerData];
GetPlayerName(playerid, Player[playerid][Name], sizeof(Player[playerid][Name])); // 7525
I get these errors
Код:
(7525) : error 001: expected token: "]", but found "-identifier-"
(7525) : warning 215: expression has no effect
(7525) : error 001: expected token: ";", but found "]"
(7525) : error 029: invalid expression, assumed zero
(7525) : fatal error 107: too many error messages on one line
Re: error 001: expected token: "]", but found "-identifier- -
Konstantinos - 25.11.2016
You cannot use
sizeof with enum-arrays unless you use
Zeex's compiler patch so you'll have to pass the value yourself:
pawn Код:
GetPlayerName(playerid, Player[playerid][Name], MAX_PLAYER_NAME);
Re: error 001: expected token: "]", but found "-identifier- -
ax1 - 25.11.2016
I still get
(7525) : error 020: invalid symbol name ""
(7525) : error 029: invalid expression, assumed zero
(7525) : warning 215: expression has no effect
Re: error 001: expected token: "]", but found "-identifier- -
Konstantinos - 25.11.2016
The code is correct, invalid symbol name error would be given if the name of the array started with a number for example but that's not it. I can't reproduce it myself, the problem is still something in your script (like defining a symbol that breaks it) so try renaming "Player" and "Name" and see the results.
Re: error 001: expected token: "]", but found "-identifier- -
ax1 - 25.11.2016
Quote:
Originally Posted by Konstantinos
The code is correct, invalid symbol name error would be given if the name of the array started with a number for example but that's not it. I can't reproduce it myself, the problem is still something in your script (like defining a symbol that breaks it) so try renaming "Player" and "Name" and see the results.
|
Does not work. I also tried putting this code in clean gamemode and I still get these errors
Re: error 001: expected token: "]", but found "-identifier- -
Konstantinos - 25.11.2016
Quote:
Originally Posted by ax1
[..] I also tried putting this code in clean gamemode and I still get these errors
|
That's not possible if you use the line as I told you. This compiles:
pawn Код:
#include <a_samp>
enum PlayerData
{
ID,
Name[MAX_PLAYER_NAME]
};
new Player[MAX_PLAYERS][PlayerData];
public OnPlayerConnect(playerid)
{
GetPlayerName(playerid, Player[playerid][Name], MAX_PLAYER_NAME);
return 1;
}
Re: error 001: expected token: "]", but found "-identifier- -
ax1 - 25.11.2016
Quote:
Originally Posted by Konstantinos
That's not possible if you use the line as I told you. This compiles:
pawn Код:
#include <a_samp>
enum PlayerData { ID, Name[MAX_PLAYER_NAME] }; new Player[MAX_PLAYERS][PlayerData];
public OnPlayerConnect(playerid) { GetPlayerName(playerid, Player[playerid][Name], MAX_PLAYER_NAME); return 1; }
|
My bad, I put MAX_PLAYER_NAME in sizeof(). It works, thank you