Raised This Month: $12 Target: $400
 3% 

[REQ] CVar change when all players die


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
FubarJamie
Junior Member
Join Date: Apr 2015
Location: United Kingdom
Old 02-06-2019 , 05:29   [REQ] CVar change when all players die
Reply With Quote #1

Hi guys,

Wonder if someone can help, I am creating a minigames server and I want players on both teams.

I want T's and CT's to play together but the problem is if all T's die and there is CT's left the round ends with mp_ignore_round_win_conditions 0.

Is it possible to make it so when the round starts mp_ignore_round_win_conditions is set to 1 but when all players are dead set to mp_ignore_round_win_conditions to 0

Cheers.
__________________

Last edited by FubarJamie; 02-06-2019 at 05:30. Reason: typo
FubarJamie is offline
CliptonHeist
Senior Member
Join Date: Feb 2016
Old 02-06-2019 , 06:24   Re: [REQ] CVar change when all players die
Reply With Quote #2

Untested, lemme know if this does/doesn't work.
PHP Code:
#include <sourcemod>

#pragma semicolon 1
#pragma newdecls required

public void OnPluginStart()
{
    
HookEvent("round_start"Event_RoundStart);
    
HookEvent("player_death"Event_PlayerDeathEventHookMode_Post);
}

public 
void Event_RoundStart(Event event, const char[] namebool dontBroadcast)
{
    
SetConVarInt(FindConVar("mp_ignore_round_win_conditions"), 1);
}

public 
void Event_PlayerDeath(Event event, const char[] namebool dontBroadcast)
{
    
bool bDead true;
    for(
int i 1<= MaxClientsi++)
    {
        if(!
IsValidClient(i)) continue;

        if(
IsPlayerAlive(i)) 
        {
            
bDead false;
            break;
        }
    }

    if(
bDeadSetConVarInt(FindConVar("mp_ignore_round_win_conditions"), 0);
}

stock bool IsValidClient(int client)
{
    return 
client >= && 
    
client <= MaxClients && 
    
IsClientConnected(client) && 
    
IsClientAuthorized(client) && 
    
IsClientInGame(client);

CliptonHeist is offline
FubarJamie
Junior Member
Join Date: Apr 2015
Location: United Kingdom
Old 02-06-2019 , 08:20   Re: [REQ] CVar change when all players die
Reply With Quote #3

Thanks, i'll test later.
__________________
FubarJamie is offline
ThatKidWhoGames
Veteran Member
Join Date: Jun 2013
Location: IsValidClient()
Old 02-06-2019 , 10:39   Re: [REQ] CVar change when all players die
Reply With Quote #4

Quote:
Originally Posted by CliptonHeist View Post
Untested, lemme know if this does/doesn't work.
PHP Code:
#include <sourcemod>

#pragma semicolon 1
#pragma newdecls required

public void OnPluginStart()
{
    
HookEvent("round_start"Event_RoundStart);
    
HookEvent("player_death"Event_PlayerDeathEventHookMode_Post);
}

public 
void Event_RoundStart(Event event, const char[] namebool dontBroadcast)
{
    
SetConVarInt(FindConVar("mp_ignore_round_win_conditions"), 1);
}

public 
void Event_PlayerDeath(Event event, const char[] namebool dontBroadcast)
{
    
bool bDead true;
    for(
int i 1<= MaxClientsi++)
    {
        if(!
IsValidClient(i)) continue;

        if(
IsPlayerAlive(i)) 
        {
            
bDead false;
            break;
        }
    }

    if(
bDeadSetConVarInt(FindConVar("mp_ignore_round_win_conditions"), 0);
}

stock bool IsValidClient(int client)
{
    return 
client >= && 
    
client <= MaxClients && 
    
IsClientConnected(client) && 
    
IsClientAuthorized(client) && 
    
IsClientInGame(client);

The IsValidClient check is unnecessary. You can simply just run IsClientInGame since the client is guaranteed to be >= 1 and <= MaxClients. Also, IsClientInGame already checks if IsClientConnected is true.
ThatKidWhoGames is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 02-06-2019 , 10:47   Re: [REQ] CVar change when all players die
Reply With Quote #5

Idk if this is CS:GO but mp_teammates_are_enemies 1 should do the same.
Mitchell 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 07:59.


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