ItsMods

Full Version: MW3 HighJump speed plugin broken?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
OK I've had my server up and running for a long time now and for some reason the speed plugin is messed up now everything has been working just fine and 2 days ago something happened and now as soon as you press w a s or d you zoom off and get all glitchy everything around you is black and your weapon is messed up so i removed the plugin thinking it got corrupted and the server is fine but you walk and run normal so i reinstalled the original speed plugin i had saved on my computer and it goes back to being messed up and unplayable. So does anyone have or has anyone had this problem and know how to fix it?
You should post this in the plugin post Wink
(02-15-2013, 17:04)MADD_DOGG Wrote: [ -> ]OK I've had my server up and running for a long time now and for some reason the speed plugin is messed up now everything has been working just fine and 2 days ago something happened and now as soon as you press w a s or d you zoom off and get all glitchy everything around you is black and your weapon is messed up so i removed the plugin thinking it got corrupted and the server is fine but you walk and run normal so i reinstalled the original speed plugin i had saved on my computer and it goes back to being messed up and unplayable. So does anyone have or has anyone had this problem and know how to fix it?

I update the speedplugin myself and I don't have any problems. I think it's because it's using the wrong offsets.

Here's my code with the current offsets.
Code:
using System;
using System.Runtime.InteropServices;
using Addon;
using System.Net;

namespace ReadyUP
{
    public class Class1 : CPlugin
    {
        string cur_version = "";
        string update_message = "";

        int g_speed_var = 0;
        float jump_height_var = 0;
        int fall_damage_var = 0;
        int gravity_var = 0;
        bool fall_damage_enabled = true;

        IntPtr g_speed, jump_height, fallmax, fallmin, g_gravity;

        [DllImport("kernel32.dll")]
        private static extern bool VirtualProtect(IntPtr lpAddress, uint dwSize, uint flNewProtect, out uint lpflOldProtect);

        unsafe public bool getOffsets()
        {
            //version,g_speed,jump_height,fallmax,fallmin,g_gravity,update message
            try
            {
                WebClient wc = new WebClient();
                string download = "1.9.461,0x046F3D7,0x0787CC8,0x0787908,0x076F044,0x047036C,LOL";
                string[] downloads = download.Split(',');

                cur_version = downloads[0];
                g_speed = (IntPtr)Convert.ToInt32(downloads[1], 16);
                jump_height = (IntPtr)Convert.ToInt32(downloads[2], 16);
                fallmax = (IntPtr)Convert.ToInt32(downloads[3], 16);
                fallmin = (IntPtr)Convert.ToInt32(downloads[4], 16);
                g_gravity = (IntPtr)Convert.ToInt32(downloads[5], 16);
                update_message = downloads[6];

                /*if (cur_version != GetDvar("shortversion"))
                {
                    ServerPrint("Speed plugin outdated, wait patiently for an update!");
                    ServerPrint("Current server version: " + GetDvar("shortversion") + ". Current speed plugin offset version: " + cur_version);
                    return false;
                }*/

                ServerPrint("Speed plugin for version " + cur_version.ToString() + " loaded. Author: Pozzuh.");

                if (update_message != "-1")
                    ServerPrint(update_message);

                return true;
            }
            catch (Exception e)
            {
                ServerPrint("Speed plugin couldn't load. Error written to log.");
                ServerLog(LogType.LogConsole, "SPEED PLUGIN ERROR: " + e.ToString());

                if (update_message != "-1")
                    ServerPrint(update_message);

                return false;
            }
        }

        unsafe public override void OnServerLoad()
        {
            if (!getOffsets())
                return;

            if (GetServerCFG("SPEEDPLUGIN", "Speed", "-1") == "-1")
                SetServerCFG("SPEEDPLUGIN", "Speed", "190");
            if (GetServerCFG("SPEEDPLUGIN", "JumpHeight", "-1") == "-1")
                SetServerCFG("SPEEDPLUGIN", "JumpHeight", "39");
            if (GetServerCFG("SPEEDPLUGIN", "FallDamage", "-1") == "-1")
                SetServerCFG("SPEEDPLUGIN", "FallDamage", "1");
            if (GetServerCFG("SPEEDPLUGIN", "Gravity", "-1") == "-1")
                SetServerCFG("SPEEDPLUGIN", "Gravity", "800");

            try
            {
                g_speed_var = Convert.ToInt32(GetServerCFG("SPEEDPLUGIN", "Speed", "190"));
                jump_height_var = Convert.ToInt32(GetServerCFG("SPEEDPLUGIN", "JumpHeight", "39"));
                fall_damage_var = Convert.ToInt32(GetServerCFG("SPEEDPLUGIN", "FallDamage", "1"));
                gravity_var = Convert.ToInt32(GetServerCFG("SPEEDPLUGIN", "Gravity", "800"));
            }
            catch
            {
                ServerPrint("invalid speed, jump height, fall damage or gravity value...");
            }

            makeSpeedHappy();
            makeJumpHeightHappy();
            makeGravityHappy();

            set_g_speed(g_speed_var);
            set_jump_height(jump_height_var);
            set_g_gravity(gravity_var);

            if (fall_damage_var == 0)
                disableFallDamage();
        }

