error 033
#1

Hi, I have some problem.
Код:
enum example {
    myName[MAX_PLAYER_NAME]
};
new myInfo[MAX_PLAYERS][example], testStr[MAX_PLAYER_NAME];
format(testStr, sizeof(testStr), "%s", IsPlayerConnected(playerid) ? (myInfo[playerid][myName]) : ("Player is not connected"));
When compiling, an error arises: Эarray must be indexed (variable "-unknown-")"
The error occurs because of the parameter "myInfo[playerid][myName]", if instead substitute, for example
Код:
format(testStr, sizeof(testStr), "%s", IsPlayerConnected(playerid) ? ("My_Name") : ("Player is not connected"));
Then the script will compile without errors. Thank you in advance for your help
Reply
#2

Quote:
Originally Posted by FelixAquero
Посмотреть сообщение
Hi, I have some problem.
Код:
enum example {
    myName[MAX_PLAYER_NAME]
};
new myInfo[MAX_PLAYERS][example], testStr[MAX_PLAYER_NAME];
format(testStr, sizeof(testStr), "%s", IsPlayerConnected(playerid) ? (myInfo[playerid][myName]) : ("Player is not connected"));
When compiling, an error arises: Эarray must be indexed (variable "-unknown-")"
The error occurs because of the parameter "myInfo[playerid][myName]", if instead substitute, for example
Код:
format(testStr, sizeof(testStr), "%s", IsPlayerConnected(playerid) ? ("My_Name") : ("Player is not connected"));
Then the script will compile without errors. Thank you in advance for your help
why have the name stored, there's no noticeable benefit
just use conventional GetName

PHP код:
enum example {
    
myName[MAX_PLAYER_NAME]//not needed anymore
};
new 
myInfo[MAX_PLAYERS][example], testStr[MAX_PLAYER_NAME];
format(testStrsizeof(testStr), "%s"IsPlayerConnected(playerid) ? getName(playerid) : "Player is not connected");
getName(playerid)
{
    new 
n[MAX_PLAYER_NAME];
    
GetPlayerName(playeridnMAX_PLAYER_NAME);
    return 
n;

done
Reply
#3

With the same success, I can write this into a separate variable. I use MyName throughout the script. I'm not interested in workarounds, but how to solve this problem? Why does not it work? Because there are no errors in the syntax
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)