Author Topic: [Packaged] Ammo Control Plugin  (Read 3328 times)

Frenzzy

  • Full Member
  • ***
  • Posts: 218
    • ICQ Messenger - 337905984
    • MSN Messenger - frenzzy@live.ru
    • View Profile
    • http://css.vsevnet.ru/
[Packaged] Ammo Control Plugin
« on: December 16, 2010, 02:32:39 PM »
War3Source Addon - Ammo Control

Read the natives description for more information about this addon...
Supported only CSS game mod.

Servers running this addon: http://www.game-monitor.com/AmmoControl

Convars:

Plugin version. Don't change this.

war3_ammocontrol_version "1.2"

Enable / Disable Ammo Control.

war3_ammocontrol_enable "1"


Natives:

/**
 * Give ammo and/or clip for player's weapon.
 *
 * @param client: Client Index. Must be valid.
 * @param weapon: Weapon Index. Must be valid.
 * @param ammo: Amount of Ammo. Optional value. Use -1 to leave as it is.
 * @param clip: Amount of Clip. Optional value. Use -1 to leave as it is.
 * @noreturn
 */


native War3_GiveWeaponAmmo(client, weapon, ammo = -1, clip = -1);

/**
 * Set Ammo Control for player.
 * Auto control for the specified amount of ammo and the ammo in the clip after a buy (rebuy and autobuy) or reload.
 * Does not set an ammo and a clip, when GivePlayerItem used. Changes an ammo and/or a clip with a War3_GiveWeaponAmmo after a GivePlayerItem.
 * Also it does not give ammo, when player picks-up and gets the specified weapon from another player.
 *
 * @param client: Client Index. Use only this parameter to reset the ammo and the clip to deafult.
 * @param weapon: Weapon Name. Optional value. You can use these values instead of weapon names: weapon_primary, weapon_secondary, weapon_grenade or weapon_all.
 * @param ammo: Amount of Ammo. Optional value. Use -1 to leave as it is.
 * @param clip: Amount of Clip. Optional value. Use -1 to leave as it is.
 * @param update: Immediately Update. Optional value. Immediately ammo and/or clip update, if player is alive and has specified weapon(s).
 * @noreturn
 */


native War3_SetAmmoControl(client, String:weapon[], ammo = -1, clip = -1, bool:update = false);


Changelist:

  • 1.0 - Initial release.
  • 1.1 - Added a small check for clean log (without errors).
  • 1.2 - Buy ammo allowed only in buy zone.


P.S.: If you know how to make this addon is easier, please let me know.
« Last Edit: April 22, 2011, 04:00:30 AM by Frenzzy »
O_o

Frenzzy

  • Full Member
  • ***
  • Posts: 218
    • ICQ Messenger - 337905984
    • MSN Messenger - frenzzy@live.ru
    • View Profile
    • http://css.vsevnet.ru/
Re: Ammo Control Plugin
« Reply #1 on: December 16, 2010, 02:33:07 PM »
A simple example of using this addon (conditional code):

Quote

// ... some code ...

#include "W3SIncs/AmmoControl" // Added

// ... some code ...

public OnRaceSelected(client, newrace)
{
    if (newrace == thisRaceID)
    {
        War3_SetAmmoControl(client, "weapon_awp", _, 5); // Set Ammo Control (set amount of ammo in the clip to 5)
        // or War3_SetAmmoControl(client, "weapon_awp", -1, 5, false);
    }
    else
    {
        War3_SetAmmoControl(client, ""); // Disable Ammo Control (set amount of ammo in the clip to deafult for awp - 10)
        // or War3_SetAmmoControl(client, "", -1, -1, false);
    }
}

public OnUltimateCommand(client, race, bool:pressed)
{
    // ... some code, checks, ect ...

    new iWeapon = GivePlayerItem(client, "weapon_awp");
    if ((iWeapon != -1) && IsValidEntity(iWeapon))
    {
        War3_GiveWeaponAmmo(client, iWeapon, _, 5); // Set amount of ammo in the clip to 5
        // or War3_GiveWeaponAmmo(client, iWeapon, -1, 5);
    }
}

// ... some code ...



Or you can use this little plugin to test a Ammo Control: War3Source Addon - Ammo Control Commands.
This plugin has only two admin commands that use main "Ammo Control" addon:

war3_giveammo <#userid|name> <ammo> [clip]
war3_weaponammo <#userid|name> [weapon] [ammo] [clip]



P.S.: Sorry for double posting ;D
« Last Edit: December 16, 2010, 03:16:02 PM by Frenzzy »
O_o

Schmarotzer

  • Full Member
  • ***
  • Posts: 189
  • Ich schmarotze dich!
    • ICQ Messenger - 258631507
    • View Profile
    • Russian Fan-Site for german folk-rock-metal band Schandmaul
Re: [Packaged] Ammo Control Plugin
« Reply #2 on: April 14, 2012, 01:18:14 PM »
I think that shotguns doesn't supported
Welcome to my server