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: 192)
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
Wink Plugin with !ban !kick and !tampban clemi555 3 6,494 11-09-2013, 09:21
Last Post: clemi555
  AntiNoScope Plugin clemi555 5 7,593 11-08-2013, 19:13
Last Post: clemi555
  [Release] Bunker Plugin 1.3 archit 68 55,808 10-30-2013, 11:59
Last Post: clacki
  Help Modifying plugin maverigh 5 7,643 10-19-2013, 10:29
Last Post: Nekochan
Shocked [Request] Switch plugin axel-le-meilleur 6 8,295 10-19-2013, 06:59
Last Post: iRoNinja
  [Release] Yurio Map Plugin Yurio 101 82,123 09-26-2013, 13:38
Last Post: First_Semyon
Brick [Release] v1.1 ChangeMap/NextMap Plugin without any configuration milchshake 23 25,160 09-23-2013, 13:18
Last Post: SgtLegend
  Help !say Plugin (like the !say from GodPlugin) Hallla 0 3,655 09-13-2013, 09:31
Last Post: Hallla
Rainbow [Release] MW3: Random Weapon Plugin V1 Nekochan 50 44,656 09-11-2013, 15:11
Last Post: EnVi Sweden Rocks
  Search Plugin Fluid Killcam N3xT_974 1 3,978 09-10-2013, 20:27
Last Post: Nekochan

Forum Jump:


Users browsing this thread:
1 Guest(s)

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