[Xaseco] Vote for game mode ver 1.0 [6.10.2010]

Discuss everything about Xymph's Aseco flavoured server control scripts for TM Forever / classic TMN and for TM² Canyon.

Moderators: Xymph, TM-Patrol

Post Reply
reaby
smooth traffic navigator
smooth traffic navigator
Posts: 213
Joined: 02 Jul 2009 21:24
Owned TM-games: TMUF

[Xaseco] Vote for game mode ver 1.0 [6.10.2010]

Post by reaby » 06 Oct 2010 14:44

Vote for Gamemode

There were intresting questiong about custom votes on toolbox forum, so after some testing if fastly come up with this idea of allowing users to vote for next game mode on server.

Plugin is public domain, do whatever you wish for it, here's the source code.

HOW TO INSTALL
simply copy & paste the code to new text file, rename it to for example "plugin.votegamemode.php" and move the text file to plugins folder on your xaseco folder.

then edit plugins.xml on xaseco root folder and add <plugin>plugin.votegamemode.php</plugin> to last entry on
the file.

*edit* hehe.. before anybody asks how to use it, i'll answer *edit*

How to use
To set a vote, player needs to set a chat command like:
/vote gamemode [TA,rounds,cup,teams]

Future additions

If there's need to add other votes, then it is quite easy. examples are anonymous kick/ban/skip/replay votes like:
/vote kick [login]
/vote ban [login]
/vote skip
/vote replay

The code

Code: Select all

<?php
# Vote for game modes
# Reaby / 6.10.2010
# version 1.0
# CCBY 3.0

Aseco::registerEvent("onEcho", "echo_gamemode");
Aseco::addChatCommand("vote", "runs a vote against changing for game modes");

function chat_vote($aseco,$command) {
	$player = $command['author'];
	$login = $player->login;
	$newmode = explode(' ', $command['params']);
	
	if(empty($command['params'])) {
	$aseco->client->query('ChatSendServerMessageToLogin', ">> Arguments missing, see /vote help for more info",$login);
	}
	
	if(strtolower($newmode[0]) == "help") {
	$aseco->client->query('ChatSendServerMessageToLogin', ">> valid arguments are /vote gamemode X, where X is TA,Team,Rounds,Cup",$login);
	}
	
	if(strtolower($newmode[0]) == "gamemode") { 

		if (strtolower($newmode[1]) == "ta") {
		callEchoVote("Change the server mode to \$ff0TimeAttack", "servermode_TA");
		}

		if (strtolower($newmode[1]) == "rounds") {
		callEchoVote("Change the server mode to \$ff0Rounds", "servermode_Rounds");
		}

		if (strtolower($newmode[1]) == "team") {
		callEchoVote("Change the server mode to \$ff0Team", "servermode_Team");
		}

		if (strtolower($newmode[1]) == "cup") {
		callEchoVote("Change the server mode to \$ff0CUP", "servermode_CUP");
		}
 	
	}
	
}
function callEchoVote($public, $internal) {
	global $aseco;
    $request = new IXR_Request('Echo', array($public, $internal));
    $xml = $request->getXml();
    $aseco->client->query('CallVote', $xml);
}

function echo_gamemode($aseco, $args) {
    $internal = $args[0];
	$public = $args[1];
     
    if( trim($internal) == "servermode_TA" ) {
		$aseco->client->query('SetGameMode', 1);
        $aseco->client->query('ChatSendServerMessage', "\$o\$f00Attention! \$z\$s\$0f0 Server game mode set by vote to \$ff0Time Attack \$0f0on next challenge!");
		}

    if( trim($internal) == "servermode_Rounds" ) {
		$aseco->client->query('SetGameMode', 0);
        $aseco->client->query('ChatSendServerMessage', "\$o\$f00Attention! \$z\$s\$0f0 Server game mode set by vote to \$ff0Rounds \$0f0on next challenge!");
		}

    if( trim($internal) == "servermode_Team" ) {
		$aseco->client->query('SetGameMode', 2);
        $aseco->client->query('ChatSendServerMessage', "\$o\$f00Attention! \$z\$s\$0f0 Server game mode set by vote to \$ff0Team \$0f0on next challenge!");
		}
    if( trim($internal) == "servermode_CUP" ) {
		$aseco->client->query('SetGameMode', 5);
        $aseco->client->query('ChatSendServerMessage', "\$o\$f00Attention! \$z\$s\$0f0 Server game mode set by vote to \$ff0CUP \$0f0on next challenge!");
		}

}
?>
Last edited by reaby on 06 Oct 2010 16:24, edited 1 time in total.

jamie_macdonald
TM-Patrol
TM-Patrol
Posts: 1612
Joined: 10 Jul 2008 19:48
Owned TM-games: TMUF, TMNF, TMS
Manialink(s): ET
Location: London, UK
Contact:

Re: [Xaseco] Vote for game mode ver 1.0 [6.10.2010]

Post by jamie_macdonald » 06 Oct 2010 14:56

Very nice of you to share, very good for "anarchy" based servers :thumbsup:

(i think i may even make use of this myself)

Post Reply