Auto start matches without human players

Discussions about Servers
Post Reply
User avatar
UT Sniper (SJA94)
Inhuman
Posts: 753
Joined: Thu Jun 24, 2010 10:35 pm
Personal rank: Retard
Location: England
Contact:

Auto start matches without human players

Post by UT Sniper (SJA94) »

Is there a way to have a server always start matches even if there are no human players on the server?

I was looking through uscript code to try and find how to start a match, but couldn't find what I was looking for(being stupid) or not applying it correctly in a mutator.
User avatar
The_Cowboy
Skilled
Posts: 165
Joined: Mon Jan 24, 2011 3:22 am
Personal rank: Codezilla

Re: Auto start matches without human players

Post by The_Cowboy »

You may hafta write a new gamemode class for that purpose. Since I have UT2k4 code in front of me, I see (file DeathMatch.uc)

Code: Select all

auto State PendingMatch
{
	
    ... Some functions
    
    function Timer()
    {
        local Controller P;
        local bool bReady;

        Global.Timer();

        // first check if there are enough net players, and enough time has elapsed to give people
        // a chance to join
        if ( NumPlayers == 0 )
			bWaitForNetPlayers = true;
	
	// Now this part is hardcoded and nothing can be done here.
    }

  ... Some more related functions

}   
In your new gamemode class get rid of this line. And you are good to go!
Feralidragon wrote:Trial and error is sometimes better than any tutorial, because we learn how it works for ourselfs, which kills any doubts about anything :tu:
Patreon: https://www.patreon.com/FreeandOpen
User avatar
UT Sniper (SJA94)
Inhuman
Posts: 753
Joined: Thu Jun 24, 2010 10:35 pm
Personal rank: Retard
Location: England
Contact:

Re: Auto start matches without human players

Post by UT Sniper (SJA94) »

Pretty crude but does what I required, just wanted matches to happen on my server without me having to have a player joined to it to collect match logs for node utstats.

Code: Select all

//=============================================================================
// Potatoes.
//=============================================================================
class Potatoes expands DeathMatchPlus;

function Timer()
{

	Super.Timer();
	
	bRequireReady = false;
	
	StartMatch();
	
	if(needPlayers()){
		AddBot();
	}
	
	if ( bGameEnded )
		{
			if ( Level.TimeSeconds > EndTime + RestartWait )
				RestartGame();
		}
	else if ( !bOverTime && (TimeLimit > 0) )
	{
		GameReplicationInfo.bStopCountDown = false;
		RemainingTime--;
		GameReplicationInfo.RemainingTime = RemainingTime;
		if ( RemainingTime % 60 == 0 )
			GameReplicationInfo.RemainingMinute = RemainingTime;
		if ( RemainingTime <= 0 )
			EndGame("timelimit");
	}
	else
	{
		ElapsedTime++;
		GameReplicationInfo.ElapsedTime = ElapsedTime;
	}
}


defaultproperties
{
	GameName="Potatoes"
	NetWait=0
    	RestartWait=0
	bNetReady=True
	bStartMatch=True
	bRequireReady=False
	MutatorClass=Class'Botpack.DMMutator'
	DefaultWeapon=Class'BotPack.ImpactHammer'
}


Buggie
Godlike
Posts: 2732
Joined: Sat Mar 21, 2020 5:32 am

Re: Auto start matches without human players

Post by Buggie »

Look like this can be done outside from gameInfo code. For example via mutator with Timer.
User avatar
The_Cowboy
Skilled
Posts: 165
Joined: Mon Jan 24, 2011 3:22 am
Personal rank: Codezilla

Re: Auto start matches without human players

Post by The_Cowboy »

O yeah Buggie, my friend, enlighten us, why would you want to do that instead of graceful leverage of new game type's complete control!
Feralidragon wrote:Trial and error is sometimes better than any tutorial, because we learn how it works for ourselfs, which kills any doubts about anything :tu:
Patreon: https://www.patreon.com/FreeandOpen
User avatar
sektor2111
Godlike
Posts: 6410
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: Auto start matches without human players

Post by sektor2111 »

I've done something a few time ago for starting matches and quickly ending them in purpose to deliver server-travel at MapVote for loading mutators normally in multi-servers. Section for starting goes like this:

Code: Select all

		if ( bStartGames )
		{
			if ( DeathMatchPlus(Level.Game) != None )
			{
				DeathMatchPlus(Level.Game).NetWait=0;
				DeathMatchPlus(Level.Game).RestartWait=0;
				DeathMatchPlus(Level.Game).bRequireReady=False;
				DeathMatchPlus(Level.Game).bNetReady=False;
				DeathMatchPlus(Level.Game).StartMatch();
			}
		}
User avatar
UT Sniper (SJA94)
Inhuman
Posts: 753
Joined: Thu Jun 24, 2010 10:35 pm
Personal rank: Retard
Location: England
Contact:

Re: Auto start matches without human players

Post by UT Sniper (SJA94) »

I put what sektor said, and created a Server Actor and called it in PreBeginPlay(). I did something similar before I did the custom gametype, but missed a few of the values and couldn't get it to work.

Thanks, much less faffing about compared to making custom gametypes.

Code: Select all

//=============================================================================
// AutoStartActor.
//=============================================================================
class AutoStartActor expands Actor;

function PreBeginPlay(){

	if ( DeathMatchPlus(Level.Game) != None ){
	
		DeathMatchPlus(Level.Game).NetWait=0;
		DeathMatchPlus(Level.Game).RestartWait=0;
		DeathMatchPlus(Level.Game).bRequireReady=False;
		DeathMatchPlus(Level.Game).bNetReady=False;
		DeathMatchPlus(Level.Game).StartMatch();
	}
}
Post Reply