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(PLUGIN, VERSION, AUTHOR);
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_SetClientMaxspeed, id, 300.0);
}
public hook_StatusText(id)
{
new arg2[64];
read_data(2, arg2, 63);
if(containi(arg2, "Scout") != -1)
{
// Disguised as Scout
engfunc(EngFunc_SetClientMaxspeed, id, 400.0);
}
else if(containi(arg2, "Sniper") != -1)
{
// Disguised as Sniper
engfunc(EngFunc_SetClientMaxspeed, id, 300.0);
}
else if(containi(arg2, "Soldier") != -1)
{
// Disguised as Soldier
engfunc(EngFunc_SetClientMaxspeed, id, 240.0);
}
else if(containi(arg2, "Demoman") != -1)
{
// Disguised as Demoman
engfunc(EngFunc_SetClientMaxspeed, id, 280.0);
}
else if(containi(arg2, "Medic") != -1)
{
// Disguised as Medic
engfunc(EngFunc_SetClientMaxspeed, id, 320.0);
}
else if(containi(arg2, "HWGuy") != -1)
{
// Disguised as HWGuy
engfunc(EngFunc_SetClientMaxspeed, id, 230.0);
}
else if(containi(arg2, "Pyro") != -1)
{
// Disguised as Pyro
engfunc(EngFunc_SetClientMaxspeed, id, 300.0);
}
else if(containi(arg2, "Spy") != -1)
{
// Disguised as Spy
engfunc(EngFunc_SetClientMaxspeed, id, 300.0);
}
else if(containi(arg2, "Engineer") != -1)
{
// Disguised as Engineer
engfunc(EngFunc_SetClientMaxspeed, id, 300.0);
}
}