Quote:
Originally Posted by xines
Here, try this...
|
Or this:
PHP Code:
#pragma semicolon 1
#include sourcemod
#include sdkhooks
ConVar g_protecttime;
public void OnPluginStart()
{
g_protecttime = CreateConVar("respawn_protection_time", "3.0", "How much seconds to protect from fall damage");
HookEvent("player_spawn", OnPlayerSpawn);
}
public Action OnPlayerSpawn(Event event, const char[] name, bool dontBroadcast)
{
new userid = GetClientOfUserId(event.GetInt("userid"));
new client = GetClientUserId(userid);
if(IsClientInGame(client) && IsPlayerAlive(client))
{
CreateTimer(g_protecttime.FloatValue, Timer_StopTakingNoDamage, client);
SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
}
return Plugin_Continue;
}
public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype, int &weapon, float damageForce[3], float damagePosition[3])
{
if (IsClientInGame(victim) && IsPlayerAlive(victim))
{
if (damagetype & DMG_FALL)
{
return Plugin_Handled;
}
}
return Plugin_Continue;
}
public Action Timer_StopTakingNoDamage(Handle timer, any userid)
{
new client = GetClientOfUserId(userid);
if (client != 0 && IsClientInGame(client))
{
SDKUnhook(client, SDKHook_OnTakeDamage, OnTakeDamage);
}
return Plugin_Continue;
}