Log in

View Full Version : CoD2 How to give a certain ammount of Ammo to player



BrandonDR
13th January 2026, 20:29
Hello, is there a way to give a specific, or certain amount of ammo to the player via GSC? something similar when picking up from dead AI, neither level.player givestartammo(); or level.player givamaxammo(); suit for this task,

How can I script the following:

level.player does something...

level.player giveammo(10); // give just 10 bullets to the total ammo that the player is carrying.

e3ks55
19th January 2026, 05:51
Hey
i think the methods you are looking for are documented here:
https://www.ibuddie.at/libcod/stock/player/setweaponclipammo.htm
https://www.ibuddie.at/libcod/stock/player/setweaponslotammo.htm

BrandonDR
20th January 2026, 06:45
Thanks for the reply but I am afrai I have tried those before and they do not work as I would like since those functions, forces clip & weapon to have that ammount of ammo, they do not add the cartdriges to the ammo pool, I think Ill stick to level.player givestartammo(); for now.

IzNoGoD
20th January 2026, 07:24
then just getweaponslotammo and getweaponslotclipammo, add some to it, then setweaponslotammo and setweaponslotclipammo that new, increased number

BrandonDR
20th January 2026, 19:18
// S O L V E D //

Thank you so much, I solved it the way you said and it was certainly very easy, thanks for making this community better and helping begginer modders like me to continue learning.

// solution:
playerWeapon[0] = level.player getweaponslotweapon("primary"); // registers current weapon in primary slot.
playerWeapon_Ammo[0] = level.player getweaponslotammo("primary"); // registers current ammo lot
playerWeapon_Ammo[0] +=10; // ammount of ammo to add
level.player setweaponslotammo("primary", playerWeapon_Ammo[0]); // must use "primary" word.

BrandonDR
20th January 2026, 19:18
// S O L V E D //

Thank you so much, I solved it the way you said and it was certainly very easy, thanks for making this community better and helping begginer modders like me to continue learning.

// solution:
playerWeapon[0] = level.player getweaponslotweapon("primary"); // registers current weapon in primary slot.
playerWeapon_Ammo[0] = level.player getweaponslotammo("primary"); // registers current ammo lot
playerWeapon_Ammo[0] +=10; // ammount of ammo to add
level.player setweaponslotammo("primary", playerWeapon_Ammo[0]); // must use "primary" word.