View Single Post
Nursik
Senior Member
Join Date: Jul 2016
Location: In TF2
Old 09-28-2016 , 07:48   Re: [CS GO] Spawn protection with fall damage
Reply With Quote #12

Quote:
Originally Posted by xines View Post
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[] namebool dontBroadcast)
{
    new 
userid GetClientOfUserId(event.GetInt("userid"));
    new 
client GetClientUserId(userid);
    if(
IsClientInGame(client) && IsPlayerAlive(client))
    {
        
CreateTimer(g_protecttime.FloatValueTimer_StopTakingNoDamageclient);
        
SDKHook(clientSDKHook_OnTakeDamageOnTakeDamage);
    }
    return 
Plugin_Continue;
}

public 
Action OnTakeDamage(int victimint &attackerint &inflictorfloat &damageint &damagetypeint &weaponfloat 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 timerany userid)
{
    new 
client GetClientOfUserId(userid);
    if (
client != && IsClientInGame(client))
    {
        
SDKUnhook(clientSDKHook_OnTakeDamageOnTakeDamage);
    }
    return 
Plugin_Continue;


Last edited by Nursik; 09-28-2016 at 07:55.
Nursik is offline