AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugin/Gameplay Ideas and Requests (https://forums.alliedmods.net/forumdisplay.php?f=60)
-   -   [CS GO] Spawn protection with fall damage (https://forums.alliedmods.net/showthread.php?t=288340)

teo30 09-27-2016 08:39

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

Nursik 09-27-2016 12:00

Re: [CS GO] Spawn protection with fall damage
 
Quote:

Originally Posted by teo30 (Post 2457436)
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.

Nursik 09-27-2016 23:24

Re: [CS GO] Spawn protection with fall damage
 
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);



teo30 09-27-2016 23:36

Re: [CS GO] Spawn protection with fall damage
 
Quote:

Originally Posted by Nursik (Post 2457588)
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!

Nursik 09-27-2016 23:39

Re: [CS GO] Spawn protection with fall damage
 
Quote:

Originally Posted by teo30 (Post 2457590)
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).

Bacardi 09-28-2016 00:39

Re: [CS GO] Spawn protection with fall damage
 
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

Nursik 09-28-2016 00:52

Re: [CS GO] Spawn protection with fall damage
 
Quote:

Originally Posted by Bacardi (Post 2457598)
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 09-28-2016 03:46

Re: [CS GO] Spawn protection with fall damage
 
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.



teo30 09-28-2016 05:35

Re: [CS GO] Spawn protection with fall damage
 
I tried but I can't compile sp file to smx
http://imgur.com/a/Tnvh2
What did I do wrong?

Bacardi 09-28-2016 06:18

Re: [CS GO] Spawn protection with fall damage
 
Rename g_protectiontime to g_protecttime
*wait, there many errors


All times are GMT -4. The time now is 20:26.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.