error 028: invalid subscript (not an array or too many subscripts): "pInfo"
#1

i got this problem when i add admin names:


heres the code:
PHP код:
stock AdminLevelName(playerid)
{
    new 
staffname[256];
    switch(
pInfo[playerid][pAdmin]) //line of proble, the pInfo thing
    
{
        case 
0staffname "Member";
        case 
1staffname "Helper";
        case 
2staffname "Moderator";
        case 
3staffname "Manager";
        case 
4staffname "Head Admin";
        case 
5staffname "Founder";
    }
    return 
staffname;

Reply
#2

Show your enum.
Reply
#3

PHP код:
enum pInfo
{
    
pPass,
    
pLog,
    
pCash,
    
pBleed,
    
pSleep,
    
pEXP,
    
pNEXP,
    
pLv,
    
pAdmin,
    
pKills,
    
pDeaths,
    
pSpawn,
    
pSkin,
    
pSlot,
    
pSlotu,
    
pBanned,
    
pHunger,
    
pThirst,
    
pMale,
    
pHas,
    
pNoR,
    
pWeapon[13],
    
pWeapona[13],
    
pAmmoColt,
    
pAmmoShotgun,
    
pAmmoSMS,
    
pAmmoAus,
    
pAmmoRifle,
Float:hp,
Float:sposx,
Float:sposy,
Float:sposz

Reply
#4

Quote:
Originally Posted by XGreen
Посмотреть сообщение
PHP код:
enum pInfo
{
    
pPass,
    
pLog,
    
pCash,
    
pBleed,
    
pSleep,
    
pEXP,
    
pNEXP,
    
pLv,
    
pAdmin,
    
pKills,
    
pDeaths,
    
pSpawn,
    
pSkin,
    
pSlot,
    
pSlotu,
    
pBanned,
    
pHunger,
    
pThirst,
    
pMale,
    
pHas,
    
pNoR,
    
pWeapon[13],
    
pWeapona[13],
    
pAmmoColt,
    
pAmmoShotgun,
    
pAmmoSMS,
    
pAmmoAus,
    
pAmmoRifle,
Float:hp,
Float:sposx,
Float:sposy,
Float:sposz

Correct Way:


pawn Код:
enum PlayerStats
{
    pPass,
    pLog,
    pCash,
    pBleed,
    pSleep,
    pEXP,
    pNEXP,
    pLv,
    pAdmin,
    pKills,
    pDeaths,
    pSpawn,
    pSkin,
    pSlot,
    pSlotu,
    pBanned,
    pHunger,
    pThirst,
    pMale,
    pHas,
    pNoR,
    pWeapon[13],
    pWeapona[13],
    pAmmoColt,
    pAmmoShotgun,
    pAmmoSMS,
    pAmmoAus,
    pAmmoRifle,
Float:hp,
Float:sposx,
Float:sposy,
Float:sposz
}

new pInfo[MAX_PLAYERS][PlayerStats];
Reply
#5

If I Rename That, I Got bunch Of Things To Rename.

I Just Do:
switch(PlayerInfo[playerid][pAdmin])
and it works.

BTW, thanks for reply, +1
Reply
#6

Quote:
Originally Posted by XGreen
Посмотреть сообщение
If I Rename That, I Got bunch Of Things To Rename.

I Just Do:
switch(PlayerInfo[playerid][pAdmin])

BTW, thanks for reply, +1
You didn't do the enum correctly, like you did, the only thing you need to do is:

1) Change the name of the enum to anything
2) Do this:

new pInfo[MAX_PLAYERS][-YOUR-ENUM-NAME-];

You shouldn't have any errors, because this is the correct way of doing it, what you showed me before, you were using the enum's name, instead you need to create for it, look at what I did, maybe you'll understand it, but the code I gave you is the correct way to use an enum.

BTW: You are supposed to put the new variable for the enum under the enum.
Note: This is only the var you are creating to use the enum, if you have used everything with pInf[etc][etc]
Then you should have ZERO errors.
Reply
#7

Quote:
Originally Posted by Ox1gEN
Посмотреть сообщение
You didn't do the enum correctly, like you did, the only thing you need to do is:

1) Change the name of the enum to anything
2) Do this:

new pInfo[MAX_PLAYERS][-YOUR-ENUM-NAME-];

You shouldn't have any errors, because this is the correct way of doing it, what you showed me before, you were using the enum's name, instead you need to create for it, look at what I did, maybe you'll understand it, but the code I gave you is the correct way to use an enum.

BTW: You are supposed to put the new variable for the enum under the enum.
Note: This is only the var you are creating to use the enum, if you have used everything with pInf[etc][etc]
Then you should have ZERO errors.
that is just edit, i thought, it was like from my other scripts. so now i use PlayerInfo
Reply
#8

Quote:
Originally Posted by XGreen
Посмотреть сообщение
that is just edit, i thought, it was like from my other scripts. so now i use PlayerInfo
Didn't quite understand what you are saying here (lol - my bad) but I assume you have solved your problem.
If so - I'm glad
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)