Weapons Saving help
#2

Quote:
Originally Posted by Namer
Посмотреть сообщение
pawn Код:
for (new i = 0; i < 13; i++)
{
    GivePlayerWeapon(playerid, 9, 1); // Give them a desert eagle
    PlayerInfo[ playerid ][ Cookies ] -= 5;
    GetPlayerWeaponData(playerid, 0, PlayerInfo[ i ][ wslot ], PlayerInfo[ i ][ wslotammo ]);
}
What is that? Where did you get that from? i should be the player id, so why player id 0-13?
Also where is wslot declared? You should either create an array at the top of your script where you assign each weapon id the associated weapon slot or (if you don't intent to use it anywhere else) use the correct wslot for every case in the switch construct.

Or, if you want to save all weapon slots regardless of what weapon you give the player, just save them all after the switch statement:

pawn Код:
for (new slot = 0; slot < 13; slot++)
        GetPlayerWeaponData(playerid, slot, PlayerInfo[playerid][wslot[slot]], PlayerInfo[playerid][wslotammo[slot]]);
You could also just define this array at the top of your code:
pawn Код:
static const
    WeaponIDSlot[] = {0, 0, 1, 1, 1, 1 , 1, 1, 1, 1, 10, 10, 10, 10, 10, 10, 8, 8, 8, -1, -1, -1,
        2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 4, 6, 6, 7, 7, 7, 7, 8, 12, 9, 9, 9, 11, 11, 11};
Now by just doing WeaponIDSlot[weaponid] you get the corresponding weapon slot to that weapon id.
But then you can't easily access the PlayerInfo[playerid][wslot] construct anymore, so you should declare that just like:
pawn Код:
new PlayerWeapons[MAX_PLAYERS][12];
new PlayerAmmo[MAX_PLAYERS][12];
for example. And then you could use that like this:
pawn Код:
case 0:
{
    GivePlayerWeapon(playerid, WEAPON_DEAGLE, 50); // Give them a desert eagle
    PlayerInfo[playerid][Cookies] -= 5;
    GetPlayerWeaponData(playerid, WeaponIDSlot[WEAPON_DEAGLE], PlayerWeapons[playerid][WeaponIDSlot[WEAPON_DEAGLE]], PlayerAmmo[playerid][WeaponIDSlot[WEAPON_DEAGLE]]);
}
Depends on how you prefer to do it.

I hope this helps you.
Reply


Messages In This Thread
Weapons Saving help - by JeaSon - 13.05.2014, 11:06
Re: Weapons Saving help - by Madd92 - 13.05.2014, 12:48

Forum Jump:


Users browsing this thread: 1 Guest(s)