SA-MP Forums Archive
Array in y_ini - 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: Array in y_ini (/showthread.php?tid=456411)



Array in y_ini - RedJohn - 05.08.2013

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.



Re: Array in y_ini - Ada32 - 05.08.2013

Код:
pInfo[playerid][Weapons][0]



Re: Array in y_ini - RedJohn - 05.08.2013

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



Re: Array in y_ini - Ada32 - 05.08.2013

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


Re: Array in y_ini - RedJohn - 05.08.2013

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?


Re: Array in y_ini - RedJohn - 05.08.2013

It's good to know that. Thanks.


Re: Array in y_ini - Jefff - 05.08.2013

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 ?