GiMMLi's
Scripting Tutorials
| Adding
a tab menu by TalonHawk |
|
|
TalonHawk's
Adding a menu tutorial!
//W E L C O M E TO T A B M E N U B A S I
C S
//This is like a little model of a a menu
option thing, not for copy/paste. It is a
2 option
//thing that has my weapon option feature
in it and team change menu. In this only
admins can
//change teams, and all players can set
thier gun options:
//This is what is called when you press
TAB.
function Game::menuRequest(%clientId)
{
%curItem = 0;
Client::buildMenu(%clientId,
"Options", "options",
true);
if(%clientId.isAdmin)
{
if(!$matchStarted ||
!$Server::TourneyMode)
{
Client::addMenuItem(%clientId, %curItem++
@ "Change Teams/Observe",
"changeteams");
}
}
Client::addMenuItem(%clientId, %curItem++
@ "Talon: Weapon options",
"weapons");
}
//This is what is called when you press
one of those buttons, the high-level
options on the
//TAB menu.
function processMenuOptions(%clientId,
%option)
if(%opt == "fteamchange")
{
%clientId.ptc = %cl;
//Build menu creates the top part of the
menu that you see, it is basically the
title
//and is required.
Client::buildMenu(%clientId, "Pick a
team:", "FPickTeam",
true);
//addMenuItem creates a option on the
menu. The first letter in the name is
//the key you press to do it.
Client::addMenuItem(%clientId,
"0Observer", -2);
Client::addMenuItem(%clientId,
"1Automatic", -1);
for(%i = 0; %i < getNumTeams(); %i =
%i + 1)
Client::addMenuItem(%clientId, (%i+2) @
getTeamName(%i), %i);
return;
}
if(%opt == "weapons")
{
%theClient =
Client::getOwnedObject(%clientId);
%MG =
Player::getMountedItem(%theClient,$WeaponSlot);
//Build menu creates the top part of the
menu that you see, it is basically the
title
//and is required.
Client::buildMenu(%clientId, "CPU:
"@ %MG @" Weapon
options:","weapons",
true);
if(%MG == "RPG")
{
Client::addMenuItem(%clientId, "1Set
missile to EMP.", "RPG
EMP");
Client::addMenuItem(%clientId, "2Set
missile to Explosive.", "RPG
Explosive");
Client::addMenuItem(%clientId, "3Set
missile to Seeking.", "RPG
Seeking");
}
else if(%MG == "Mortar")
{
Client::addMenuItem(%clientId, "1Set
to Incendiary.", "Mortar
Incendiary");
Client::addMenuItem(%clientId, "2Set
to High Explosive.", "Mortar
Explosive");
Client::addMenuItem(%clientId, "3Set
to EMP Charge.", "Mortar
EMP");
}
return;
}
}
//If you look carfully, you will notice
that way up in Menu Request, after the
weapon options
//thing I had somehting that said
"weapons". Look at this thing's
title: process menu weapons.
//The game automatically does it, it
checks the menu's little name and looks
for a
//processMenu____ for your added menu.
function processMenuweapons(%clientId,
%option)
{
%main = getWord(%option, 0);
%setting = getWord(%option, 1);
if(%main == "RPG")
{
//Do wahtever is needed here - I'm not
showing how I did it
}
if(%main == "Mortar")
{
//Same deal
}
}
//Same deal for the Team change, but
there is no point in actually bothering
to show that.
//You can do more stuff than I showed,
like multi levels and neat features like
kill player
//options for admins and such. |
The
Realm is owned and maintained by {FA}GiMMLi J (c)1999
The
Realm's {FA}Demon logo is sole property of
GiMMLi's Realm any duplication or modifications
of this trade mark are Strictly prohibited.
Violators will be prosecuted!
Tribes
is a trademark of the Dynamix and Sierra Co.
|