Question 2. how do i make those cool abilitys\functions from quickmessages!?
Answer 2. well im not going to show you how to make a nuke or the terminator by pressing "v42" sorry im not making your mod for you, but im going to give you the right steps to getting there. so first off we need to make the buttons... okay so lets start off by getting the files we need! open up
iw_06.iwd open the folder ui_mp and at the bottom ull find the .menu file named
wm_quickmessage.menu now drag that to your mod your desktop what ever you want just get it out of
iw_06.iwd in there you will see stock buttons that you will see normally ingame okay well right under
Code:
itemDef
{
name "window"
visible 1
rect 16 52 0 0
origin ORIGIN_QUICKMESSAGEWINDOW
forecolor 1 1 1 1
textfont UI_FONT_NORMAL
textscale .24
textaligny 8
text "@QUICKMESSAGE_3_RESPONSES"
decoration
}
execKey "3" { close quickmessage; open quickresponses }
lets add your own button to open your own new menu. so now we should have something like this
Code:
itemDef
{
name "window"
visible 1
rect 16 52 0 0
origin ORIGIN_QUICKMESSAGEWINDOW
forecolor 1 1 1 1
textfont UI_FONT_NORMAL
textscale .24
textaligny 8
text "@QUICKMESSAGE_3_RESPONSES"
decoration
}
execKey "3" { close quickmessage; open quickresponses }
itemDef
{
name "window"
visible 1
rect 16 52 0 0
origin ORIGIN_QUICKMESSAGEWINDOW
forecolor 1 1 1 1
textfont UI_FONT_NORMAL
textscale .24
textaligny 8
text "4. Abilitys"
decoration
}
execKey "4" { close quickmessage; open abilitys }
name it what ever you want, the way i named it will say ingame console unlocalized string da da da dont worry its not a big deal it will not crash your server or mess with anything maybe in the long run i dont know but personally been doing this for ever and never ran into 1 problem with it but if you are worried you can localize it the same way they do it but learn localizing properly somewhere else not here for i dont care and its kinda common sense on how to do it.
now back on topic! we now need to make a new menu named
abilitys now its as simple as make a copy of that
wm_quickmessage.menu rename it to
abilitys.menu and in the file all you need is this.
Code:
#define ORIGIN_QUICKMESSAGETAB 32 224
#define ORIGIN_QUICKMESSAGEWINDOW 32 256
{
menuDef
{
name "abilitys"
visible 0
fullscreen 0
rect 0 0 640 480
focuscolor 1 1 1 1
disablecolor 0 0 0 0
style WINDOW_STYLE_EMPTY
onOpen
{
setDvar cl_bypassMouseInput "1"
}
onClose
{
setDvar cl_bypassMouseInput "0"
}
// WINDOW BACKGROUND
itemDef
{
name "window_background"
visible 1
rect 0 0 224 192
origin ORIGIN_QUICKMESSAGEWINDOW
style WINDOW_STYLE_FILLED
forecolor 1 1 1 1
backcolor 0 0 0 0.7975
decoration
}
// WINDOW LINES
itemDef
{
name "window_lines"
visible 1
rect 3 0 2 187
origin ORIGIN_QUICKMESSAGEWINDOW
style WINDOW_STYLE_FILLED
backcolor 1 1 1 .125
decoration
}
itemDef
{
name "window_lines"
visible 1
rect 219 0 2 187
origin ORIGIN_QUICKMESSAGEWINDOW
style WINDOW_STYLE_FILLED
backcolor 1 1 1 .125
decoration
}
itemDef
{
name "window_lines"
visible 1
rect 5 0 214 2
origin ORIGIN_QUICKMESSAGEWINDOW
style WINDOW_STYLE_FILLED
backcolor 1 1 1 .125
decoration
}
itemDef
{
name "window_lines"
visible 1
rect 3 187 218 2
origin ORIGIN_QUICKMESSAGEWINDOW
style WINDOW_STYLE_FILLED
backcolor 1 1 1 .125
decoration
}
// TITLE
itemDef
{
name "title"
visible 1
rect 0 0 224 32
origin ORIGIN_QUICKMESSAGETAB
style WINDOW_STYLE_FILLED
forecolor 1 1 1 1
backcolor 0 0 0 0.7975
type ITEM_TYPE_TEXT
text "@QUICKMESSAGE_QUICK_MESSAGE"
textfont UI_FONT_NORMAL
textscale .24
textalignx 112
textaligny 24
textalign ITEM_ALIGN_CENTER
decoration
}
itemDef
{
name "title_quickmessage_gray"
visible 1
rect 3 3 218 29
origin ORIGIN_QUICKMESSAGETAB
style WINDOW_STYLE_FILLED
backcolor 1 1 1 .125
decoration
}
itemDef
{
name "window"
visible 1
rect 16 20 0 0
origin ORIGIN_QUICKMESSAGEWINDOW
forecolor 1 1 1 1
textfont UI_FONT_NORMAL
textscale .24
textaligny 8
text "1. Custom Command!"
decoration
}
execKey "1" { scriptMenuResponse "customcommand1"; close abilitys; }
itemDef
{
name "window"
visible 1
rect 16 68 0 0
origin ORIGIN_QUICKMESSAGEWINDOW
forecolor 1 1 1 1
textfont UI_FONT_NORMAL
textscale .24
textaligny 8
text "@QUICKMESSAGE_ESC_EXIT"
decoration
}
}
}
notice i only dummed it down to 1 command and i added
scriptMenuResponse instead of opening a new menu? you dont need to have 1 custom command have as many as u want and can fit but for this example im just showing 1. so now lets put some functionality behind this button and precache the new menu you just made! open
iw_07.iwd go to
maps\mp\gametypes and grab the
_menus.gsc out to your mod or desktop like before just take it out of the
iw_07.iwd. in _menus.gsc is where just about every stock menu is handled. so right off the bat when you open up
_menus.gsc you will see on
line 3 to 11 they're already precaching some stock menus. because im a neat fella lets add our custom menu there. also have you ever experienced the problem where you made this awesome menu but ingame you go to open the menu and you just get a blank screen??? thats caused by 1 to 2 problems. 1 you didnt precache your menu. 2 you might have a small error in your .menu file. you can find the second error in console most the time.
back to the topic! now lets precache you should have something like this
Code:
game["menu_ingame"] = "ingame";
game["menu_abilitys"] = "abilitys";
game["menu_team"] = "team_" + game["allies"] + game["axis"];
game["menu_weapon_allies"] = "weapon_" + game["allies"];
game["menu_weapon_axis"] = "weapon_" + game["axis"];
precacheMenu(game["menu_ingame"]);
precacheMenu(game["menu_abilitys"]);
precacheMenu(game["menu_team"]);
precacheMenu(game["menu_weapon_allies"]);
precacheMenu(game["menu_weapon_axis"]);
okay so now that you have that out of your way lets make some functionality! so now if you scroll down to around line 84 you will see something that should be saying this
Code:
if(response == "endgame")
{
if(level.splitscreen)
level thread [[level.endgameconfirmed]]();
continue;
}
okay now were doing something similar only we are going to look for the response named
"customcommand1" so right under that we can have something like this
Code:
if(response == "endgame")
{
if(level.splitscreen)
level thread [[level.endgameconfirmed]]();
continue;
}
if(response == "customcommand1")
{
iprintlnbold("THAT TICKLES!");
}
now you have just made a button that will open up a new menu by pressing v4, and inside that new menu you made a button that will have functionality behind it to print on your screen saying "THAT TICKLES!"
NOW TIME FOR A BONUS!!!
i know, shocking what could this bonus possibly be!?
well now lets take a look into
_menus.gsc again and lets pretend we did the preaching but we didnt add that functionality for that button just yet. if you scroll down to the bottom of
_menus.gsc you will see something like this
Code:
else if(!level.xenon)
{
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);
}
in there you can add something of your own. now this isnt to important infact you dont even need to do this but... come on lets be neat and keep our codes organized together and easy to find. so instead of adding that functionality inside
_menus.gsc we can have our own little block of functionality inside the file named
_quickmessages.gsc this way our functions are organized when we add more and easyer to find everything. okay so lets start off by adding our own thread in that little block of code something like this
Code:
else if(!level.xenon)
{
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);
else if(menu == game["menu_abilitys"])
maps\mp\gametypes\_quickmessages::abilitys(response);
}
okay now we got that now open that
iw_07.iwd again if you dont have it opened already and go to
maps\mp\gametypes and get that
_quickmessages.gsc out of there! open it up and for me i like to start at the bottom when ever im adding something new to a stock .gsc but thats just me. so now when your scrolling down to that dreadful bottom of the
Code:
_quickmessages.gsc
you may see these things on cases. its just like saying if(response == "rawr") but its more organized and just... better if anyone else can elaborate more on that that would be much appreciated. so were at the bottom lets add our own little casing.
Code:
abilitys(response)
{
switch(response)
{
case "customcommand1":
iprintlnbold("THAT TICKLES!");
break;
default: // not really needed... but im a very better safe then sorry kind of guy
break;
}
}
woohoo! thats all done i just also would like to add that if your button is going to be more then saying "THAT TICKLES" and have a few more lines of code it would be easyer if you make a new thread instead of having it all under case "customcommand1" that way everythings more neat like im always about and just... yeah. that wraps up that question thank you
------------------------
i will be answering more questions later today iv just been awake since 4am and im going out for some dunkin donuts to keep my self awake and i just remembered CSGO should be on the xbox right this sec and im an xbox fan so i must get that
edited on Aug. 22, 2012 05:01 am by liltc64