AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   sv_maxspeed and set_user_maxspeed (https://forums.alliedmods.net/showthread.php?t=60111)

M249-M4A1 08-27-2007 00:57

sv_maxspeed and set_user_maxspeed
 
Hi, I'm trying to make a plugin that changes the spy's disguised class speed to whichever class's disguise they take on. All works fine, except if I raise sv_maxspeed to 400, everyone in the server's maxspeed raises. But I want it to only effect that one player. It seems that set_user_maxspeed seems to obey the sv_maxspeed cvar. Is there any way I can set the maxspeed for one player higher than sv_maxspeed so it doesn't effect other players? BTW: The default server maxspeed is set to 320, but when I did get_user_maxspeed on a scout, it reported 400. In the game programming it seems to override the default 320.

EDIT: I checked http://forums.alliedmods.net/showthr...axspeed&page=2 and I'm still wondering if setting a cl_blahblah would be considered slowhacking. I want to stay away from that.

ConnorMcLeod 08-27-2007 06:04

Re: sv_maxspeed and set_user_maxspeed
 
You can get client cvar like this :

Code:
new Float:g_speed[33][3] public client_connect(id) {     query_client_cvar(id , "cl_forwardspeed" , "cvar_result1");     query_client_cvar(id , "cl_backspeed" , "cvar_result2");     query_client_cvar(id , "cl_sidespeed" , "cvar_result3"); } public cvar_result1(id, const cvar[] , const value[]) {     g_speed[id][0] = floatstr(value); } public cvar_result2(id, const cvar[] , const value[]) {     g_speed[id][1] = floatstr(value); } public cvar_result3(id, const cvar[] , const value[]) {     g_speed[id][2] = floatstr(value); }


I guess you shoud do it with only 1 cvar_result function but i don't want to search how to do it ;)
So you can now store client's values, and set them back when you want.

I think that you can't set client_maxspeed (set_user_maxspeed) higher than sv_maxspeed but i may be wrong.Please give feed back about this.

M249-M4A1 08-27-2007 11:51

Re: sv_maxspeed and set_user_maxspeed
 
That looks great! Is that considered slowhacking though?

EDIT: It still needs sv_maxspeed up for it to work (or so it seems). I'm stumped! +Karma for the help though!

EDIT AGAIN: I just noticed that if I changed sv_maxspeed to 1000 WITHOUT my plugin running, no one goes any faster. In my plugin, I used "id" for the player index. Could it be that it doesn't know who's ID it really is? (I never did any get index thing)

hlstriker 08-27-2007 14:09

Re: sv_maxspeed and set_user_maxspeed
 
This will set the spys speed to the class they disguised as and reset their speed to normal when they undisguise. I think this is what you are trying to do? If so, none of that other code is needed. Also, the maxspeed doesn't need to be changed for this to work. 400 is default maxspeed in TFC.

Note: Maxspeed in TFC can go up to 2000. I saw the other thread said maxspeed is 1000, not sure if that's only CS or what.

PHP Code:

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_event("StatusText""hook_StatusText""b""2&Spy_disguised");
    
register_event("TextMsg""hook_TextMsg""b""2&Disguise_Lost");
}

public 
hook_TextMsg(id)
{
    
// Spy lost their disguise, reset their speed
    
engfunc(EngFunc_SetClientMaxspeedid300.0);
}

