Game Development Community

Code: Torque Admin System

by Dustin Mullen · 06/19/2008 (6:23 am) · 3 comments

Torque Admin System.

This comes complete with a team indicator, mute options, change team options, kick, ping indicator, PL indicator, and much more.

This resource was originally posted by Daniel Neilsen. I found it to be heavily flawed and I took the time to fix those flaws. Also, the instructions on how to properly implement this where very vague. I'll do to the best of my ability to explain what you need to do in detail.

There are some known issues with this setup that I will be working on myself or totally taking out period.

1. The defaultbinds such as for A do not work in the adminGUI. You have to use your mouse to select the items. I'll be fixing this soon.

2. Missionoptions does not work and will freeze the adminGUI preventing you from playing. It will probably be omitted in a newer release.

3. Some of the options do not allow you to go back to the previous screen or cancel what you want to do if you made a mistake. I'll be fixing that soon.

4. I'm not sure where to put the passwords for the servers. This isn't originally my coding, so I have to figure out what they did and how to fix it.

5. I will be adding the scoreboard into the adminGUI shortly rather than having to press f2 for the scores.
//--------------------------------------------------------------------------------------------------------

Getting Started:

1. Download the zip from this page: http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=2475

DO NOT FOLLOW THE INSTRUCTION IN THE ZIP. FOLLOW THE INSTRUCTIONS HERE.

2. You will need to add this in your main.cs (example/main.cs) like this:
$defaultGame = "starter.fps";
$displayHelp = false;
$userMods = "starter.fps;admin";

2. Go your server init.cs (server/init.cs)

Find this code:
exec("./scripts/commands.cs");
   exec("./scripts/centerPrint.cs");
   exec("./scripts/game.cs");
Then add:
exec("./scripts/admin.cs");
   exec("./scripts/vote.cs");
   exec("./scripts/access.cs");
   exec("./scripts/menu.cs");
   exec("./prefs.cs");
   exec("./scripts/plugin.cs");
3. Go to your Prefs.cs ( starter.fps/server/) and add the following to your file at the bottom:
$TorqueAdminSystem::disablePlugin[changemission_admin] = false;
$TorqueAdminSystem::disablePlugin[changeteam_admin] = false;
$TorqueAdminSystem::disablePlugin[console_admin] = false;
$TorqueAdminSystem::disablePlugin[kickban_admin] = false;
$TorqueAdminSystem::disablePlugin[muteplayer_admin] = false;
$TorqueAdminSystem::disablePlugin[passwordserver_admin] = false;
$TorqueAdminSystem::disablePlugin[personalmute_admin] = false;
$TorqueAdminSystem::disablePlugin[swapteam_admin] = false;
$TorqueAdminSystem::disablePlugin[tournament_admin] = false;
4. Next put the access.cs, admin.cs,menu.cs,plugin.cs, vote.cs, and the admin folder in your in your server/scripts directory.

5. We will need to go to client side. Open up client/init.cs and put in this code under this section :// Client scripts You will need to add it to the bottom:
exec("./ui/adminGameProfiles.cs");
exec("./scripts/messageQuery.cs");
exec("./scripts/clientadmin.cs");

6. Under // Load up the shell GUIs

Add to the bottom:
exec("./ui/adminMenu.gui");
exec("./ui/MessageQueryDlg.gui");

7. Go to the ui folder (starter.fps/client/ui) and add the files admingameprofiles.cs, adminmenu.gui, and messagequerydlg.gui.

8. Open up defaultgameprofiles.cs in the same folder (client/ui) and add this code to the bottom:
new GuiControlProfile ("AdminHudScrollProfile")
{
   opaque = false;
   border = true;
   borderColor = "0 255 0";
   bitmap = "common/ui/darkScroll";
   hasBitmapArray = true;
};

new GuiControlProfile ("AdminHudTextProfile")
{
   opaque = false;
   fillColor = "128 128 128";
   fontColor = "0 255 0";
   border = true;
   borderColor = "0 255 0";
};
9. Put in the clientadmin.cs and the messagequery.cs in your client/scripts folder.

10. Open up client.cs and add the following at the bottom:
function SetKeyMapping(%mapping)
{
	//pop the action maps...
	if ( isObject( moveMap ) )
		moveMap.pop();
	if ( isObject( AdminGuiMap ) )
		AdminGuiMap.pop();
	cursorOff();

	switch$ ( %mapping )
	{
	 case "Admin":
	 	AdminGuiMap.push();
	 	cursorOn();

	 default:
		moveMap.push();
	}

}
11. Open up defaultbind.cs (client/scripts) and add the following to the bottom before the misc section:
//------------------------------------------------------------------------------
// Admin Menu
//------------------------------------------------------------------------------

function toggleAdminMenuGui(%val)
{
	if(%val)
		AdminMenuGui.toggle();
}

function adminGuiData(%keypress)
{
	AdminInputData(%keypress);
}

function adminSubmitVote(%vote)
{
	%vote = %vote $= "" ? false : %vote;
	CommandToServer('IntegrateClientVote', %vote);
}

function adminSubmitYesVote(%val)
{
	if(%val)
		adminSubmitVote(true);
}

function adminSubmitNoVote(%val)
{
	if(%val)
		adminSubmitVote(false);
}
11. Add these to the misc section:
moveMap.bind(keyboard, "F3", "", "toggleAdminMenuGui");
moveMap.bind(keyboard, "insert", "", "adminSubmitYesVote");
moveMap.bind(keyboard, "delete", "", "adminSubmitNoVote");
12. Delete tournament_admin.cs in your (server/scripts/admin) folder.

13. Open up menu.cs (server/scripts) and take out:

This:
"$Server::Tournament && Game.getNumTeams() > 1"

And this:
%this.addAdminMenuItem("Main", 20, 2, "Mission Options", "$Server::Tournament", "AdminMenu.ListMenuData(%client, TournamentMissionOptions);");

13. Start a mission and press f3. Use your mouse to choose an action in the GUI.

14. Have fun.

#1
06/19/2008 (6:55 am)
No Zip... It seems there was an issue with your upload.
#2
06/19/2008 (8:21 am)
Sorry about that, for some reason it won't let me upload the file. It does go through, just it won't appear.

Download the zip from this page: http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=2475
#3
06/19/2008 (10:50 pm)
Alright, thanks.