Code
StartMessageOne("Shake", victim);
if(hBf != INVALID_HANDLE)
{
BfWriteByte(hBf, 0);
BfWriteFloat(hBf, flAmplitude);
BfWriteFloat(hBf, 1.0);
BfWriteFloat(hBf, flDuration);
EndMessage();
}
flAmplitude и flDuration - амплитуда и продолжительность
Добавлено (08.10.2012, 22:06:23)
---------------------------------------------
Пробуй.
Code
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#define AMP_SHAKE 50.0
#define DUR_SHAKE 1.0
#define NDMG_VERSION "1.0"
new Handle:g_Cvar_Enabled = INVALID_HANDLE;
new bool:g_Enabled;
new Handle:g_Cvar_EnabledDmg = INVALID_HANDLE;
new String:Weapon[30];
public OnPluginStart()
{
g_Cvar_Enabled = CreateConVar("sm_nadedmg_enable", "1", "Enable Nade Dmg");
g_Cvar_EnabledDmg = CreateConVar("sm_nadedmg", "1", "Enable Nade dmg.");
g_Enabled = GetConVarBool(g_Cvar_Enabled);
CreateConVar("sm_nadedmg_version", NDMG_VERSION, "Current version of this plugin", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_UNLOGGED|FCVAR_DONTRECORD|FCVAR_REPLICATED|FCVAR_NOTIFY);
AutoExecConfig(true, "sm_nadedmg");
HookConVarChange(g_Cvar_Enabled, CvarChanged);
if ( g_Enabled )
{
StartHook();
}
}
public CvarChanged(Handle:cvar, const String:oldValue[], const String:newValue[])
{
if ( cvar == g_Cvar_Enabled )
{
if ( g_Enabled == GetConVarBool(g_Cvar_Enabled) )
{
return;
}
g_Enabled = !g_Enabled;
if ( g_Enabled )
{
StartHook();
} else
{
StopHook();
}
return;
}
}
StartHook()
{
HookEvent("player_hurt", player_hurt);
}
StopHook()
{
UnhookEvent("player_hurt", player_hurt);
}
public Action:player_hurt(Handle:event, const String:name[], bool:dontBroadcast)
{
GetEventString(event,"weapon",Weapon,30);
if(StrEqual(Weapon,"hegrenade"))
{
if(g_Cvar_EnabledDmg)
{
new clientid = GetEventInt(event,"userid");
new client = GetClientOfUserId(clientid);
new Float:damage = GetEventFloat(event, "dmg_health");
Shake(client, damage, DUR_SHAKE);
}
else
{
new clientid = GetEventInt(event,"userid");
new client = GetClientOfUserId(clientid);
Shake(client, AMP_SHAKE, DUR_SHAKE);
}
}
return Plugin_Continue;
}
stock Shake(client, Float:flAmplitude, Float:flDuration)
{
new Handle:hBf=StartMessageOne("Shake", client);
if(hBf!=INVALID_HANDLE)
BfWriteByte(hBf, 0);
BfWriteFloat(hBf, flAmplitude);
BfWriteFloat(hBf, 1.0);
BfWriteFloat(hBf, flDuration);
EndMessage();
}
Выполнено на гранату.