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

Quote:
Originally Posted by Bacardi
More like this, use player userid.

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_StopTakingNoDamageGetClientUserId(client));
        
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:userid)
{
   new 
client GetClientOfUserId(userid);

    if (
client != && IsClientInGame(client))
    {
        
SDKUnhook(clientSDKHook_OnTakeDamageOnTakeDamage)
    }


Quote:
Originally Posted by Nursik
The disconnect error fixing.

Last edited by Nursik; 09-28-2016 at 03:48.
Nursik is offline