Array in y_ini
#1

Hey, I'm creating some weapon saving.

Standard way is to declare:
pawn Код:
pWep0,
pWep1,
pWep2,
pWep3,
pWep4,
pWep5,
pWep6,
pWep7,
pWep8,
pWep9,
pWep10,
pWep11,
pWep12
So i tried with
pawn Код:
new Weapons[11];
but can't make it working while using:

pawn Код:
INI_Int("Weapon0", pInfo[playerid][Weapons[0]]);
Error:
Код:
C:\Users\Anis\Desktop\MoneyGrub\MoneyGrub\gamemodes\moneygrub.pwn(50) : error 028: invalid subscript (not an array or too many subscripts): "Weapons"
C:\Users\Anis\Desktop\MoneyGrub\MoneyGrub\gamemodes\moneygrub.pwn(50) : warning 215: expression has no effect
C:\Users\Anis\Desktop\MoneyGrub\MoneyGrub\gamemodes\moneygrub.pwn(50) : error 001: expected token: ";", but found "]"
C:\Users\Anis\Desktop\MoneyGrub\MoneyGrub\gamemodes\moneygrub.pwn(50) : error 029: invalid expression, assumed zero
C:\Users\Anis\Desktop\MoneyGrub\MoneyGrub\gamemodes\moneygrub.pwn(50) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply
#2

Код:
pInfo[playerid][Weapons][0]
Reply
#3

Thanks. So is there any way to:
pawn Код:
INI_Int("Weapon0", pInfo[playerid][Weapons][0]);
    INI_Int("Weapon1", pInfo[playerid][Weapons][1]);
    INI_Int("Weapon2", pInfo[playerid][Weapons][2]);
    INI_Int("Weapon3", pInfo[playerid][Weapons][3]);
    INI_Int("Weapon4", pInfo[playerid][Weapons][4]);
    INI_Int("Weapon5", pInfo[playerid][Weapons][5]);
    INI_Int("Weapon6", pInfo[playerid][Weapons][6]);
    INI_Int("Weapon7", pInfo[playerid][Weapons][7]);
    INI_Int("Weapon9", pInfo[playerid][Weapons][8]);
    INI_Int("Weapon10", pInfo[playerid][Weapons][9]);
    INI_Int("Weapon11", pInfo[playerid][Weapons][10]);
    INI_Int("Weapon12", pInfo[playerid][Weapons][11]);
    INI_Int("Weapon13", pInfo[playerid][Weapons][12]);
Is there any way to create array for those Weapon1, Weapon2...

Like:

pawn Код:
INI_Int("Weapon[1]", pInfo[playerid][Weapons][1]);
Reply
#4

I'm not sure what you're asking. They're already in an array.
Reply
#5

pawn Код:
INI_Int("Weapon1"..
INI_Int("Weapon2"..
INI_Int("Weapon3"..
INI_Int("Weapon4"..
INI_Int("Weapon5"..
INI_Int("Weapon6"..
Can I put those in array?
Reply
#6

It's good to know that. Thanks.
Reply
#7

pawn Код:
new str[12];
    for(new d=0; d != 13; d++)
    {
        if(d != 8)
            format(str,sizeof(str),"Weapon[%d]",d);
        else
            format(str,sizeof(str),"Weapon[%d]",d+1);

        INI_Int(str, pInfo[playerid][Weapons][d]);
    }
like that ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)