Quick Chat Menu (Introduction)

Have a question about modding, modelling or skinning? Have a tutorial to post? Post here!

Moderator: Core Staff

Post Reply
Copy-Cat
CJ Wannabe
CJ Wannabe
Posts: 30
Joined: July 1st, 2011, 2:01 am

Quick Chat Menu (Introduction)

Post by Copy-Cat » 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):

Code: Select all

execkey "1" { close quickmessage; open quickcommands }
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):

Code: Select all

execkey "2" { close quickmessage; open quickstatements }
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):

Code: Select all

execkey "3" { close quickmessage; open quickresponses }
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

Code: Select all

execkey "1" { scriptMenuResponse "1"; close quickcommands; }
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.

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();
}
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

Code: Select all

self doQuickMessage(soundalias, saytext);
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.
You do not have the required permissions to view the files attached to this post.

IzNoGoD
CJ Worshipper
CJ Worshipper
Posts: 343
Joined: January 6th, 2009, 8:39 pm
Location: Netherlands/Holland

Re: Quick Chat Menu (Introduction)

Post by IzNoGoD » July 17th, 2011, 8:53 am

You missed the _menus.gsc. This file actually sends the request for a message to quickmessage.gsc.
here:

Code: Select all

 
level thread onPlayerConnect();
}
 
onPlayerConnect()
{
        for(;;)
        {
                level waittill("connecting", player);
                player thread onMenuResponse();
        }
}
 
onMenuResponse()
{
        for(;;)
        {
                self waittill("menuresponse", menu, response);
 
                        if(menu == game["menu_quickcommands"])
                                maps\mp\gametypes\_quickmessages::quickcommands(response);
                        else if(menu == game["menu_quickstatements"])
                                maps\mp\gametypes\_quickmessages::quickstatements(response);
                        else if(menu == game["menu_quickresponses"])
                                maps\mp\gametypes\_quickmessages::quickresponses(response);
                }
        }
}
(shortened version)
Also, the doquickmessage function is also included:

Code: Select all

 
doQuickMessage(soundalias, saytext)
{
        if(self.sessionstate != "playing")
                return;
 
        if(isdefined(level.QuickMessageToAll) && level.QuickMessageToAll)
        {
                self.headiconteam = "none";
                self.headicon = "talkingicon";
 
                self playSound(soundalias);
                self sayAll(saytext);
        }
        else
        {
                if(self.sessionteam == "allies")
                        self.headiconteam = "allies";
                else if(self.sessionteam == "axis")
                        self.headiconteam = "axis";
                
                self.headicon = "talkingicon";
 
                self playSound(soundalias);
                self sayTeam(saytext);
                self pingPlayer();
        }
}
hafe vun

edit: just noticed there is no "self endon("disconnect");" in the onmenuresponse... LOL shitty coding IW
LMGTFY!

Its not a glitch... Its the future!

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Quick Chat Menu (Introduction)

Post by Drofder2004 » July 17th, 2011, 12:28 pm

IzNoGoD wrote:edit: just noticed there is no "self endon("disconnect");" in the onmenuresponse... LOL shitty coding IW
Aye, although no processpr usage would be used a small amount of memory per disconnect is being used. I wonder how many diconnects in one round would be required to get some sort of memory overload :P
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Moustache
CJ Worshipper
CJ Worshipper
Posts: 476
Joined: August 18th, 2008, 9:30 am

Re: Quick Chat Menu (Introduction)

Post by Moustache » July 17th, 2011, 4:52 pm

Drofder2004 wrote:
IzNoGoD wrote:edit: just noticed there is no "self endon("disconnect");" in the onmenuresponse... LOL shitty coding IW
Aye, although no processpr usage would be used a small amount of memory per disconnect is being used. I wonder how many diconnects in one round would be required to get some sort of memory overload :P
Test it with bots when you have nothing to do?

Nekoneko
CJ Fan
CJ Fan
Posts: 170
Joined: April 18th, 2011, 3:48 pm

Re: Quick Chat Menu (Introduction)

Post by Nekoneko » July 17th, 2011, 4:58 pm

What do you want to test there? oO

Moustache
CJ Worshipper
CJ Worshipper
Posts: 476
Joined: August 18th, 2008, 9:30 am

Re: Quick Chat Menu (Introduction)

Post by Moustache » July 17th, 2011, 6:32 pm

Nekoneko wrote:What do you want to test there? oO
You can disconnect a bot?

Nekoneko
CJ Fan
CJ Fan
Posts: 170
Joined: April 18th, 2011, 3:48 pm

Re: Quick Chat Menu (Introduction)

Post by Nekoneko » July 17th, 2011, 6:45 pm

Ah I see.
Would be fun to see xD

Copy-Cat
CJ Wannabe
CJ Wannabe
Posts: 30
Joined: July 1st, 2011, 2:01 am

Re: Quick Chat Menu (Introduction)

Post by Copy-Cat » July 17th, 2011, 8:32 pm

Hi, and thanks to everyone for your responses.
IzNoGoD wrote:You missed the _menus.gsc. This file actually sends the request for a message to quickmessage.gsc.
here:
Which _menus.gsc are you talking about? there are 3 in the \raw\ directory. 2 of which contain the code

Code: Select all

 onmenuResponse()
\raw\maps\mp\_menus.gsc
\raw\maps\mp\gametypes\_menus.gsc
\raw\maps\_menus.gsc

I searched for the quickmessages.gsc and didn't find the one are you talking about. Is it the
\raw\maps\_quickmessages.gsc ?

All the files I talk about in the above Introduction are default files with paths listed somewhere in the /raw directory


Please explain further. Where in the process of the Quick Chat Menu does te _menu.gsc play a part of.
It seems to me to be a declaration of variables that each of the listed menus will yeild to be passed on to the _quickmessages.gsc in its corresponding menu(Response).

I agree with the doquickmessage function is what actually writes to screen to be placed as the final function.

I believe as a basic introduction it's a good start.
I should go into more detail in a new topic "Creating a custom Quick Chat Menu." maybe with Cod Jumper in mind.

What do you guys think?

F |Madness| U
CJ G0D!
CJ G0D!
Posts: 1575
Joined: June 3rd, 2009, 9:02 pm
Location: Cardiff University, UK

Re: Quick Chat Menu (Introduction)

Post by F |Madness| U » July 17th, 2011, 8:56 pm

It would be very helpful. Personally I would like to know what there code is on how to initially open the quickmessage menu (eg. when you press B the quickmessage opens).

Because I tried making my own, but sometimes you have to press the button twice or three times before it will open. If you can share that code I would be thankful.
-

Copy-Cat
CJ Wannabe
CJ Wannabe
Posts: 30
Joined: July 1st, 2011, 2:01 am

Re: Quick Chat Menu (Introduction)

Post by Copy-Cat » July 17th, 2011, 10:48 pm

Sounds awesome! I thought I was the only interested at this current moment on scripting menus.

What I ment by "Creating a custom Quick Chat Menu." maybe with Cod Jumper in mind" is adding to the default quick chat menu an additional menu, not to the codjumper quick chat menu.
The Quick Chat menu will look something like.
1. Quick Commands
2. Quick Statements
3. Quick Responses
4. Common Responses
5. Select Model

Some common reponses will include sound and text to look something like:
1. Please move and let me try.
2. I was here first (LOL)
3. Use RPG.
4. It's a Jump Crouch
5. You took soo long I could have had a smoke and a coke.
6. You on a smoke break?

And a menu to choose your character.

I hope this clarifies any misunderstandings.

Post Reply

Who is online

Users browsing this forum: No registered users and 16 guests