        public override unsafe ChatType OnSay(string Message, ServerClient Client)
        {
            string lowMsg = Message.ToLower();

            if (lowMsg.StartsWith("!falldamage"))
            {
                string[] splitMsg = lowMsg.Split(' ');

                if (splitMsg.Length == 1)
                {
                    if (fall_damage_enabled)
                        TellClient(Client.ClientNum, "Fall damage is currently enabled.", true);
                    else
                        TellClient(Client.ClientNum, "Fall damage is currently disabled.", true);
                }
                else
                {
                    if (splitMsg[1] == "0")
                    {
                        disableFallDamage();
                        TellClient(Client.ClientNum, "Fall damage is now disabled.", true);
                    }
                    else if (splitMsg[1] == "1")
                    {
                        enableFallDamage();
                        TellClient(Client.ClientNum, "Fall damage is now enabled.", true);
                    }
                }

                return ChatType.ChatNone;
            }

            if (lowMsg.StartsWith("!speed"))
            {
                string[] splitMsg = lowMsg.Split(' ');

                if (splitMsg.Length == 1)
                    TellClient(Client.ClientNum, "Current speed: " + *(int*)g_speed, true);
                else
                {
                    try
                    {
                        int NewSpeedValue = Convert.ToInt32(splitMsg[1]);
                        set_g_speed(NewSpeedValue);

                        TellClient(Client.ClientNum, "Speed changed to: " + NewSpeedValue + " (default=190)", true);
                    }
                    catch
                    {
                        TellClient(Client.ClientNum, "^1Invalid speed value!", true);
                    }
                }
                return ChatType.ChatNone;
            }

            if (lowMsg.StartsWith("!jumpheight"))
            {
                string[] splitMsg = lowMsg.Split(' ');

                if (splitMsg.Length == 1)
                    TellClient(Client.ClientNum, "Current jump height: " + *(float*)jump_height, true);
                else
                {
                    try
                    {
                        float NewJumpHeightValue = (float)Convert.ToInt32(splitMsg[1]);

                        set_jump_height(NewJumpHeightValue);

                        if (NewJumpHeightValue < 128)
                            TellClient(Client.ClientNum, "Jump height changed to: " + NewJumpHeightValue, true);
                        else
                        {
                            TellClient(Client.ClientNum, "Jump height changed to: " + NewJumpHeightValue + " (default=39). Fall damage disabled.", true);
                            disableFallDamage();
                        }

                    }
                    catch
                    {
                        TellClient(Client.ClientNum, "^1Invalid jump height value!", true);
                    }
                }
                return ChatType.ChatNone;
            }

            if (lowMsg.StartsWith("!gravity"))
            {
                string[] splitMsg = lowMsg.Split(' ');

                if (splitMsg.Length == 1)
                    TellClient(Client.ClientNum, "Current gravity: " + *(int*)g_gravity, true);
                else
                {
                    try
                    {
                        int newGravityValue = Convert.ToInt32(splitMsg[1]);

                        set_g_gravity(newGravityValue);

                        TellClient(Client.ClientNum, "Gravity changed to: " + newGravityValue + " (default=800).", true);
                    }
                    catch
                    {
                        TellClient(Client.ClientNum, "^1Invalid gravity value!", true);
                    }
                }
                return ChatType.ChatNone;
            }

            return ChatType.ChatContinue;
        }

        /////////////////////////////////////////////////////////////////////////////////////////////////////////
        //Stuff needed for speed change
        public void makeSpeedHappy()
        {
            try
            {
                uint size = 4;
                uint newProtect = 0x40;
                uint oldProtect = 0;

                VirtualProtect(g_speed, size, newProtect, out oldProtect);
            }
            catch (Exception e)
            {
                ServerLog(LogType.LogConsole, "SPEED PLUGIN ERROR: " + e.ToString());
            }
        }

        unsafe public void set_g_speed(int value)
        {
            try
            {
                *(int*)g_speed = value;
            }
            catch (Exception e)
            {
                ServerLog(LogType.LogConsole, "SPEED PLUGIN ERROR: " + e.ToString());
            }
        }

        public unsafe void makeJumpHeightHappy()
        {
            try
            {
                uint size = 4;
                uint newProtect = 0x40;
                uint oldProtect = 0;

                VirtualProtect(jump_height, size, newProtect, out oldProtect);
                VirtualProtect(fallmin, size, newProtect, out oldProtect);
                VirtualProtect(fallmax, size, newProtect, out oldProtect);


            }
            catch (Exception e)
            {
                ServerLog(LogType.LogConsole, "SPEED PLUGIN ERROR: " + e.ToString());
            }
        }

        public unsafe void disableFallDamage()
        {
            fall_damage_enabled = false;
            *(float*)fallmin = 999999.0f;
            *(float*)fallmax = 1000000.0f;
        }


        public unsafe void enableFallDamage()
        {
            fall_damage_enabled = true;
            *(float*)fallmin = 128.0f;
            *(float*)fallmax = 300.0f;
        }

        unsafe public void set_jump_height(float value)
        {
            try
            {
                *(float*)jump_height = value;
            }
            catch (Exception e)
            {
                ServerLog(LogType.LogConsole, "SPEED PLUGIN ERROR: " + e.ToString());
            }
        }

        public void makeGravityHappy()
        {
            try
            {
                uint size = 4;
                uint newProtect = 0x40;
                uint oldProtect = 0;

                VirtualProtect(g_gravity, size, newProtect, out oldProtect);
            }
            catch (Exception e)
            {
                ServerLog(LogType.LogConsole, "SPEED PLUGIN ERROR: " + e.ToString());
            }
        }

        unsafe public void set_g_gravity(int value)
        {
            try
            {
                *(int*)g_gravity = value;
            }
            catch (Exception e)
            {
                ServerLog(LogType.LogConsole, "SPEED PLUGIN ERROR: " + e.ToString());
            }
        }
    }
}
if your using @8q4s8 ok,

otherwise reboot now should be ok.