[Problem]Weapon save
#1

Heey guys,

I am using a weapon systeem with variables like: weapon1,ammo1,weapon2,ammo2.

Now I want that when you are out of guns you are REALY out of guns so you need to buy more guns.

Now I have made this:
if(GetPlayerWeapon(playerid) == 25)
{
PlayerInfo[playerid][pAmmo3] = GetPlayerAmmo(playerid);
return 1;
}
I know sure that I have weapon ID 25.

When I shoot 2 times with the shotgun and I disconnect (so the player is getting saved) and I look at the scriptfiles it is still the same ammo wich I bought.

Can anyone please help me how to fix this?
Reply
#2

If I understand you correctly, this is what you're looking for.

pawn Код:
new WeaponsData[MAX_PLAYERS][13],
    SavedAmmo[MAX_PLAYERS][13];
When player disconnects...
pawn Код:
for(new i; i < 13; i++)
{
    GetPlayerWeaponData(playerid, i, WeaponsData[playerid][i], SavedAmmo[playerid][i]);
}
Save WeaponsData, SavedAmmo to file...

On player connect/login, load them from the file...
pawn Код:
for(new i = 12; i > 1; i--)
{
    GivePlayerWeapon(playerid, WeaponsData[playerid][i],  SavedAmmo[playerid][i]);
}
Reply
#3

Oke but I have 5 weapon slots saving
Weapon 1-5
Ammo 1-5
And how do I put that then into those variabel?
Reply
#4

pawn Код:
new WeaponsData[MAX_PLAYERS][5],
    SavedAmmo[MAX_PLAYERS][5];
pawn Код:
for(new i; i < 5; i++)
{
    GetPlayerWeaponData(playerid, i, WeaponsData[playerid][i], SavedAmmo[playerid][i]);
}
pawn Код:
for(new i = 4; i > 1; i--)
{
    GivePlayerWeapon(playerid, WeaponsData[playerid][i],  SavedAmmo[playerid][i]);
}
Reply
#5

Aah now I get it, I am gonna try if this is what I want in the GM

Thanks mate
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)