Raised This Month: $ Target: $400
 0% 

[CS GO] Spawn protection with fall damage


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
teo30
Junior Member
Join Date: Sep 2016
Old 09-27-2016 , 08:39   [CS GO] Spawn protection with fall damage
Reply With Quote #1

Hi guys I need new plugin for my server
I want to use Spawn protection with fall damage enable.
Is it possible?

Last edited by teo30; 09-27-2016 at 08:39.
teo30 is offline
Nursik
Senior Member
Join Date: Jul 2016
Location: In TF2
Old 09-27-2016 , 12:00   Re: [CS GO] Spawn protection with fall damage
Reply With Quote #2

Quote:
Originally Posted by teo30 View Post
Hi guys I need new plugin for my server
I want to use Spawn protection with fall damage enable.
Is it possible?
Yes.

PHP Code:
#pragma semicolon 1
#include sourcemod
#include sdkhooks

public void OnPluginStart()
{
    
HookEvent("player_spawn"OnPlayerSpawn);
}

public 
Action OnPlayerSpawn(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(event.GetInt("userid")
    if(
IsClientInGame(client) && IsPlayerAlive(client))
    {
        
CreateTimer(3.0Timer_StopTakingNoDamageclient);
        
SDKHook(clientSDKHook_OnTakeDamageOnTakeDamage);
    }
}

public 
Action OnTakeDamage(victim, &attacker, &inflictor, &damagefloat damageForce[3], float damagePosition[3])
{
    If (
IsClientInGame(victim) && IsPlayerAlive(victim))
    {
        
damage *= 0.0;
        return 
Plugin_Changed;
    }
}

public 
Action:Timer_StopTakingNoDamage(Handle:timerany:damage)
{
    
SDKUnhook(clientSDKHook_OnTakeDamageOnTakeDamage);

This plugin is not full, please someone finish it, because i don't have time right now. I might finish it soon if no one does. By the way, do you want to make it fall damage blocking only? Because this plugin blocks all the damage. You'll have to compile this as an .sp file via the web compiler or compiler in the "scripting" folder of addons in sourcemod.
EDIT: I think it's finished now.

Last edited by Nursik; 09-27-2016 at 12:57.
Nursik is offline
Nursik
Senior Member
Join Date: Jul 2016
Location: In TF2
Old 09-27-2016 , 23:24   Re: [CS GO] Spawn protection with fall damage
Reply With Quote #3

Tell me if it works.

PHP Code:
#pragma semicolon 1
#include sourcemod
#include sdkhooks

public void OnPluginStart()
{
    
HookEvent("player_spawn"OnPlayerSpawn);
}

public 
Action OnPlayerSpawn(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(event.GetInt("userid")
    if(
IsClientInGame(client) && IsPlayerAlive(client))
    {
        
CreateTimer(3.0Timer_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)
    {
        
damage *= 0.0;
        return 
Plugin_Changed;
    }
}

public 
Action:Timer_StopTakingNoDamage(Handle:timerany:client)
{
    
SDKUnhook(clientSDKHook_OnTakeDamageOnTakeDamage);


Last edited by Nursik; 09-28-2016 at 00:20.
Nursik is offline
teo30
Junior Member
Join Date: Sep 2016
Old 09-27-2016 , 23:36   Re: [CS GO] Spawn protection with fall damage
Reply With Quote #4

Quote:
Originally Posted by Nursik View Post
Tell me if it works.

PHP Code:
#pragma semicolon 1
#include sourcemod
#include sdkhooks
 
public void OnPluginStart()
{
    
HookEvent("player_spawn"OnPlayerSpawn);
}
 
public 
Action OnPlayerSpawn(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(event.GetInt("userid")
    if(
IsClientInGame(client) && IsPlayerAlive(client))
    {
        
CreateTimer(3.0Timer_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)
    {
        
damage *= 0.0;
        return 
Plugin_Changed;
    }
}
 
public 
Action:Timer_StopTakingNoDamage(Handle:timerany:damage)
{
    
SDKUnhook(clientSDKHook_OnTakeDamageOnTakeDamage);

Thank you!
I'll try this later
really thank you!
teo30 is offline
Nursik
Senior Member
Join Date: Jul 2016
Location: In TF2
Old 09-27-2016 , 23: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 01:10.
Nursik is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 09-28-2016 , 00:39   Re: [CS GO] Spawn protection with fall damage
Reply With Quote #6

Use sdkhook once when player enter in server.
Now you create multiple sdkhooks everytime when player spawn.

*nvm, you did use unhook with timer

*if player disconnect before timer executed, error maybe appear
__________________
Do not Private Message @me

Last edited by Bacardi; 09-28-2016 at 00:42.
Bacardi is offline
Nursik
Senior Member
Join Date: Jul 2016
Location: In TF2
Old 09-28-2016 , 00:52   Re: [CS GO] Spawn protection with fall damage
Reply With Quote #7

Quote:
Originally Posted by Bacardi View Post
Use sdkhook once when player enter in server.
Now you create multiple sdkhooks everytime when player spawn.

*nvm, you did use unhook with timer

*if player disconnect before timer executed, error maybe appear
I think i fixed the disconnect error now.
Nursik is offline
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
teo30
Junior Member
Join Date: Sep 2016
Old 09-28-2016 , 05:35   Re: [CS GO] Spawn protection with fall damage
Reply With Quote #9

I tried but I can't compile sp file to smx
http://imgur.com/a/Tnvh2
What did I do wrong?
teo30 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 09-28-2016 , 06:18   Re: [CS GO] Spawn protection with fall damage
Reply With Quote #10

Rename g_protectiontime to g_protecttime
*wait, there many errors
__________________
Do not Private Message @me

Last edited by Bacardi; 09-28-2016 at 06:20.
Bacardi is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 03:30.


Powered by vBulletin®
Copyright ©2000 - 2022, vBulletin Solutions, Inc.
Theme made by Freecode