PHP- Kodu:
/* Aim Freeze v0.0.3 by Devil
* Description : An admin (flag definable), which have bind a key for using "freeze" command, can aim a player and freeze/unfreeze him.
A freezed player cannot move, shot, [ jump , take weapons (excepted knife) , and move mouse ] ( [ ] -> definable by cvar )
* Cvars : af_distance < value > - Distance max between aimer and aimed (default : 400)
af_allow_mouse < value > - 1 : allow move mouse ; 0 : not allow move mouse
af_only_knife < value > - 1 : allow only knife ; 0 : allow all weapons
af_allow_jump < value > - 1 : allow jump ; 0 : not allow jump
af_block_chat < value > - Block chat when a player is frozen. 0 : don't block chat ; 1 : block say ; 2 : block say_team ; 3 : block both
* Notes : You have to use the chatcolor plugin of ConnorMcLeod : https://forums.alliedmods.net/showthread.php?p=851160
A player who die is automaticaly unfreezed
A freezed bot can jump even if af_allow_jump is set on "0"
A freezed player is glowed in blue
* Commands : bind < key > "freeze" -> Require admin flag (default : ADMIN_KICK) definable on line X (#define ADMIN_ALLOWED)
-> Freeze/Unfreeze a player
* To approvers : A lot of freeze plugins do same things. This plugins is different because the freeze is by aiming the player, and there is some cvars to config to your tastes
* Credits : ConnorMcLeod - Part of [Un]Freeze stock
* To do : Give me ideas ? :3
* Changelog : v0.0.3 (3 dec 2011) - Add ML
v0.0.2 - Add a glow and some cvars to config to your tastes
v0.0.1 - First release
*/
#include < amxmodx >
#include < engine >
#include < fun >
#include < hamsandwich >
#include < fakemeta >
#include < chatcolor >
#define IsPlayer(%1) (1 <= %1 <= g_iMaxPlayers)
#define is_user_frozen(%1) bFrozen[%1]
#define ADMIN_ALLOWED ADMIN_KICK
/* const */
const iVictim = 2;
const XO_WEAPONS = 4;
const m_pPlayer = 41;
const m_iId = 43;
/* */
new g_iMaxPlayers;
new fwPreThink;
/* bool */
new bool:bFrozen[ 33 ];
/* */
/* pcvars */
new pCvarDistance;
new pCvarAllowMouse;
new pCvarOnlyKnife;
new pCvarAllowJump;
new pCvarBlockChat;
new pCvarBlockVoice;
/* */
/* floats */
new Float: iAngles[ 33 ][ 3 ];
/* */
public plugin_init( )
{
register_plugin( "Aim Freeze" , "0.0.4" , "Devil" );
register_dictionary_colored( "aimfreeze.txt" );
register_clcmd( "freeze" , "cmdFreezePlayer" );
register_clcmd( "say" , "cmdHookSay" );
register_clcmd( "say_team" , "cmdHookSay_Team" );
register_event( "CurWeapon" , "eventCurWeapon" , "be" , "1=1" , "2!29" ); // https://wiki.amxmodx.org/CS_Weapons_Information
register_event( "DeathMsg" , "eventDeathMsg" , "a" );
register_logevent( "eventRoundEnd" , 2 , "1=Round_End" );
pCvarDistance = register_cvar( "af_distance" , "400" ); // distance max between aimer and aimed
pCvarAllowMouse = register_cvar( "af_allow_mouse" , "0" ); // 1 : allow move mouse ; 0 : not allow move mouse
pCvarOnlyKnife = register_cvar( "af_only_knife" , "1" ); // 1 : only allow knife ; 0 : allow all weapons
pCvarAllowJump = register_cvar( "af_allow_jump" , "0" ); // 1 : allow jump ; 0 : not allow jump
pCvarBlockChat = register_cvar( "af_block_chat" , "3" ); // 0 : no blocking ; 1 : block say ; 2 : block say_team ; 3 : block both
pCvarBlockVoice = register_cvar( "af_block_voice" , "1" ); // 0 : no blocking ; 1 : block voice
RegisterHam( Ham_Spawn , "player" , "Player_Spawn" , true );
RegisterHam( Ham_Player_Jump , "player" , "Player_Jump" , false );
g_iMaxPlayers = get_maxplayers( );
}
public cmdFreezePlayer( id )
{
if( !( get_user_flags( id ) & ADMIN_ALLOWED ) )
return PLUGIN_HANDLED;
if( !is_user_alive( id ) )
return PLUGIN_HANDLED;
new tempid , body;
new Float:flDistance = get_user_aiming( id , tempid , body );
if( IsPlayer( tempid ) &&
is_user_alive( tempid ) &&
flDistance <= get_pcvar_float( pCvarDistance ) )
{
new szNameID[ 32 ] , szNameTempID[ 32 ];
get_user_name( id , szNameID , charsmax( szNameID ) );
get_user_name( tempid , szNameTempID , charsmax( szNameTempID ) );
if( is_user_frozen( tempid ) )
{
UnFreeze( tempid );
client_print_color( 0 , DontChange , "%L" , 0 , "UNFREEZE_PLAYER" , szNameID , szNameTempID );
}
else
{
Freeze( tempid );
client_print_color( 0 , DontChange , "%L" , 0 , "FREEZE_PLAYER" , szNameID , szNameTempID );
}
}
return PLUGIN_HANDLED;
}
public cmdHookSay( id )
{
if( is_user_frozen( id ) )
{
new iBlockChat = get_pcvar_num( pCvarBlockChat );
if( iBlockChat == 1 || iBlockChat == 3 )
{
return PLUGIN_HANDLED;
}
}
return PLUGIN_CONTINUE;
}
public cmdHookSay_Team( id )
{
if( is_user_frozen( id ) )
{
new iBlockChat = get_pcvar_num( pCvarBlockChat );
if( iBlockChat == 2 || iBlockChat == 3 )
{
return PLUGIN_HANDLED;
}
}
return PLUGIN_CONTINUE;
}
public Player_Jump( id )
{
if( is_user_frozen( id ) && !get_pcvar_num( pCvarAllowJump ) )
{
return HAM_SUPERCEDE;
}
return HAM_IGNORED;
}
public Player_Spawn( id )
{
if( is_user_alive( id ) )
{
if( is_user_frozen( id ) )
{
UnFreeze( id );
}
}
}
public fwPlayerPreThink( id )
{
if( is_user_frozen( id ) && !get_pcvar_num( pCvarAllowMouse ) )
{
if( is_user_alive( id ) )
{
set_pev( id , pev_v_angle , iAngles[ id ] );
set_pev( id , pev_fixangle , 1 );
}
}
}
public eventCurWeapon( id )
{
if( is_user_alive( id ) )
{
if( is_user_frozen( id ) && get_pcvar_num( pCvarOnlyKnife ) )
{
engclient_cmd( id , "weapon_knife" );
}
}
}
public eventDeathMsg( )
{
UnFreeze( read_data( iVictim ) );
}
public eventRoundEnd( )
{
new iPlayers[ 32 ] , iNum , i , id;
get_players( iPlayers , iNum , "a" );
for( i = 0; i < iNum; i++ )
{
id = iPlayers[ i ];
if( is_user_frozen( id ) )
{
UnFreeze( id );
}
}
}
Freeze( id )
{
new iFlags = pev( id , pev_flags );
if( ~iFlags & FL_FROZEN )
{
set_pev( id , pev_flags , iFlags | FL_FROZEN );
pev( id , pev_v_angle , iAngles[ id ] );
set_user_rendering( id , kRenderFxGlowShell , 0 , 100 , 200 , kRenderNormal , 16 );
if( get_pcvar_num( pCvarBlockVoice ) )
set_speak( id , SPEAK_MUTED );
if( !fwPreThink && !get_pcvar_num( pCvarAllowMouse ) )
fwPreThink = register_forward( FM_PlayerPreThink , "fwPlayerPreThink" );
}
bFrozen[ id ] = true;
}
UnFreeze( id )
{
new frozenCount = 0;
bFrozen[ id ] = false;
new iFlags = pev( id , pev_flags ) ;
if( iFlags & FL_FROZEN )
{
set_pev( id , pev_flags , iFlags & ~FL_FROZEN ) ;
set_user_rendering( id , kRenderFxNone , 0 , 0 , 0 , kRenderNormal , 0 );
new iPlayers[ 32 ] , iNum , i , tid;
get_players( iPlayers , iNum , "a" );
for( i = 0; i < iNum; i++ )
{
tid = iPlayers[ i ];
if( is_user_frozen( tid ) )
{
frozenCount++;
}
}
if( get_speak( id ) == SPEAK_MUTED )
set_speak( id , SPEAK_NORMAL );
if( !frozenCount && fwPreThink )
unregister_forward( FM_PlayerPreThink , fwPreThink );
}
}