|
Junior Member
|
09-29-2016
, 10:27
Re: [CS GO] Spawn protection with fall damage
|
#18
|
Quote:
Originally Posted by xines
I thought you wanted both, so this is only to block damage from players, but allow fall damage?
If so, here:
Spoiler
PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdkhooks>
#pragma newdecls required
ConVar g_protecttime;
int g_protonoff[MAXPLAYERS+1];
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))
{
g_protonoff[client] = 1;
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 (g_protonoff[victim] == 1 && !(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);
g_protonoff[client] = 0;
}
return Plugin_Continue;
}
|
perfect, thank you so much!
|
|
|
|