I am trying to freeze the whole ct team for 5 seconds. I wrote this:
PHP Code:
#include < amxmodx >
#include < cstrike >
#include < fun >
new bool:g_bFreeze;
new g_msgShakeScreen;
public plugin_init( ) {
register_event( "CurWeapon" , "Event_WeaponSwitch" , "be" , "1=1" );
register_clcmd( "say /test", "Freeze" );
g_msgShakeScreen = get_user_msgid( "ScreenShake" );
}
// called when player switch weapons (because maxspeed changes with every gun
public Event_WeaponSwitch( iPlayerID ) {
new CsTeams:iTeam = cs_get_user_team( iPlayerID );
if( g_bFreeze && iTeam == CS_TEAM_CT ) {
set_user_maxspeed( iPlayerID, 0.1 );
return PLUGIN_HANDLED;
}
return PLUGIN_CONTINUE;
}
public Freeze( ) {
static iPlayers[ 32 ], iNum, iTempid;
get_players( iPlayers, iNum, "ae", "CT" );
g_bFreeze = true;
for( new iLoop = 0; iLoop < iNum; iLoop++ ) {
iTempid = iPlayers[ iLoop ];
// shake screen when become frozen
message_begin( MSG_ONE, g_msgShakeScreen, { 0, 0, 0 }, iTempid );
write_short( 255 << 14 );
write_short( 10 << 14 );
write_short( 255 << 14 );
message_end( );
set_user_maxspeed( iTempid, 0.1 );
}
// unfreeze after 5 seconds
set_task( 5.0, "Unfreeze" );
}
public Unfreeze( ) {
static iPlayers[ 32 ], iNum;
get_players( iPlayers, iNum, "ae", "CT" );
for( new iLoop = 0; iLoop < iNum; iLoop++ ) {
g_bFreeze = false;
ResetUserMaxSpeed( iPlayers[ iLoop ] );
}
}
ResetUserMaxSpeed( iPlayerID ) {
// credits to connor?
new Float:fMaxSpeed;
switch( get_user_weapon( iPlayerID ) )
{
case CSW_SG550, CSW_AWP, CSW_G3SG1 : fMaxSpeed = 210.0;
case CSW_M249 : fMaxSpeed = 220.0;
case CSW_AK47 : fMaxSpeed = 221.0;
case CSW_M3, CSW_M4A1 : fMaxSpeed = 230.0;
case CSW_SG552 : fMaxSpeed = 235.0;
case CSW_XM1014, CSW_AUG, CSW_GALIL, CSW_FAMAS : fMaxSpeed = 240.0;
case CSW_P90 : fMaxSpeed = 245.0;
case CSW_SCOUT : fMaxSpeed = 260.0;
default : fMaxSpeed = 250.0;
}
set_user_maxspeed( iPlayerID, fMaxSpeed );
}
I tested it and it works great.
BUT, when i implement the same idea into my mod (a big plugin), it doesn't seem to work. So what i am asking is when will the user speed be reset (or changed)? Maybe something is interfering with it.
Posting the whole code won't help, cause its 4000+ lines.
__________________