Results 1 to 6 of 6

Thread: CoD2 How to give a certain ammount of Ammo to player

  1. #1
    Private
    Join Date
    May 2024
    Posts
    13
    Thanks
    0
    Thanked 2 Times in 2 Posts

    CoD2 How to give a certain ammount of Ammo to player

    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.

  2. #2
    ... connecting
    Join Date
    Jan 2026
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

  3. #3
    Private
    Join Date
    May 2024
    Posts
    13
    Thanks
    0
    Thanked 2 Times in 2 Posts
    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.

  4. #4
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,731
    Thanks
    17
    Thanked 1,082 Times in 683 Posts
    then just getweaponslotammo and getweaponslotclipammo, add some to it, then setweaponslotammo and setweaponslotclipammo that new, increased number
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  5. #5
    Private
    Join Date
    May 2024
    Posts
    13
    Thanks
    0
    Thanked 2 Times in 2 Posts
    // 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.

  6. The Following User Says Thank You to BrandonDR For This Useful Post:

    e3ks55 (Today)

  7. #6
    Private
    Join Date
    May 2024
    Posts
    13
    Thanks
    0
    Thanked 2 Times in 2 Posts
    // 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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •