[Problem]Weapon save - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [Problem]Weapon save (
/showthread.php?tid=210305)
[Problem]Weapon save -
jorambo - 12.01.2011
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?
Re: [Problem]Weapon save -
iMonk3y - 12.01.2011
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]);
}
Re: [Problem]Weapon save -
jorambo - 12.01.2011
Oke but I have 5 weapon slots saving
Weapon 1-5
Ammo 1-5
And how do I put that then into those variabel?
Re: [Problem]Weapon save -
iMonk3y - 12.01.2011
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]);
}
Re: [Problem]Weapon save -
jorambo - 13.01.2011
Aah now I get it, I am gonna try if this is what I want in the GM
Thanks mate