ItsMods
Help Need Help with C# code - Printable Version

+- ItsMods (https://www.itsmods.com)
+-- Forum: Archive (https://www.itsmods.com/Forum-Archive.html)
+--- Forum: Archive (https://www.itsmods.com/Forum-Archive--64.html)
+--- Thread: Help Need Help with C# code (/Thread-Help-Need-Help-with-C-code.html)



Need Help with C# code - tubwux - 08-27-2013

I'm trying to make a plugin for my mw3 infected server that gives the infected extra health and speed. I looked all over this website for help but i couldnt find anything on it. If there is a thread on this that I somehow missed please direct me to it if not here's what I have i'm a noob at coding any help would be greatly appreciated

Code:
using System; using Addon; using System.Timers; namespace plugin_test { public class plugin_test : CPlugin { public override void OnPlayerSpawned(ServerClient Client) { if (Client.Team == Teams.Axis) { Client.Other.MaxHealth = 250; Client.Other.Health = 250; Client.Other.SpeedScale = 2; Client.Other.SetPlayerModel("mp_fullbody_opforce_juggernaut"); } } } }



RE: Need Help with C# code - 8q4s8 - 08-27-2013

Your code should already do what you want but the speed does reset if you change weapon. Created a plugin with easy sv_config settings just for you.
I hope you aren't using tekno or I did this for nothing

Code:
using System; using System.Collections.Generic; using Addon; using System.Text; namespace ClassLibrary1 { public class Class1:CPlugin { int HealthAxis = 100; int HealthAllies = 100; float SpeedScaleAxis = 1; float SpeedScaleAllies = 1; public override void OnServerLoad() { HealthAxis = int.Parse(GetServerCFG("HEALTHandSPEED", "health_axis", "")); HealthAllies = int.Parse(GetServerCFG("HEALTHandSPEED", "health_allies", "")); SpeedScaleAxis = float.Parse(GetServerCFG("HEALTHandSPEED", "speedscale_axis", "")); SpeedScaleAllies = float.Parse(GetServerCFG("HEALTHandSPEED", "speedscale_allies", "")); } public override void OnPlayerSpawned(ServerClient Client) { if (Client.Team == Teams.Allies) Client.Other.Health = HealthAllies; else if (Client.Team == Teams.Axis) Client.Other.Health = HealthAxis; } public override void OnAddonFrame() { foreach (ServerClient c in GetClients()) { if (c.Other.isAlive == true) { if (c.Team == Teams.Allies) c.Other.SpeedScale = SpeedScaleAllies; else if (c.Team == Teams.Axis) c.Other.SpeedScale = SpeedScaleAxis; } } } } }

sv_config
Code:
[HEALTHandSPEED] //axis = zombies, allies = survivors //default health is 100 and default speedscale is 1 health_axis=200 health_allies=100 speedscale_axis=1.5 speedscale_allies=1



RE: Need Help with C# code - tubwux - 08-27-2013

Thank you soooooo much