I'm not sure but it might be the bots screwing everything up.
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(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("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(msgId, dest, id)
{
if(!get_pcvar_num(m2_spyspeed))
return PLUGIN_HANDLED;
if(!is_user_alive(id)) set_user_maxspeed(id, 1.0);
else set_speed(id, savedSpeed[id]);
return PLUGIN_CONTINUE;
}
public applySpeed(id)
{
if(!get_pcvar_num(m2_spyspeed))
return PLUGIN_HANDLED;
new arg[64];
read_data(2, arg, 63);
// Set spys speed according to the class they disguised as
if(containi(arg, "Scout") != -1) set_speed(id, 400.0);
else if(containi(arg, "Sniper") != -1) set_speed(id, 300.0);
else if(containi(arg, "Soldier") != -1) set_speed(id, 240.0);
else if(containi(arg, "Demoman") != -1) set_speed(id, 280.0);
else if(containi(arg, "Medic") != -1) set_speed(id, 320.0);
else if(containi(arg, "HWGUY") != -1) set_speed(id, 230.0);
else if(containi(arg, "Pyro") != -1) set_speed(id,300.0);
else if(containi(arg, "Spy") != -1) set_speed(id, 300.0);
else if(containi(arg, "Engineer") != -1) set_speed(id, 300.0);
return PLUGIN_CONTINUE;
}
public removeSpeed(id)
set_speed(id, 300.0);
public set_speed(id, Float:speed)
{
savedSpeed[id] = speed;
if(is_user_alive(id)) set_user_maxspeed(id, speed);
}
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_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(1, arge, 4);
if(str_to_num(arge) == 0)
{
set_pcvar_num(m2_spyspeed, 0);
console_print(id, "[Spy Speed] Spy Speed is disabled!");
}
else if(str_to_num(arge) == 1)
{
set_pcvar_num(m2_spyspeed, 1);
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;
}