Raised This Month: $344 Target: $400
 86%   Almost there!

Solved [CSGO] check for round 3 and + restart delay (Auto Switch Teams Plugin Done!)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Austin
Senior Member
Join Date: Oct 2005
Old 08-03-2022 , 21:36   [CSGO] check for round 3 and + restart delay (Auto Switch Teams Plugin Done!)
Reply With Quote #1

I have this setting
mp_round_restart_delay 7
to give 7 seconds after a round is over before the next round starts.

How do I tell
1) if it is the end of round 3
2) and the mp_round_restart_delay time has expired?

Tx

Last edited by Austin; 08-13-2022 at 15:10.
Austin is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 08-03-2022 , 23:12   Re: [CSGO] check for round 3 and + restart delay
Reply With Quote #2

Quote:
Originally Posted by Austin View Post
I have this setting
mp_round_restart_delay 7
to give 7 seconds after a round is over before the next round starts.

How do I tell
1) if it is the end of round 3
2) and the mp_round_restart_delay time has expired?

Tx
1. int roundsPlayed = CS_GetTeamScore(CS_TEAM_CT) + CS_GetTeamScore(CS_TEAM_T);

2. When that time expires, a new round will start. HookEvent("round_start", Event_RoundStart, EventHookMode_PostNoCopy);

If you want to tell at any given moment if a round has ended, without relying on events:

GameRules_GetPropFloat("m_flRestartRoundTime" ) will be bigger than 0.0 if the round has ended.
__________________
I am available to make plugins for pay.

Discord: Eyal282#1334
eyal282 is offline
Austin
Senior Member
Join Date: Oct 2005
Old 08-13-2022 , 03:19   Re: [CSGO] check for round 3 and + restart delay
Reply With Quote #3

Quote:
Originally Posted by eyal282 View Post
1. int roundsPlayed = CS_GetTeamScore(CS_TEAM_CT) + CS_GetTeamScore(CS_TEAM_T);
This is the part I didn't have.
I could not find anything releated to tracking number of rounds.

Working switch teams on n rounds.
Thanks!

PHP Code:
#include <sourcemod>
#include <sdktools>
#include <cstrike>
#pragma semicolon 1

ConVar roundToSwitchOn;

public 
void OnPluginStart()
{
    
roundToSwitchOn CreateConVar("roundToSwitchOn""3""Switches Teams at the end of this round");
    
HookEvent("round_end"Event_RoundEndEventHookMode_Post);
}

public 
Event_RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
{
    if ((
CS_GetTeamScore(CS_TEAM_CT) + CS_GetTeamScore(CS_TEAM_T)) ==  GetConVarInt(roundToSwitchOn))
    {
        
PrintCenterTextAll("Switching Teams in 5 seconds....");
        
CreateTimer(5.0RestartRound);
    }
}

public 
Action RestartRound(Handle timer)
{
    for (
int i 1<= MaxClientsi++)
        if (
IsClientInGame(i))
            if (
GetClientTeam(i) == CS_TEAM_T)
                
ChangeClientTeam(i,CS_TEAM_CT);
            else if (
GetClientTeam(i) == CS_TEAM_CT)
                
ChangeClientTeam(i,CS_TEAM_T);
    
ServerCommand("mp_restartgame 0");

Attached Files
File Type: sp Get Plugin or Get Source (ABS_CSGO_AutoSwitchTeams.sp - 17 views - 912 Bytes)

Last edited by Austin; 08-13-2022 at 19:10.
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 02:40.


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