error 001: expected token: "]", but found "-identifier-
#1

Код 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
Reply
#2

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);
Reply
#3

I still get

(7525) : error 020: invalid symbol name ""
(7525) : error 029: invalid expression, assumed zero
(7525) : warning 215: expression has no effect
Reply
#4

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.
Reply
#5

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
Reply
#6

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;
}
Reply
#7

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)