SA-MP Forums Archive
How to add more ammo.. - 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)
+--- Thread: How to add more ammo.. (/showthread.php?tid=372554)



How to add more ammo.. - Black Axe - 27.08.2012

Well - I Was wondering - How to add more ammo ? Because I Was making a Clips system - So that.. Once you use a Clip - A Certain amount of Ammo get increased to the weapon , Like - if you have 10 bullets and you used a clip - you 'll get 20 bullet.. so - how to do it ? Xd


Re: How to add more ammo.. - Kh4led - 27.08.2012

Show us some codes?


Re: How to add more ammo.. - GTAprogamer111 - 27.08.2012

Well if you want to add to AK, then put this code to somewhere:
SetPlayerAmmo(playerid,30,500);
It will set 500 ammo.


Re: How to add more ammo.. - Black Axe - 27.08.2012

Mhm - You don't get me -How to UPDATE the ammo ? Like - to increase it..


Re: How to add more ammo.. - Kh4led - 27.08.2012

I guess it's a Mafia Wars server, so add it OnPlayerSpawn
For example
pawn Код:
public OnPlayerSpawn
{
 if(gTeam[playerid] == TEAM_POLICE)
    {
     GivePlayerWeapon(playerid,30)
     SetPlayerAmmo(playerid,30,500);
     }
     return 1;
}



Re: How to add more ammo.. - Unte99 - 27.08.2012

It could get a little buggy when players would lag. Just use OnPlayerKeyStateChange function. That's all you need.


Re: How to add more ammo.. - Black Axe - 27.08.2012

Guys.. It's not that hard to understand lol

- Let's say - now you have a gun and you are fighting with ? K ? and you have a CLIP to INCREASE "INCREASE" your Ammo - So once you use the - the BULLETS [Ammo] IN the WEAPON SHOULD INCREASE - so if you have 10 - it will be 20 - BUT if you have 20 - It will be 30 , Do you get it now ? lol


Re: How to add more ammo.. - ddnbb - 27.08.2012

Quote:
Originally Posted by Black Axe
Посмотреть сообщение
Guys.. It's not that hard to understand lol

- Let's say - now you have a gun and you are fighting with ? K ? and you have a CLIP to INCREASE "INCREASE" your Ammo - So once you use the - the BULLETS [Ammo] IN the WEAPON SHOULD INCREASE - so if you have 10 - it will be 20 - BUT if you have 20 - It will be 30 , Do you get it now ? lol
What's up with these weird people here on forums, lol...

Anyway here, i'll show you how it works:
pawn Код:
new ammo = GetPlayerAmmo(playerid); // Save your ammo amount into a variable.
new weapon = GetPlayerWeapon(playerid); // Same with the weapon ID.
ResetPlayerWeapons(playerid); // Remove player weapons. (you might want to ****** for 'RemovePlayerWeapon' function to remove only specific weapon.
GivePlayerWeapon(playerid, weaponid, ammo+10); // Gives the player it's weapon back with old + new (10) ammo.
I hope this helps you in some way.

EDIT: Or, actually by giving the player the same weapon that he already has, will increase the ammo.