For entity id, you do it right.
To set player maxspeed :
PHP Code:
set_user_maxspeed(id, flMaxSpeed)
Then to prevent it to change, you have to hook Ham_CS_Item_GetMaxSpeed for every items, then retrieve the owner (either with weapon m_pPlayer offset either with pev_owner) and to supercede it returning a stored by plugin value)
Other solution is to post hook Item_Deploy and to send here set_user_maxspeed.
Last solution is to filter CurWeapon to determinate when a player switch weapon.
Basically something like this should be enough :
PHP Code:
public Event_CurWeapon_Active( id )
{
new iCurWeapon = read_data(2)
if( iCurWeapon != g_iCurWeapon[id] )
{
g_iCurWeapon[id] = iCurWeapon
new Float:flCustomMaxSpeed = g_flCustomMaxSpeed[id]
if( flCustomMaxSpeed != 0.0 )
{
set_user_maxspeed(id, flCustomMaxSpeed)
}
}
}
Also, to reset player speed you can use this :
PHP Code:
cs_reset_user_maxspeed(id)
{
new Float:flMaxSpeed;
switch ( get_user_weapon(id) )
{
case CSW_SG550, CSW_AWP, CSW_G3SG1 : flMaxSpeed = 210.0;
case CSW_M249 : flMaxSpeed = 220.0;
case CSW_AK47 : flMaxSpeed = 221.0;
case CSW_M3, CSW_M4A1 : flMaxSpeed = 230.0;
case CSW_SG552 : flMaxSpeed = 235.0;
case CSW_XM1014, CSW_AUG, CSW_GALIL, CSW_FAMAS : flMaxSpeed = 240.0;
case CSW_P90 : flMaxSpeed = 245.0;
case CSW_SCOUT : flMaxSpeed = 260.0;
default : flMaxSpeed = 250.0;
}
set_user_maxspeed(id, flMaxSpeed);
}
__________________