Skip to content
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Donate
Collapse

Plutonium

  1. Home
  2. BO2 Modding Releases & Resources
  3. Wall buy fills weapon clip to max

Wall buy fills weapon clip to max

Scheduled Pinned Locked Moved BO2 Modding Releases & Resources
2 Posts 2 Posters 188 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Vl.Sunnyundefined Offline
    Vl.Sunnyundefined Offline
    Vl.Sunny
    wrote last edited by
    #1

    Couldn't find any working scripts so I made a server script that fills the clip to max when buying ammo from a wall buy.

    Script should be copy and pasted into your plutonium server folder at
    c:\storage\t6\scripts\zm

    Also I'm new to all of this stuff so let me know if there are any bugs or things that can be fixed, thanks!

    #include common_scripts\utility;
    #include maps\mp\_utility;
    #include maps\mp\zombies\_zm_utility;
    #include maps\mp\zombies\_zm_weapons;
    main()
    {
    	replaceFunc(maps\mp\zombies\_zm_weapons::ammo_give,::new_ammo_give);
    }
    new_ammo_give( weapon ) //checked changed to match cerberus output
    {
        give_ammo = 0;
        fill_clip = 0; // Add a flag to control clip filling
        if ( !is_offhand_weapon( weapon ) )
        {
            weapon = get_weapon_with_attachments( weapon );
            if ( isDefined( weapon ) )
            {
                stockmax = 0;
                stockmax = weaponstartammo( weapon );
                clipmax = weaponclipsize( weapon ); // Get the maximum clip size
                clipcount = self getweaponammoclip( weapon );
                currstock = self getammocount( weapon );
                stockleft = currstock - clipcount;
                if ( stockleft < stockmax )
                {
                    give_ammo = 1;
                }
                // Always fill the clip when buying ammo for a primary weapon
                if ( clipcount < clipmax )
                {
                    fill_clip = 1;
                }
            }
        }
        else if ( self has_weapon_or_upgrade( weapon ) )
        {
            if ( self getammocount( weapon ) < weaponmaxammo( weapon ) )
            {
                give_ammo = 1;
                // For offhand weapons, we might not want to automatically "refill" in the same way
                // Consider if you want to add a specific clip mechanic for offhands.
            }
        }
        if ( give_ammo || fill_clip ) // Give ammo OR fill the clip
        {
            self play_sound_on_ent( "purchase" );
            if ( give_ammo )
            {
                self givemaxammo( weapon );
                alt_weap = weaponaltweaponname( weapon );
                if ( alt_weap != "none" )
                {
                    self givemaxammo( alt_weap );
                }
            }
            if ( fill_clip )
            {
                self setweaponammoclip( weapon, clipmax ); // Fill the clip to max
            }
            return 1;
        }
        return 0;
    }
    
    1 Reply Last reply
    0
    • briskoLEGOATundefined Offline
      briskoLEGOATundefined Offline
      briskoLEGOAT
      wrote last edited by
      #2

      hey bro can you make a box patch for all maps on bo1 and bo2 zombies ?

      1 Reply Last reply
      0

      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Donate