public 
hook_StatusText(id)
{
    new 
arg2[64];
    
read_data(2arg263);
    
    if(
containi(arg2"Scout") != -1)
    {
        
// Disguised as Scout
        
engfunc(EngFunc_SetClientMaxspeedid400.0);
    }
    else if(
containi(arg2"Sniper") != -1)
    {
        
// Disguised as Sniper
        
engfunc(EngFunc_SetClientMaxspeedid300.0);
    }
    else if(
containi(arg2"Soldier") != -1)
    {
        
// Disguised as Soldier
        
engfunc(EngFunc_SetClientMaxspeedid240.0);
    }
    else if(
containi(arg2"Demoman") != -1)
    {
        
// Disguised as Demoman
        
engfunc(EngFunc_SetClientMaxspeedid280.0);
    }
    else if(
containi(arg2"Medic") != -1)
    {
        
// Disguised as Medic
        
engfunc(EngFunc_SetClientMaxspeedid320.0);
    }
    else if(
containi(arg2"HWGuy") != -1)
    {
        
// Disguised as HWGuy
        
engfunc(EngFunc_SetClientMaxspeedid230.0);
    }
    else if(
containi(arg2"Pyro") != -1)
    {
        
// Disguised as Pyro
        
engfunc(EngFunc_SetClientMaxspeedid300.0);
    }
    else if(
containi(arg2"Spy") != -1)
    {
        
// Disguised as Spy
        
engfunc(EngFunc_SetClientMaxspeedid300.0);
    }
    else if(
containi(arg2"Engineer") != -1)
    {
        
// Disguised as Engineer
        
engfunc(EngFunc_SetClientMaxspeedid300.0);
    }



M249-M4A1 08-27-2007 15:03

Re: sv_maxspeed and set_user_maxspeed
 
Yeah I have that code already, except I didn't use engfunc

now i cant release this plugin :(

ConnorMcLeod 08-27-2007 16:11

Re: sv_maxspeed and set_user_maxspeed
 
In counter-strike, user maxspeed is set each time a player change weapons, make sure that it's not the same in TFC.

And in cs, CurrentWeapon is called when a player change weapon but also when the player is shooting.
I have already made the code to filtering that so if you need it just ask.

hlstriker 08-27-2007 16:17

Re: sv_maxspeed and set_user_maxspeed
 
Quote:

Originally Posted by connorr (Post 524001)
In counter-strike, user maxspeed is set each time a player change weapons, make sure that it's not the same in TFC.

And in cs, CurrentWeapon is called when a player change weapon but also when the player is shooting.
I have already made the code to filtering that so if you need it just ask.

TFC is like that only if the maxspeed exceeds the 400 limit. So in this case the cur weapon hooking isn't needed.

Quote:

Originally Posted by M249-M4A1 (Post 523971)
Yeah I have that code already, except I didn't use engfunc

now i cant release this plugin :(

Why's that? It's your plugin. We just helped.

M249-M4A1 08-27-2007 16:25

Re: sv_maxspeed and set_user_maxspeed
 
I have almost exactly what you had, I used engfunc as an alternative to set_user_maxspeed as a test. I could change it back but I don't want anything thinking I stole your code. Thanks for all the help guys!

PS: I give up on this maxspeed deal. Most servers are set to 320, scouts still go 400, and changing sv_maxspeed makes everyone go crazy, for some weeeeeiiiirrrrddd reason...

hlstriker 08-27-2007 16:27

Re: sv_maxspeed and set_user_maxspeed
 
I don't understand why everyone goes crazy. That's not happening in my server.

M249-M4A1 08-27-2007 16:32

Re: sv_maxspeed and set_user_maxspeed
 
I have bots on my server, and when I disguise their speeds change (when they respawn). The scout doesn't get any additional speed unless sv_maxspeed is 400, and the plugin affects players too (id confusion?) I'll post my code:

Code:

#include <amxmodx>
#include <amxmisc>
#include <fun>

#define PLUGIN "M2's Spy Speed"
#define VERSION "1.0"
#define AUTHOR "M249-M4A1"

new Float:speed[33]

public plugin_init()
{
        // Basic plugin initialization stuff
        register_plugin(PLUGIN, VERSION, AUTHOR)
        register_concmd("amx_spyspeed", "ToggleEnabled", ADMIN_RCON, "<1|0> - turns real spy speeds on or off; 1 = enabled, 0 = disabled")
        register_event("TextMsg", "RemoveSpeed", "b", "2&Disguise_resetclass")
        register_event("TextMsg", "RemoveSpeed", "b", "2&Disguise_Lost")
        register_event("TextMsg", "RemoveSpeed", "b", "2&Disguise_resetteam")
        register_event("StatusText", "ApplySpeed", "b", "2&Spy_disguised")
        register_event("Feign", "CheckFeign", "b")
        register_cvar("m2_spyspeed", "1")
}


public CheckFeign(id)
{
        if (is_user_alive(id) == 0 && get_user_maxspeed(id) == 1.0)
        {
                // This is necessary to prevent the feigned spy from moving
                return PLUGIN_HANDLED
        }
        else if (is_user_alive(id) == 1 && get_user_maxspeed(id) || 1.0)
        {
                // Restores the spy's original class speed
                ApplySpeed2(id)
        }
        return PLUGIN_CONTINUE
}

public ApplySpeed(id)
{
        // Check if the spy speed adjustor is enabled
        if (get_cvar_num("m2_spyspeed") == 1)
        {
                new arg[64]
                read_data(2, arg, 63)
               
                // Check which class the user disguised themself as and
                // set their maxspeed according to that class
                if(containi(arg, "Scout") != -1)
                {
                        speed[id] = 400.0
                        ApplySpeed2(id)
                }
                else if(containi(arg, "Sniper") != -1)
                {
                        speed[id] = 300.0
                        ApplySpeed2(id)
                }
                else if(containi(arg, "Soldier") != -1)
                {
                        speed[id] = 240.0
                        ApplySpeed2(id)
                }
                else if(containi(arg, "Demoman") != -1)
                {
                        speed[id] = 280.0
                        ApplySpeed2(id)
                }
                else if(containi(arg, "Medic") != -1)
                {
                        speed[id] = 320.0
                        ApplySpeed2(id)
                }
                else if(containi(arg, "HWGUY") != -1)
                {
                        speed[id] = 230.0
                        ApplySpeed2(id)
                }
                else if(containi(arg, "Pyro") != -1)
                {
                        speed[id] = 300.0
                        ApplySpeed2(id)
                }
                else if(containi(arg, "Spy") != -1)
                {
                        speed[id] = 300.0
                        ApplySpeed2(id)
                }
                else if(containi(arg, "Engineer") != -1)
                {
                        speed[id] = 300.0
                        ApplySpeed2(id)
                }
        }
}

public ApplySpeed2(id)
{
        set_user_maxspeed(id, speed[id])
        return PLUGIN_HANDLED
}

public RemoveSpeed(id)
{
        // Remove the user's speed change
        speed[id] = 300.0
        ApplySpeed2(id)
}

public ToggleEnabled(id, level, cid)
{
        // Check if the user calling the command has the right access flag
        if (!cmd_access(id, level, cid, 1))
                return PLUGIN_HANDLED
       
        // See if the user supplied enough arguments
        if (read_argc() < 2)
        {
                if (get_cvar_num("m2_spyspeed") == 1)
                {
                        console_print(id,"[Spy Speed] Usage: amx_spyspeed <1|0> | Currently: Enabled")
                        return PLUGIN_HANDLED
                }
                else if (get_cvar_num("m2_spyspeed") == 0)
                {
                        console_print(id,"[Spy Speed] Usage: amx_spyspeed <1|0> | Currently: Disabled")
                        return PLUGIN_HANDLED
                }
                return PLUGIN_HANDLED
        }
       
        new arge[5]
        read_argv(1, arge, 4)
       
        if (str_to_num(arge) == 0)
        {
                set_cvar_num("m2_spyspeed", 0)
                console_print(id, "[Spy Speed] Spy Speed is disabled!")
                return PLUGIN_HANDLED
        }
        else if (str_to_num(arge) == 1)
        {
                set_cvar_num("m2_spyspeed", 1)
                console_print(id, "[Spy Speed] Spy Speed is enabled!")
                return PLUGIN_HANDLED
        }
        else
        {
                console_print(id, "[Spy Speed] Usage: amx_spyspeed <1|0> | 1 = enabled, 0 = disabled")
                return PLUGIN_HANDLED
        }
        return PLUGIN_HANDLED
}



All times are GMT -4. The time now is 16:17.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.