AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugin/Gameplay Ideas and Requests (https://forums.alliedmods.net/forumdisplay.php?f=60)
-   -   [CS:GO] mp_respawn_immunitytime for humans only? (https://forums.alliedmods.net/showthread.php?t=334039)

Austin 08-24-2021 16:20

[CS:GO] mp_respawn_immunitytime for humans only?
 
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

8guawong 08-25-2021 03:35

Re: [CS:GO] mp_respawn_immunitytime for humans only?
 
i don't think there is built in cvar that will only give protection to humans
use a plugin instead

Ilusion9 08-28-2021 05:12

Re: [CS:GO] mp_respawn_immunitytime for humans only?
 
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);



Austin 09-06-2021 15:52

Re: [CS:GO] mp_respawn_immunitytime for humans only?
 
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.

??

Ilusion9 09-07-2021 05:03

Re: [CS:GO] mp_respawn_immunitytime for humans only?
 
PHP Code:

    SetEntProp(clientProp_Send"m_bGunGameImmunity"false); 
    
SetEntPropFloat(clientProp_Send"m_fImmuneToGunGameDamageTime"0.0); 


Austin 09-10-2021 19:27

Re: [CS:GO] mp_respawn_immunitytime for humans only?
 
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.


??

Ilusion9 09-11-2021 09:43

Re: [CS:GO] mp_respawn_immunitytime for humans only?
 
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.

Austin 09-11-2021 22:50

Re: [CS:GO] mp_respawn_immunitytime for humans only?
 
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);


All times are GMT -4. The time now is 02:44.

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