Hey everyone
This is a plugin to spawn ammoboxes with many config options.
I made this plugin by request.
Features
- Unlimitted ammoboxes per map
- No HUD or press F
- activate/deactivate iPrintLnBold message
- solid/unsolid
- you can change the model
- you can use it for any gametype
- rotation
- add this plugin as a reference to your shop plugin to use GetPoints() method (AmmoBox.AmmoBox.GetPoints(ServerClient))
How to use
1.) download file
2.) put AmmoBox Plugin.dll into your plugins folder
3.) start your server once
4.) edit sv_config
5.) start your server again
6.) Enjoy!
Example of sv_config
Video
Credits
@8q4s8 - creator
@master131 - addon extensions
This is a plugin to spawn ammoboxes with many config options.
I made this plugin by request.
Features
- Unlimitted ammoboxes per map
- No HUD or press F
- activate/deactivate iPrintLnBold message
- solid/unsolid
- you can change the model
- you can use it for any gametype
- rotation
- add this plugin as a reference to your shop plugin to use GetPoints() method (AmmoBox.AmmoBox.GetPoints(ServerClient))
How to use
1.) download file
2.) put AmmoBox Plugin.dll into your plugins folder
3.) start your server once
4.) edit sv_config
5.) start your server again
6.) Enjoy!
Example of sv_config
Code:
[AmmoBox]
//disable box for team axis (infected=true)
infected=false
//ammobox model
model=com_plasticcase_friendly
radius=100
//ammobox stops at this value
MaxAmmo=180
//time in milliseconds (1 second = 1000)
timerinterval=500
increaseAmmo=10
//enable/disable iPrintLnBold message (+ 10 etc.)
iPrintLnBoldMSG=true
solid=true
//points for each increase if you use shop (you have to add decrease stuff yourself)
points=0
boxes=4
//box123=mapname,X,Y,Z,Rotation
box1=mp_village,1004,-1165,284,90
box2=mp_village,300,200,300,340
box3=mp_underground,0,0,0,0
box4=mp_underground,100,100,100,0Code:
using System;
using System.Collections.Generic;
using Addon;
using System.Text;
using System.Timers;
namespace AmmoBox
{
public class Location
{
public float x;
public float y;
public float z;
public float rotation;
public Location(float _x,float _y,float _z,float _rotation)
{
x = _x;
y = _y;
z = _z;
rotation = _rotation;
}
}
public class AmmoBox:CPlugin
{
int MaxAmmo;
int Radius;
int IncreaseAmmo;
int points;
string ModelName;
string Map;
float Timerinterval;
bool Infected;
bool IPrintLnBoldMSG;
bool Solid;
Timer timer = new Timer();
Dictionary<string, Location> AmmoBoxes = new Dictionary<string, Location>();
public static Dictionary<string, int> Points = new Dictionary<string, int>();
public override void OnServerLoad()
{
Config();
ServerPrint("AmmoBox Plugin by 8Q4S8 loaded!");
timer.Elapsed += new ElapsedEventHandler(handler);
timer.Interval = Timerinterval;
timer.Enabled = true;
}
public static int GetPoints(ServerClient Client)
{
return Points[Client.XUID];
}
public void handler(object s, ElapsedEventArgs e)
{
foreach (ServerClient c in GetClients())
{
foreach (string key in AmmoBoxes.Keys)
{
if (key.Contains(Map))
{
if (c.Team == Teams.Axis != Infected || c.Team == Teams.Allies)
{
if (Difference(c.OriginX, AmmoBoxes[key].x) <= Radius && Difference(c.OriginY, AmmoBoxes[key].y) <= Radius && Difference(c.OriginZ, AmmoBoxes[key].z) <= Radius)
{
if (c.Ammo.PrimaryAmmoClip < MaxAmmo || c.Ammo.SecondaryAmmoClip < MaxAmmo)
{
if (c.Ammo.PrimaryAmmoClip < MaxAmmo)
{
c.Ammo.PrimaryAmmoClip += IncreaseAmmo;
if (c.Ammo.PrimaryAmmoClip > MaxAmmo)
c.Ammo.PrimaryAmmoClip = MaxAmmo;
}
if (c.Ammo.SecondaryAmmoClip < MaxAmmo)
{
c.Ammo.SecondaryAmmoClip += IncreaseAmmo;
if (c.Ammo.SecondaryAmmoClip > MaxAmmo)
c.Ammo.SecondaryAmmoClip = MaxAmmo;
}
PlaySoundOnPlayer(c, "scavenger_pack_pickup");
if(IPrintLnBoldMSG)
iPrintLnBold("^2+ "+IncreaseAmmo.ToString(),c);
Points[c.XUID] += points;
}
}
}
}
}
}
}
private static float Difference(float loc1, float loc2)
{
return Math.Abs(loc1 - loc2);
}
public override void OnMapChange()
{
Map = GetDvar("mapname");
foreach(string key in AmmoBoxes.Keys)
{
if (key.Contains(Map))
{
Entity ent1 = SpawnModel("script_model", ModelName, new Vector(AmmoBoxes[key].x, AmmoBoxes[key].y, AmmoBoxes[key].z));
Extensions.SetAngles(ent1,new Vector(0, AmmoBoxes[key].rotation , 0));
if (Solid)
Extensions.CloneBrushModelToScriptModel(ent1, Extensions.FindAirdropCrateCollisionId());
}
}
}
public void Config()
{
if (GetServerCFG("AmmoBox", "infected", "") == "")
SetServerCFG("AmmoBox", "infected", "true");
if (GetServerCFG("AmmoBox", "MaxAmmo", "") == "")
SetServerCFG("AmmoBox", "MaxAmmo", "180");
if (GetServerCFG("AmmoBox", "model", "") == "")
SetServerCFG("AmmoBox", "model", "com_plasticcase_friendly");
if (GetServerCFG("AmmoBox", "radius", "") == "")
SetServerCFG("AmmoBox", "radius", "100");
if (GetServerCFG("AmmoBox", "timerinterval", "") == "")
SetServerCFG("AmmoBox", "timerinterval", "500");
if (GetServerCFG("AmmoBox", "increaseAmmo", "") == "")
SetServerCFG("AmmoBox", "increaseAmmo", "10");
if (GetServerCFG("AmmoBox", "iPrintLnBoldMSG", "") == "")
SetServerCFG("AmmoBox", "iPrintLnBoldMSG", "true");
if (GetServerCFG("AmmoBox", "solid", "") == "")
SetServerCFG("AmmoBox", "solid", "false");
if (GetServerCFG("AmmoBox", "points", "") == "")
SetServerCFG("AmmoBox", "points", "0");
if (GetServerCFG("AmmoBox", "boxes", "") == "")
SetServerCFG("AmmoBox", "boxes", "0");
try
{
MaxAmmo = int.Parse(GetServerCFG("AmmoBox", "MaxAmmo", ""));
ModelName = GetServerCFG("AmmoBox", "model", "");
Radius = int.Parse(GetServerCFG("AmmoBox", "radius", ""));
Infected = bool.Parse(GetServerCFG("AmmoBox", "infected", ""));
Timerinterval = float.Parse(GetServerCFG("AmmoBox", "timerinterval", ""));
IncreaseAmmo = int.Parse(GetServerCFG("AmmoBox", "increaseAmmo", ""));
Solid = bool.Parse(GetServerCFG("AmmoBox", "solid", ""));
points = int.Parse(GetServerCFG("AmmoBox", "points", ""));
string boxes = GetServerCFG("AmmoBox", "boxes", "");
if (boxes != "0")
{
for (int i = 1; i <= int.Parse(boxes); i++)
{
string boxLocation = GetServerCFG("AmmoBox", string.Format("box{0}", i), "");
if (boxLocation != null)
{
string mp = boxLocation.Split(',')[0];
string originX = boxLocation.Split(',')[1];
string originY = boxLocation.Split(',')[2];
string originZ = boxLocation.Split(',')[3];
string rotation = boxLocation.Split(',')[4];
AmmoBoxes.Add(i.ToString() + mp,new Location(float.Parse(originX), float.Parse(originY), float.Parse(originZ), float.Parse(rotation)));
}
}
}
}
catch (Exception ex) { ServerPrint("Loading AmmoBoxes failed: " + ex.Message); }
}
public override void OnPlayerConnect(ServerClient Client)
{
if(!Points.ContainsKey(Client.XUID))
Points.Add(Client.XUID, 0);
}
public override void OnPlayerDisconnect(ServerClient Client)
{
Points.Remove(Client.XUID);
}
}
}Video
Credits
@8q4s8 - creator
@master131 - addon extensions


