Release AmmoBox Plugin
#1
Rainbow 
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
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,0

Code:
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


Attached Files
.zip   AmmoBox Plugin.zip (Size: 7.25 KB / Downloads: 193)
Reply

#2
a question how i can rotate the box or i can't?
Reply

#3
(05-29-2013, 13:34)DJSKilly Wrote: a question how i can rotate the box or i can't?

plugin updated! you can now use rotation, look at the sv_config example.
Reply

#4
You should make some stuff for users like cost, etc. Importing points from some file. ( Or Assembly.Load, then do something in sv_config like 'points_variable="classname.client[xuid].Points";' )/ Then update client's points by 'Assemly.Load' -> WriteTo or just update variable.
C++/Obj-Cdeveloper. Neko engine wip
Steam: Click
Reply

#5
Updated the plugin because it got a bug (x and y coordinates were wrong) redownload the plugin and it should work. Thanks to @X-Track for letting me know

(05-29-2013, 14:45)SailorMoon Wrote: You should make some stuff for users like cost, etc. Importing points from some file. ( Or Assembly.Load, then do something in sv_config like 'points_variable="classname.client[xuid].Points";' )/ Then update client's points by 'Assemly.Load' -> WriteTo or just update variable.

I don't know exactly what you mean but I think it isn't that easy because not eveyone is using the same DB. Or could you give me an example?
I added a little function for developers, you can add the plugin as a reference in your shop and use the GetPoints() method. It returns the points that you spent on the ammobox (from sv_config settings).
Reply

#6
how to do i find the coordinates?
Reply

#7
here u go. http://www.itsmods.com/forum/Thread-Rele...orter.html
Reply

#8
(06-03-2013, 18:25)isaacirlanda Wrote: how to do i find the coordinates?

(06-03-2013, 18:31)EnVi Sweden Rocks Wrote: here u go. http://www.itsmods.com/forum/Thread-Rele...orter.html

this one i like more but ok.
because than u don't need to type every time !savepos but can u look up your screen.
in my eyes its a lot easier ^^

http://www.itsmods.com/forum/Thread-Rele...onHUD.html
Reply

#9
Could anyone direct me to to the latest add on available at the moment?
Reply

#10
(06-03-2013, 19:28)isaacirlanda Wrote: Could anyone direct me to to the latest add on available at the moment?

here is a link to the last addon:
http://www.itsmods.com/forum/Thread-Rele...-7734.html
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
Rainbow [Release] Plugin ReservedSlot v1.3 frst_ 1 4,998 11-08-2018, 19:17
Last Post: frst_
Tongue [Release] MW3 Shop plugin Dude 56 51,330 03-25-2018, 05:18
Last Post: [email protected]
  [Release] Permission plugin Pozzuh 202 164,009 05-01-2017, 15:41
Last Post: W4R||The Hyper
  [Release] FIXED SPEED PLUGIN hillbilly 2 5,657 06-02-2016, 20:23
Last Post: clacki
  [Release] Bots Plugin For Users Casper 22 39,856 08-22-2015, 17:45
Last Post: SnapBacks
  [Release] God Plugin v5.0 [Ingame Rcon Tool] OzonE 464 336,214 06-27-2015, 15:38
Last Post: bluedot
  [Release] Anti Hardscope Plugin 8q4s8 26 27,635 06-20-2015, 22:44
Last Post: urj88419
  [Release] ProMod Plugin zxz0O0 875 761,849 03-25-2015, 22:02
Last Post: kris
  [Release] [Discontinued] Speed Plugin Pozzuh 164 122,127 10-06-2014, 12:56
Last Post: Nekochan
  [help]how create a ping plugin clacki 3 5,077 09-13-2014, 01:23
Last Post: clacki

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2026 Melroy van den Berg.