Making weapons loading short
#1

Is there a way of shorting the function of loading the players weapon data instead of doing this:
pawn Код:
enum pInfo
{
    pWeapon,
    pAmmo,
    pWeapon2,
    pAmmo2,
    pWeapon3,
    pAmmo3,
    pWeapon4,
    pAmmo4,
    pWeapon5,
    pAmmo5,
    pWeapon6,
    pAmmo6,
    pWeapon7,
    pAmmo7,
    pWeapon8,
    pAmmo8,
    pWeapon9,
    pAmmo9,
    pWeapon10,
    pAmmo10,
    pWeapon11,
    pAmmo11,
    pWeapon12,
    pAmmo12,
    pWeapon13,
    pAmmo13,
    pWeapon14,
    pAmmo14,
};
Reply
#2

pawn Код:
new playerWeapons[MAX_PLAYERS][13];
new playerAmmo[MAX_PLAYERS][13];
There's only 13 weapon slots.
Reply
#3

I want to load them...like making a loop which loads all of them.
Reply
#4

You can make those 2 arrays with 13 slots, and when you want to give the weapons you do
pawn Код:
GivePlayerWeapon(playerid, Weapon[playerid][0], Ammo[playerid][0]);
GivePlayerWeapon(playerid, Weapon[playerid][1], Ammo[playerid][1]);
And when you want to store them you do.
pawn Код:
GetPlayerWeaponData(playerid, 0, Weapon[playerid][0], Ammo[playerid][0]);
GetPlayerWeaponData(playerid, 1, Weapon[playerid][1], Ammo[playerid][1]);
And so on.
Reply
#5

Quote:
Originally Posted by ||123||
Посмотреть сообщение
I want to load them...like making a loop which loads all of them.
Be a bit more clear next time then. With my arrays:

pawn Код:
new weapons[MAX_PLAYERS][13][2]; // 0 - Weapon ID | 1 - Ammo Count

stock getPlayerWeaponsToArray(playerid) {
    for (new i = 0; i < 13; i++)
    {
        GetPlayerWeaponData(playerid, i, weapons[playerid][i][0], weapons[playerid][i][1]);
    }
   
    return 1;
}
Untested.
Reply
#6

I meant that I want to load the weapons when the player connects (his old stats weapons). I only need to know how do they give weapons to the player in a short loop.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)