Git Product home page Git Product logo

Comments (2)

LiamKarlMitchell avatar LiamKarlMitchell commented on July 20, 2024

I added a new command map2 to change the map clearing players state.

The map command was no good on it's own because it shuts down the server so client's are of course disconnected, I didn't want to modify a core command.
The changelevel command keeps the players state so that's no good for deathmatch.

Server Host.js

Host.Map2_f = function()
{
	if (Cmd.argv.length !== 2)
	{
		Con.Print('map2 <map> : switches to a new map wiping players state\n');
		return;
	}
	if (Cmd.client === true)
		return;
	SV.svs.serverflags = 0;
	SV.SpawnServer(Cmd.argv[1]);
};

Also in the Host.InitCommands add the command.

Cmd.AddCommand('map2', Host.Map2_f);

This can be called by rcon.

So next up would be to read a map rotation file of some kind, and configure it to run that command to the next map after some kind of time or frag limit criteria.

from webquake.

LiamKarlMitchell avatar LiamKarlMitchell commented on July 20, 2024

You can put the commands in Host.js by the way.

Adding another command for map rotation.

Host.MapRotation_f = function() {
	// TODO: figure out how to read a file.
	// TODO: figure out how to perodically check the frag count or play time as a condition to change map?
	// TODO: switch to next map in rotation (or perhaps random or voted map?)
	var mapList = ['DM1', 'DM2', 'DM3', 'DM4', 'DM5', 'DM6', 'END', 'E1M1'];
	var mapIndex = 0;

	function changeToNextMap() {
		mapIndex = (mapIndex + 1) % mapList.length;
		var map = mapList[mapIndex];
		Sys.Print("Map rotating to "+map+"\n");
		Cmd.ExecuteString('map2 '+map); // TODO: Maybe there is a way to call command directly?
	}

	// Change map every 5 minutes.
	clearInterval(Host._mapRotateInterval);
	Host._mapRotateInterval = setInterval(changeToNextMap, 5 * 60000);

	// Change map right now.
	changeToNextMap();
};
Cmd.AddCommand('maprotation', Host.MapRotation_f);

from webquake.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.