undefined symbol "playerid"
#1

I have created an enum containing CMD permission. but why I get an error?
Whereas above enum that contains CMD permission there is enum pInfo. Can you guys help me?

Код:
undefined symbol "playerid"
PHP код:
enum (<<= 1)
{
    
CMD_OWNER PlayerInfo[playerid][pAdmin] == 999999,
    
CMD_PATRIOT PlayerInfo[playerid][pAdmin] == 69,
    
CMD_DEVELOPER PlayerInfo[playerid][pAdmin] == 12,
    
CMD_HEADA PlayerInfo[playerid][pAdmin] == 11,
    
CMD_ADMIN PlayerInfo[playerid][pAdmin] == 4,
    
CMD_JADMIN PlayerInfo[playerid][pAdmin] == 3,
    
CMD_MOD PlayerInfo[playerid][pAdmin] == 2,
    
CMD_JMOD PlayerInfo[playerid][pAdmin] == 1,
    
CMD_MAPPER PlayerInfo[playerid][pMapper] == 1,
    
CMD_FMOD PlayerInfo[playerid][pFMOD] == 1,
    
CMD_GMOD PlayerInfo[playerid][pGMOD] == 1,
    
CMD_SEC PlayerInfo[playerid][pSecurity] == 1
}
new 
cmdPerm[MAX_PLAYERS]; 
Reply
#2

Try changing "playerid" to "MAX_PLAYERS" while I don't even support doing it like that..
Reply
#3

Quote:
Originally Posted by JasonRiggs
Посмотреть сообщение
Try changing "playerid" to "MAX_PLAYERS" while I don't even support doing it like that..
I've try it, but i got another error.. like this
Код:
must be a constant expression; assumed zero
Reply
#4

Or, should I create a variable? like this?

PHP код:
new  CMD_OWNER PlayerInfo[MAX_PLAYERS][pAdmin] == 999999,
    
CMD_PATRIOT PlayerInfo[MAX_PLAYERS][pAdmin] == 69,
    
CMD_DEVELOPER PlayerInfo[MAX_PLAYERS][pAdmin] == 12,
    
CMD_HEADA PlayerInfo[MAX_PLAYERS][pAdmin] == 11,
    
CMD_ADMIN PlayerInfo[MAX_PLAYERS][pAdmin] == 4,
    
CMD_JADMIN PlayerInfo[MAX_PLAYERS][pAdmin] == 3,
    
CMD_MOD PlayerInfo[MAX_PLAYERS][pAdmin] == 2,
    
CMD_JMOD PlayerInfo[MAX_PLAYERS][pAdmin] == 1,
    
CMD_MAPPER PlayerInfo[MAX_PLAYERS][pMapper] == 1,
    
CMD_FMOD PlayerInfo[MAX_PLAYERS][pFMOD] == 1,
    
CMD_GMOD PlayerInfo[MAX_PLAYERS][pGMOD] == 1,
    
CMD_SEC PlayerInfo[MAX_PLAYERS][pSecurity] == 1
I'm really confused XD
Reply
#5

You could create enums normally..
PHP код:
enum (<<=1)
{
     
CMD_OWNER,
    
CMD_PATRIOTetc..

And save them after as you wish.. depends on what you're trying to do
Reply
#6

Quote:
Originally Posted by JasonRiggs
Посмотреть сообщение
You could create enums normally..
PHP код:
enum (<<=1)
{
     
CMD_OWNER,
    
CMD_PATRIOTetc..

And save them after as you wish.. depends on what you're trying to do
Ohh!! okay okayy i got it!
Reply
#7

you cannot use playerid or max_players in a enum
enum goes simply
PHP код:
enum
{
pCash,
pVIP

Reply
#8

You have to create enums normally...
PHP код:
enum blabla
{
     
CMD_OWNER,
    
CMD_PATRIOT//, etc..

Then use variable
like
PHP код:
new  PlayerInfo[MAX_PLAYERS][blabla]; 
And error of undefined playerid is occurs when you doing this in OnGameModeInit or where they playerid is not defined in Callback then use for statement. Like
PHP код:
// OnGameModeInit()
for(new playerid=0playerid<MAX_PLAYERSplayerid++)
{
 
// Your statements here...

Reply
#9

You might be using it in Pawn.CMD.
use it like this
PHP код:
enum (<<= 1)
{
    
CMD_OWNER
};
flags:test(CMD_OWNER);
CMD:test(playeridparams[])
{
     
//do anything
     
return 1;
}
public 
OnPlayerCommandReceived(playeridcmd[], params[], flags)
{
    if((
flags CMD_OWNER) && PlayerInfo[playerid][pAdmin] < 999999)
    {
        return 
0;
    }
    return 
1;

Reply
#10

Quote:
Originally Posted by Zeth
Посмотреть сообщение
You might be using it in Pawn.CMD.
use it like this
PHP код:
... 
At least explain him what he did wrong instead of just throwing up some code.
This means that you're not aware yourself of what the code is supposed to do.
Also, shouldn't it be
Код:
CMD_OWNER = 1
?

Just a suggestion! Deep apologies if offended.

Quote:
Originally Posted by AlfaSufaIndo
Посмотреть сообщение
I have created an enum containing CMD permission. but why I get an error?
Whereas above enum that contains CMD permission there is enum pInfo. Can you guys help me?

Код:
undefined symbol "playerid"
PHP код:
enum (<<= 1)
{
    
CMD_OWNER PlayerInfo[playerid][pAdmin] == 999999,
    
CMD_PATRIOT PlayerInfo[playerid][pAdmin] == 69,
    
CMD_DEVELOPER PlayerInfo[playerid][pAdmin] == 12,
    
CMD_HEADA PlayerInfo[playerid][pAdmin] == 11,
    
CMD_ADMIN PlayerInfo[playerid][pAdmin] == 4,
    
CMD_JADMIN PlayerInfo[playerid][pAdmin] == 3,
    
CMD_MOD PlayerInfo[playerid][pAdmin] == 2,
    
CMD_JMOD PlayerInfo[playerid][pAdmin] == 1,
    
CMD_MAPPER PlayerInfo[playerid][pMapper] == 1,
    
CMD_FMOD PlayerInfo[playerid][pFMOD] == 1,
    
CMD_GMOD PlayerInfo[playerid][pGMOD] == 1,
    
CMD_SEC PlayerInfo[playerid][pSecurity] == 1
}
new 
cmdPerm[MAX_PLAYERS]; 
Zeth's code is correct, however, you can't do such operations in your code because "<<=" related operations are for bit flag/ masking, which makes your code incorrect.
You might be interested to read more here: http://www.learncpp.com/cpp-tutorial...and-bit-masks/

Thanks.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)