Raised This Month: $32 Target: $400
 8% 

sv_maxspeed and set_user_maxspeed


Post New Thread Reply   
 
Thread Tools Display Modes
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 08-28-2007 , 13:58   Re: sv_maxspeed and set_user_maxspeed
Reply With Quote #11

I'm not sure but it might be the bots screwing everything up.

Try this:
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fun>

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

new m2_spyspeed;
new 
Float:savedSpeed[33];

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_concmd("amx_spyspeed""ToggleEnabled"ADMIN_RCON"<1|0> - turns real spy speeds on or off; 1 = enabled, 0 = disabled")
    
register_event("ResetHUD""hook_ResetHUD""be");
    
register_event("StatusText""applySpeed""b""2&Spy_disguised");
    
register_event("TextMsg""removeSpeed""b""2&Disguise_Lost");
    
register_message(get_user_msgid("Feign"), "checkFeign");
    
server_cmd("sv_maxspeed 400");
    
m2_spyspeed register_cvar("m2_spyspeed""1");
}

public 
hook_ResetHUD(id)
    
savedSpeed[id] = 300.0;

public 
checkFeign(msgIddestid)
{
    if(!
get_pcvar_num(m2_spyspeed))
        return 
PLUGIN_HANDLED;
    
    if(!
is_user_alive(id)) set_user_maxspeed(id1.0);
    else 
set_speed(idsavedSpeed[id]);
    
    return 
PLUGIN_CONTINUE;
}

public 
applySpeed(id)
{
    if(!
get_pcvar_num(m2_spyspeed))
        return 
PLUGIN_HANDLED;
    
    new 
arg[64];
    
read_data(2arg63);
    
    
// Set spys speed according to the class they disguised as
    
if(containi(arg"Scout") != -1set_speed(id400.0);
    else if(
containi(arg"Sniper") != -1set_speed(id300.0);
    else if(
containi(arg"Soldier") != -1set_speed(id240.0);
    else if(
containi(arg"Demoman") != -1set_speed(id280.0);
    else if(
containi(arg"Medic") != -1set_speed(id320.0);
    else if(
containi(arg"HWGUY") != -1set_speed(id230.0);
    else if(
containi(arg"Pyro") != -1set_speed(id,300.0);
    else if(
containi(arg"Spy") != -1set_speed(id300.0);
    else if(
containi(arg"Engineer") != -1set_speed(id300.0);
    
    return 
PLUGIN_CONTINUE;
}

public 
removeSpeed(id)
    
set_speed(id300.0);

public 
set_speed(idFloat:speed)
{
    
savedSpeed[id] = speed;
    if(
is_user_alive(id)) set_user_maxspeed(idspeed);
}

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

hlstriker is offline
M249-M4A1
I <3 Mac
Join Date: May 2005
Location: Not interested
Old 08-28-2007 , 16:47   Re: sv_maxspeed and set_user_maxspeed
Reply With Quote #12

Mad props to you! It worked like a charm! The code is so much nicer and cleaner, but there's still some stuff I gotta add and fix. Thanks so much! I'll be releasing this soon!!! +K
M249-M4A1 is offline
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 08-28-2007 , 16:53   Re: sv_maxspeed and set_user_maxspeed
Reply With Quote #13

No problem, anything to help people supporting the TFC community
hlstriker is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 22:20.


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