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

Quote:
Originally Posted by teo30 View Post
Thank you!
I'll try this later
really thank you!
Have fun. It should block fall damage for spawned people for 3 seconds.
EDIT: This might be a better version, try both!

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 
client GetClientOfUserId(event.GetInt("userid"));
    if(
IsClientInGame(client) && IsPlayerAlive(client))
    {
        
CreateTimer(g_protectiontime.FloatValueTimer_StopTakingNoDamageclient);
        
SDKHook(clientSDKHook_OnTakeDamageOnTakeDamage);
    }
}

public 
Action OnTakeDamage(victim, &attacker, &inflictor, &damagefloat 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:client)
{
    if (
IsClientInGame(client) && IsPlayerAlive(client))
    {
        
SDKUnhook(clientSDKHook_OnTakeDamageOnTakeDamage)
    }

This one has a cvar, it's called respawn_protection_time, it should be used in seconds, like 2.0, 6.0. Use it in floats, not integers. Integers are values without points (2, 5, 6).

Last edited by Nursik; 09-28-2016 at 02:10.
Nursik is offline