Here quick sample.
- Red screen fade when fall damage.
- If player survive after fall, player health restore half of fall damage.
PHP Code:
#include <sdkhooks>
#include <sdktools>
#include <cstrike>
public void OnPluginStart()
{
for(int i = 1; i <= MaxClients; i++)
{
if(IsClientInGame(i)) OnClientPutInServer(i);
}
}
public void OnClientPutInServer(int client)
{
SDKHook(client, SDKHook_OnTakeDamageAlivePost, OnTakeDamageAlivePost);
}
public void OnTakeDamageAlivePost(int victim, int attacker, int inflictor, float damage, int damagetype)
{
if(attacker != 0 || attacker != inflictor || damagetype != DMG_FALL) return;
if(GetClientHealth(victim) <= 0) return;
DataPack pack;
CreateDataTimer(0.5, reg, pack, TIMER_FLAG_NO_MAPCHANGE);
pack.WriteCell(GetClientUserId(victim));
pack.WriteFloat(damage);
pack.Reset();
int duration = 255;
int hold_time = 128;
int flags = 0x0001;
int clr[4];
clr[0] = 255;
clr[1] = 0;
clr[2] = 0;
clr[3] = 255;
Protobuf fade = view_as<Protobuf>(StartMessageOne("Fade", victim));
fade.SetInt("duration", duration);
fade.SetInt("hold_time", hold_time);
fade.SetInt("flags", flags);
fade.SetColor("clr", clr);
EndMessage();
return;
}
public Action reg(Handle timer, DataPack pack)
{
int victim = GetClientOfUserId(pack.ReadCell());
if(victim == 0 || !IsClientInGame(victim) || !IsPlayerAlive(victim)) return Plugin_Stop;
int heal = RoundFloat(pack.ReadFloat());
SetEntityHealth(victim, GetClientHealth(victim) + heal/2);
return Plugin_Continue;
}
__________________