Veteran Member
Join Date: Aug 2013
Location: Denmark
09-28-2016
, 06:25
Re: [CS GO] Spawn protection with fall damage
#10
Quote:
Originally Posted by
teo30
Here, try this...
Spoiler
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 )
{
int client = GetClientOfUserId ( event . GetInt ( "userid" ));
if( IsClientInGame ( client ) && IsPlayerAlive ( client ))
{
CreateTimer ( g_protecttime . FloatValue , Timer_StopTakingNoDamage , GetClientUserId ( 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 )
{
int client = GetClientOfUserId ( userid );
if ( client != 0 && IsClientInGame ( client ))
{
SDKUnhook ( client , SDKHook_OnTakeDamage , OnTakeDamage );
}
return Plugin_Continue ;
}
__________________