Quick Chat Menu (Introduction)
Posted: July 16th, 2011, 10:18 pm
In my ongoing quest to learn sripting I have hopefully understood the basics of how the Quick chat menu works. I wanted to share this with all of you looking into making a custom Quick Chat Menu.
This is just a basic explanation of how the Quick Chat Menu works not how to modify it.
It all starts with this file: raw\ui_mp\wm_quickmessage.menu
This file is what displays the text for the Quick Chat Menu and gives the player 3 choices to choose from; each of these choices executes a set of commands(functions) to close the Quick Chat Menu and run(load) corresponding menu files.
Let's have a quick look at some snippets from this file.
For Quick Commands (choice 1):
When the player presses 1, the code closes the window containing script from the wm_quickmessage.menu and opens(loads) the script from the correspoding menu file raw\ui_mp\scriptmenus\quickcommands.menu
For Quick Statements (choice 2):
When the player presses 2, the code closes the window containing script from the wm_quickmessage.menu and opens(loads) the script from the correspoding menu file raw\ui_mp\scriptmenus\quickstatements.menu
For Quick Responses (choice 3):
When the player presses 3, the code closes the window containing script from the wm_quickmessage.menu and opens(loads) the script from the correspoding menu file raw\ui_mp\scriptmenus\quickresponses.menu
As you can see Each of these choices opens the corresponding menu file.
raw\ui_mp\scriptmenus\quickcommands.menu
raw\ui_mp\scriptmenus\quickstatements.menu
raw\ui_mp\scriptmenus\quickresponses.menu
These menu files contain code to display Menu specific Text, and gives the player 1 of (up to) 8 menu specific choices. Each of these choices executes a set of commands(functions) to set a menu specific scriptMenuResponse and close the menu.
Let's Have a quick look at a snippet from one of these files.
For raw\ui_mp\scriptmenus\quickcommands.menu
When the player presses(selects) "1" from the quickcommands.menu choices, the code sets the scriptMenuResponse to "1" and then closes the quickcommands.menu.
This scriptMenuResponse of "1" is passed to the raw\maps\mp\gametypes\_quickmessages.gsc where the quick command choice "1" will be run thru it's script.
Now let's look at a snippet from the raw\maps\mp\gametypes\_quickmessages.gsc to see what "1" it actually does.
For Quick Commands
We will look for quickcommands(response) within the _quickmessages.gsc because that is the menu we are following in the above code.
scriptMenuReponse "1" is run thru its corresponding quickcommands(response) script and run thru a switch(response) statement until true. Then it will set the variables for soundalias and say text, break to finish the switch statement.
but the party is not over,
the command is what actually executes the sound and text. Finally whew!, that is a lot of stuff.
The _quickmessages.gsc is where all the good stuff happens, where the sound is called and played; where text is actually written on screen for players to read, and has many other usefull capabilites.
This is just a basic explanation of how the Quick Chat Menu works not how to modify it.
It all starts with this file: raw\ui_mp\wm_quickmessage.menu
This file is what displays the text for the Quick Chat Menu and gives the player 3 choices to choose from; each of these choices executes a set of commands(functions) to close the Quick Chat Menu and run(load) corresponding menu files.
Let's have a quick look at some snippets from this file.
For Quick Commands (choice 1):
Code: Select all
execkey "1" { close quickmessage; open quickcommands }
For Quick Statements (choice 2):
Code: Select all
execkey "2" { close quickmessage; open quickstatements }
For Quick Responses (choice 3):
Code: Select all
execkey "3" { close quickmessage; open quickresponses }
As you can see Each of these choices opens the corresponding menu file.
raw\ui_mp\scriptmenus\quickcommands.menu
raw\ui_mp\scriptmenus\quickstatements.menu
raw\ui_mp\scriptmenus\quickresponses.menu
These menu files contain code to display Menu specific Text, and gives the player 1 of (up to) 8 menu specific choices. Each of these choices executes a set of commands(functions) to set a menu specific scriptMenuResponse and close the menu.
Let's Have a quick look at a snippet from one of these files.
For raw\ui_mp\scriptmenus\quickcommands.menu
Code: Select all
execkey "1" { scriptMenuResponse "1"; close quickcommands; }
This scriptMenuResponse of "1" is passed to the raw\maps\mp\gametypes\_quickmessages.gsc where the quick command choice "1" will be run thru it's script.
Now let's look at a snippet from the raw\maps\mp\gametypes\_quickmessages.gsc to see what "1" it actually does.
For Quick Commands
We will look for quickcommands(response) within the _quickmessages.gsc because that is the menu we are following in the above code.
Code: Select all
quickcommands(response)
{
self endon ( "disconnect" );
if(!isdefined(self.pers["team"]) || self.pers["team"] == "spectator" || isdefined(self.spamdelay))
return;
self.spamdelay = true;
switch(response)
{
case "1":
soundalias = "mp_cmd_followme";
saytext = &"QUICKMESSAGE_FOLLOW_ME";
break;
.
.
.
}
self saveHeadIcon();
self doQuickMessage(soundalias, saytext);
wait 2;
self.spamdelay = undefined;
self restoreHeadIcon();
}
but the party is not over,
the command
Code: Select all
self doQuickMessage(soundalias, saytext);
The _quickmessages.gsc is where all the good stuff happens, where the sound is called and played; where text is actually written on screen for players to read, and has many other usefull capabilites.