AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugin/Gameplay Ideas and Requests (https://forums.alliedmods.net/forumdisplay.php?f=60)
-   -   [REQ] CVar change when all players die (https://forums.alliedmods.net/showthread.php?t=314161)

FubarJamie 02-06-2019 05:29

[REQ] CVar change when all players die
 
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.

CliptonHeist 02-06-2019 06:24

Re: [REQ] CVar change when all players die
 
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);



FubarJamie 02-06-2019 08:20

Re: [REQ] CVar change when all players die
 
Thanks, i'll test later.

ThatKidWhoGames 02-06-2019 10:39

Re: [REQ] CVar change when all players die
 
Quote:

Originally Posted by CliptonHeist (Post 2638381)
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.

Mitchell 02-06-2019 10:47

Re: [REQ] CVar change when all players die
 
Idk if this is CS:GO but mp_teammates_are_enemies 1 should do the same.


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

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