SA-MP Forums Archive
Save ammo and then set it - 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: Save ammo and then set it (/showthread.php?tid=77384)



Save ammo and then set it - SpiderPork - 10.05.2009

Hello!

I need some help. How do I save the ammo when they change the weapon and then set it back when they change back to the previous weapon? And save the ammo of ALL the weapons then set it back when they change the weapon.
Example: I have an AK47, I change to MP5 and it saves my AK47 ammo. When I change back to AK47, it sets my ammo to the previous. And I mean the rounds REMAINING to shoot out, not the whole equipment.
I tried some stuff with OnPlayerUpdate - failed.


Re: Save ammo and then set it - BlackFoX - 10.05.2009

new weapons[13],ammo[13];

for(new i = 0;i<13;i++){
GetPlayerWeaponData(playerid,i,weapons[i],ammo[i]);}

You must Get first Weapon Data, then you can Use Variables to Save, easy




Re: Save ammo and then set it - SpiderPork - 11.05.2009

But I think when I'll set the player's ammo back, it will set the amount of the whole "equipment", not just the remaining rounds.


Re: Save ammo and then set it - matrix_smq - 11.05.2009

Quote:
Originally Posted by SpiderPork
But I think when I'll set the player's ammo back, it will set the amount of the whole "equipment", not just the remaining rounds.
Код:
new weapons[13],ammo[13];
for(new i = 0;i<13;i++){
GetPlayerWeaponData(playerid,i,weapons[i],ammo[i]);}
Not really, check the slots of the weapon and then the weapon is < weapons[SLOT] >
Check the weapon slots at the weapon list on the wiki.


Re: Save ammo and then set it - SpiderPork - 11.05.2009

I don't understand this at all. I never ever worked with GetPlayerWeaponData.
Could anyone make just an example of how to save and set it back?


Re: Save ammo and then set it - Derksen123 - 05.06.2009

how to make a loadweapondata when player joins the server


Re: Save ammo and then set it - lol2112 - 05.06.2009

Quote:
Originally Posted by Derksen123
how to make a loadweapondata when player joins the server
Well provided you're already using a save script and you have the weapon values saved, you'll want to use SetPlayerAmmo and GivePlayerWeapon.


Re: Save ammo and then set it - Badger(new) - 05.06.2009

pawn Код:
new bullets[MAX_PLAYERS][12];
new weapons[MAX_PLAYERS][12];
GetPlayerWeaponData(playerid,1,weapons[playerid][0],bullets[playerid][0]);
GetPlayerWeaponData(playerid,2,weapons[playerid][1],bullets[playerid][1]);
GetPlayerWeaponData(playerid,3,weapons[playerid][2],bullets[playerid][2]);
GetPlayerWeaponData(playerid,4,weapons[playerid][3],bullets[playerid][3]);
GetPlayerWeaponData(playerid,5,weapons[playerid][4],bullets[playerid][4]);
GetPlayerWeaponData(playerid,6,weapons[playerid][5],bullets[playerid][5]);
GetPlayerWeaponData(playerid,7,weapons[playerid][6],bullets[playerid][6]);
GetPlayerWeaponData(playerid,8,weapons[playerid][7],bullets[playerid][7]);
GetPlayerWeaponData(playerid,9,weapons[playerid][8],bullets[playerid][8]);
GetPlayerWeaponData(playerid,10,weapons[playerid][9],bullets[playerid][9]);
GetPlayerWeaponData(playerid,11,weapons[playerid][10],bullets[playerid][10]);
GetPlayerWeaponData(playerid,12,weapons[playerid][11],bullets[playerid][11]);

//Gets the player's weapons for each slot and the ammo of it.
//You would need to also define the playerid for the weapons+bullets if you wanted to give the player these weapons at a later time
then to give the saved weapons:
pawn Код:
if(weapons[playerid][0]!=0)GivePlayerWeapon(playerid,weapons[playerid][0],bullets[playerid][0]);
if(weapons[playerid][1]!=0)GivePlayerWeapon(playerid,weapons[playerid][1],bullets[playerid][1]);
if(weapons[playerid][2]!=0)GivePlayerWeapon(playerid,weapons[playerid][2],bullets[playerid][2]);
if(weapons[playerid][3]!=0)GivePlayerWeapon(playerid,weapons[playerid][3],bullets[playerid][3]);
if(weapons[playerid][4]!=0)GivePlayerWeapon(playerid,weapons[playerid][4],bullets[playerid][4]);
if(weapons[playerid][5]!=0)GivePlayerWeapon(playerid,weapons[playerid][5],bullets[playerid][5]);
if(weapons[playerid][6]!=0)GivePlayerWeapon(playerid,weapons[playerid][6],bullets[playerid][6]);
if(weapons[playerid][7]!=0)GivePlayerWeapon(playerid,weapons[playerid][7],bullets[playerid][7]);
if(weapons[playerid][8]!=0)GivePlayerWeapon(playerid,weapons[playerid][8],bullets[playerid][8]);
if(weapons[playerid][9]!=0)GivePlayerWeapon(playerid,weapons[playerid][9],bullets[playerid][9]);
if(weapons[playerid][10]!=0)GivePlayerWeapon(playerid,weapons[playerid][10],bullets[playerid][10]);
if(weapons[playerid][11]!=0)GivePlayerWeapon(playerid,weapons[playerid][11],bullets[playerid][11]);



Re: Save ammo and then set it - Gappy - 14.06.2009

http://forum.sa-mp.com/index.php?topic=76543.0
http://forum.sa-mp.com/index.php?topic=104807.0

After 2 seconds of searching -.-


Re: Save ammo and then set it - SpiderPork - 14.06.2009

You don't understand me. Anyways:

1.) Why bump an old topic.
2.) I already found out that there is no function to set the ammount of ammo in the MAGAZINE.
3.) I don't want it to save on player's disconnect, I want it to save when a player changes the weapon and set it back when they change back.
4.) Lock this topic.