ItsMods

Full Version: Need Help with C# code
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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");
                }
            }
        }
    }
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

CSHARP Code
  1. using System;
  2. using System.Collections.Generic;
  3. using Addon;
  4. using System.Text;
  5.  
  6. namespace ClassLibrary1
  7. {
  8. public class Class1:CPlugin
  9. {
  10. int HealthAxis = 100;
  11. int HealthAllies = 100;
  12. float SpeedScaleAxis = 1;
  13. float SpeedScaleAllies = 1;
  14. public override void OnServerLoad()
  15. {
  16. HealthAxis = int.Parse(GetServerCFG("HEALTHandSPEED", "health_axis", ""));
  17. HealthAllies = int.Parse(GetServerCFG("HEALTHandSPEED", "health_allies", ""));
  18. SpeedScaleAxis = float.Parse(GetServerCFG("HEALTHandSPEED", "speedscale_axis", ""));
  19. SpeedScaleAllies = float.Parse(GetServerCFG("HEALTHandSPEED", "speedscale_allies", ""));
  20. }
  21. public override void OnPlayerSpawned(ServerClient Client)
  22. {
  23. if (Client.Team == Teams.Allies)
  24. Client.Other.Health = HealthAllies;
  25.  
  26. else if (Client.Team == Teams.Axis)
  27. Client.Other.Health = HealthAxis;
  28. }
  29. public override void OnAddonFrame()
  30. {
  31. foreach (ServerClient c in GetClients())
  32. {
  33. if (c.Other.isAlive == true)
  34. {
  35. if (c.Team == Teams.Allies)
  36. c.Other.SpeedScale = SpeedScaleAllies;
  37. else if (c.Team == Teams.Axis)
  38. c.Other.SpeedScale = SpeedScaleAxis;
  39. }
  40. }
  41. }
  42. }
  43. }


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
Thank you soooooo much