SA-MP Forums Archive
error 028: invalid subscript (not an array or too many subscripts): "pInfo" - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: error 028: invalid subscript (not an array or too many subscripts): "pInfo" (/showthread.php?tid=538155)



error 028: invalid subscript (not an array or too many subscripts): "pInfo" - XGreen - 20.09.2014

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;




Re: error 028: invalid subscript (not an array or too many subscripts): "pInfo" - Ox1gEN - 20.09.2014

Show your enum.


Re: error 028: invalid subscript (not an array or too many subscripts): "pInfo" - XGreen - 20.09.2014

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




Re: error 028: invalid subscript (not an array or too many subscripts): "pInfo" - Ox1gEN - 20.09.2014

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];



Re: error 028: invalid subscript (not an array or too many subscripts): "pInfo" - XGreen - 20.09.2014

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


Re: error 028: invalid subscript (not an array or too many subscripts): "pInfo" - Ox1gEN - 20.09.2014

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.


Re: error 028: invalid subscript (not an array or too many subscripts): "pInfo" - XGreen - 20.09.2014

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


Re: error 028: invalid subscript (not an array or too many subscripts): "pInfo" - Ox1gEN - 20.09.2014

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