#include <sdktools_engine>
#include <sdktools_sound>
#define TIME_STOP 2.5
#define FREEZE_COLOR {0, 128, 255, 255}
new g_iOffsetRender, String:g_FreezeSound[PLATFORM_MAX_PATH];
public OnPluginStart()
{
HookEvent("player_hurt", Event_PlayerHurt);
decl Handle:gameConfig;
if((gameConfig=LoadGameConfigFile("funcommands.games")))
{
GameConfGetKeyValue(gameConfig, "SoundFreeze", g_FreezeSound, PLATFORM_MAX_PATH);
CloseHandle(gameConfig);
}
else LogError("Unable to load game config \"funcommands.games\"! The sound of freezing not available.");
if((g_iOffsetRender=FindSendPropOffs("CCSPlayer", "m_clrRender")) == -1)
{
LogError("Offset 'CCSPlayer'::'m_clrRender' not found! The color of freezing not available.");
}
}
public OnMapStart() if(g_FreezeSound[0]) PrecacheSound(g_FreezeSound, true);
public Event_PlayerHurt(Handle:event,String:name[],bool:dontBroadcast)
{
decl String:weapon[9];
GetEventString(event, "weapon", weapon, 9);
if(strncmp(weapon, "knife", 5) == 0 || strcmp(weapon, "bayonet") == 0)
{
new attacker=GetClientOfUserId(GetEventInt(event, "attacker"));
if(attacker) if(GetClientTeam(attacker) == 3)
{
if(GetClientTeam(GetClientOfUserId(GetEventInt(event, "userid"))) == 2)
{
SetEntPropFloat(attacker, Prop_Data, "m_flLaggedMovementValue", 0.0);
if(g_iOffsetRender !=-1) SetEntDataArray(attacker, g_iOffsetRender, FREEZE_COLOR, 4,1,true);
if(g_FreezeSound[0])
{
decl Float:vec[3];
GetClientEyePosition(attacker, vec);
EmitAmbientSound(g_FreezeSound, vec, attacker, SNDLEVEL_RAIDSIREN);
}
SetEntPropFloat(attacker, Prop_Send, "m_flNextAttack", GetGameTime()+TIME_STOP);
CreateTimer(TIME_STOP, UnFreeze, attacker);
PrintToChat(attacker, " \x01\04You have been \x05frozen \x01by hit for \x03%0.1f \x01seconds!", TIME_STOP);
}
}
}
}
public Action:UnFreeze(Handle:timer, any:attacker)
{
if(IsClientInGame(attacker)) if(IsPlayerAlive(attacker))
{
SetEntPropFloat(attacker, Prop_Data, "m_flLaggedMovementValue", 1.0);
if(g_iOffsetRender !=-1) SetEntDataArray(attacker, g_iOffsetRender, {255, 255, 255, 255}, 4,1,true);
if(g_FreezeSound[0])
{
decl Float:vec[3];
GetClientEyePosition(attacker, vec);
EmitAmbientSound(g_FreezeSound, vec, attacker, SNDLEVEL_RAIDSIREN);
}
}
return Plugin_Stop;
}