Raised This Month: $319 Target: $400
 79%   Almost there!

[CS:GO] mp_respawn_immunitytime for humans only?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Austin
Senior Member
Join Date: Oct 2005
Old 08-24-2021 , 16:20   [CS:GO] mp_respawn_immunitytime for humans only?
Reply With Quote #1

I am using mp_respawn_immunitytime and it works great and gives immunity for the specified time and has an OK looking effect, but I would like it to apply to only humans instead of the default bot and humans having immunity.

Any ideas on how to write a plugin to do this?
tx
Austin is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 08-25-2021 , 03:35   Re: [CS:GO] mp_respawn_immunitytime for humans only?
Reply With Quote #2

i don't think there is built in cvar that will only give protection to humans
use a plugin instead
__________________
8guawong is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 08-28-2021 , 05:12   Re: [CS:GO] mp_respawn_immunitytime for humans only?
Reply With Quote #3

PHP Code:

#include <sourcemod>
#include <sdktools>

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

public 
void Event_PlayerSpawn(Event event, const char[] namebool dontBroadcast
{
    if (
event.GetInt("teamnum") < CS_TEAM_T)
    {
        return;
    }
    
    
int client GetClientOfUserId(event.GetInt("userid"));
    if (!
client || !IsFakeClient(client))
    {
        return;
    }
    
    
SetEntPropFloat(clientProp_Send"m_bGunGameImmunity"0.0);

__________________
Ilusion9 is offline
Austin
Senior Member
Join Date: Oct 2005
Old 09-06-2021 , 15:52   Re: [CS:GO] mp_respawn_immunitytime for humans only?
Reply With Quote #4

Ilusion9,
thanks for the post.

The plugin gives an error on this line: property is not a float value
SetEntPropFloat()

I changed it to
SetEntProp()

And for testing removed the check for bots so everyone should be getting immunity and my logging shows it is being called,
but no one does.

??

Last edited by Austin; 09-06-2021 at 15:52.
Austin is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 09-07-2021 , 05:03   Re: [CS:GO] mp_respawn_immunitytime for humans only?
Reply With Quote #5

PHP Code:
    SetEntProp(clientProp_Send"m_bGunGameImmunity"false); 
    
SetEntPropFloat(clientProp_Send"m_fImmuneToGunGameDamageTime"0.0); 
__________________
Ilusion9 is offline
Austin
Senior Member
Join Date: Oct 2005
Old 09-10-2021 , 19:27   Re: [CS:GO] mp_respawn_immunitytime for humans only?
Reply With Quote #6

Ilusion9,

1) Test one
mp_respawn_immunitytime 360
and no plugin.

Everyone has immunity until they fire a weapon.


2) Test two.
mp_respawn_immunitytime 360

and this plugin

#include <sourcemod>
public void OnPluginStart()
{
HookEvent("player_spawn", Event_PlayerSpawn);
}

public void Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(event.GetInt("userid"));
if (!client)
return;

new String:cname[255];
GetClientName(client, cname, 255);
PrintToChatAll("Removing Immunity from %s", cname);

SetEntProp(client, Prop_Send, "m_bGunGameImmunity", false);
SetEntPropFloat(client, Prop_Send, "m_fImmuneToGunGameDamageTime", 0.0);
}

Everyone has immunity until they fire a weapon.

I would expect immunity to be removed from everyone but everyone still has immunity.
I know the player spawn is runing because of the messages are printed.


??
Austin is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 09-11-2021 , 09:43   Re: [CS:GO] mp_respawn_immunitytime for humans only?
Reply With Quote #7

What I gave you:
PHP Code:
    int client GetClientOfUserId(event.GetInt("userid"));
    if (!
client || !IsFakeClient(client))
    {
        return;
    } 
What you pasted here:
PHP Code:
    int client GetClientOfUserId(event.GetInt("userid"));
    if (!
client)
        return; 
See the differences.
__________________
Ilusion9 is offline
Austin
Senior Member
Join Date: Oct 2005
Old 09-11-2021 , 22:50   Re: [CS:GO] mp_respawn_immunitytime for humans only?
Reply With Quote #8

Ilusion9,

I should have explained what I was doing better.
I only hinted at it when I said about my example “I would expect immunity to be removed from everyone…”

When learning a new SM concept or code and it isn’t working I like to condense it down to the smallest possible bit of code to try to debug it.

Since my example only returns on an invalid client I would expect the two SetEntProp() to run on everyone, all players all teams to remove immunity and my PrintToChat() shows all players at round start so I know those lines are being applied to all connected players,

but everyone always gets immunity so calling those two lines on a client in Player_Spawn() doesn’t remove immunity.
At least not in CSGO.

And I tried the converse to set immunity and it doesn’t work either.
SetEntProp(client, Prop_Send, "m_bGunGameImmunity", true);
SetEntPropFloat(client, Prop_Send, "m_fImmuneToGunGameDamageTime", 60.0);

Last edited by Austin; 09-13-2021 at 02:01.
Austin 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 11:49.


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