PDA

View Full Version : MODDING : How to make a shop in game.



Killer.Pro
2nd September 2012, 12:35
Hello people,
Now i'm going to show you how to make a shop ingame so that you can buy stuff with money just by pressing V+4
It's not very easy but i'll try to make a easy tutorial
So lets get started
go take main/iw_06.iwd/ui_mp/wm_quickmessage.menu and drag it on your desktop
open it up there you'll see some buttons you see in game for quickmessages like commands,reponses etc.
here we're going to make a new button which will open our shop
Find this button


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 }

right under this code type another code so that it should look something like this


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 68 0 0
origin ORIGIN_QUICKMESSAGEWINDOW
forecolor 1 1 1 1
textfont UI_FONT_NORMAL
textscale .24
textaligny 8
text "4. Shop"
decoration
}
execKey "4" { close quickmessage; open shop }

itemDef
{
name "window"
visible 1
rect 16 148 0 0
origin ORIGIN_QUICKMESSAGEWINDOW
forecolor 1 1 1 1
textfont UI_FONT_NORMAL
textscale .24
textaligny 8
text "@QUICKMESSAGE_ESC_EXIT"
decoration
}

Now this will show the shop text when you press V but nothing will happen when you press 4 because we need to make another menu to open.
So you just save this wm_quickmessage.menu and make a copy of it..rename the copy to shop.menu you'll have to put this file in ui_mp/scriptmenus/,
in shop.menu all you need is this


#include "ui_mp/menudef.h"
#define ORIGIN_QUICKMESSAGETAB 32 224

#define ORIGIN_QUICKMESSAGEWINDOW 32 256


{
menuDef
{
name "shop"
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 "-=^1ShoP^7=-"
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. Max Ammo -=^1 50 $^7=-"
decoration
}
execKey "1" { scriptMenuResponse "1"; close shop; }


itemDef
{
name "window"
visible 1
rect 16 148 0 0
origin ORIGIN_QUICKMESSAGEWINDOW
forecolor 1 1 1 1
textfont UI_FONT_NORMAL
textscale .24
textaligny 8
text "@QUICKMESSAGE_ESC_EXIT"
decoration
}
}
}

For this tutorial i'll show you how to buy max ammo for weapons
now you have to take another file from main , iw_07.iwd/maps/mp/gametypes/_menus.gsc
At the end of this file you'll see


{
if(menu == game["menu_quickcommands"])
maps\mp\gametypes\_quickmessages::quickcommands(re sponse);
else if(menu == game["menu_quickstatements"])
maps\mp\gametypes\_quickmessages::quickstatements( response);
else if(menu == game["menu_quickresponses"])
maps\mp\gametypes\_quickmessages::quickresponses(r esponse);
}

here you have to edit it so it'll be like


{
if(menu == game["menu_quickcommands"])
maps\mp\gametypes\_quickmessages::quickcommands(re sponse);
else if(menu == game["menu_quickstatements"])
maps\mp\gametypes\_quickmessages::quickstatements( response);
else if(menu == game["menu_quickresponses"])
maps\mp\gametypes\_quickmessages::quickresponses(r esponse);
else if(menu == game["menu_shop"])
maps\mp\gametypes\_quickmessages::shop(response);
}

This is where you call the shop menu so lets go and add some maxammo scripting
take maps/mp/gametypes/_quickmessages.gsc from main (iw_07.iwd)
Here we're gonna precache our shop so at the start you'll see other menus precached
here we have to make precache of shop so it should look like this


init()
{
game["menu_quickcommands"] = "quickcommands";
game["menu_quickstatements"] = "quickstatements";
game["menu_quickresponses"] = "quickresponses";
game["menu_shop"] = "shop";

precacheMenu(game["menu_quickcommands"]);
precacheMenu(game["menu_quickstatements"]);
precacheMenu(game["menu_quickresponses"]);
precacheMenu(game["menu_shop"]);
precacheHeadIcon("talkingicon");
}

now all we need to do is make a maxammo script
so find this function


doQuickMessage(soundalias, saytext)

above this we're going to put our shop script


shop(response)
{
switch(response)
{
case "1":

wepcurrent = self getcurrentweapon();


if(self.money >= 50)
{
self.money-=50;
self givemaxammo(wepcurrent);
self iprintlnbold("^1-50");
self iprintlnbold("-=^1Max ammO^7=-");
}

else if(self.money < 50)
{
self iprintlnbold("-=^1Not enough moneY^7=-");
}

break;

}

}

So thats it for shop...try it ingame
Any questions just reply here under

EvoloZz
3rd November 2012, 17:12
Everything works except that "4. Shop" doesnt show on in the quickmenu, but still when i press 4 it will open shop, but then when i want to buy max ammo, it doesnt say that i dont have enough money or anything, it just quits the quickmenu

Tally
4th November 2012, 09:20
Everything works except that "4. Shop" doesnt show on in the quickmenu, but still when i press 4 it will open shop, but then when i want to buy max ammo, it doesnt say that i dont have enough money or anything, it just quits the quickmenu

If an item doesn't show on a menu it is usually because you have an error in the itemDef{}. In this case, it is probably the rectangle. Make sure you increment your "Y" rectangle coordinate by a factor of 16 from the one above it.

EDIT - post your quickmessage menu for us to see, so that we can check it out.

EvoloZz
4th November 2012, 10:42
If an item doesn't show on a menu it is usually because you have an error in the itemDef{}. In this case, it is probably the rectangle. Make sure you increment your "Y" rectangle coordinate by a factor of 16 from the one above it.

EDIT - post your quickmessage menu for us to see, so that we can check it out.

First problem is fixed, but now i still have the second problem

Killer.Pro
6th November 2012, 05:04
Bro i've been busy now a days but i'll tell you everything through teamviewer after 1-2 days :)

2ReaL
11th November 2012, 23:42
Thank you for this lots of information ^^