Results 1 to 6 of 6

Thread: MODDING : How to make a shop in game.

  1. #1
    Corporal Killer.Pro's Avatar
    Join Date
    Jul 2012
    Location
    belgium
    Posts
    274
    Thanks
    102
    Thanked 213 Times in 141 Posts

    Post MODDING : How to make a shop in game.

    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

    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 }
    right under this code type another code so that it should look 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 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

    Code:
    #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

    Code:
    		{
    			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);
    		}
    here you have to edit it so it'll be like

    Code:
    		{
    			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_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

    Code:
    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

    Code:
    doQuickMessage(soundalias, saytext)
    above this we're going to put our shop script

    Code:
    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

  2. The Following 4 Users Say Thank You to Killer.Pro For This Useful Post:

    2ReaL (11th November 2012),Kangaroo (2nd September 2012),kolafresh (1st July 2013),kung foo man (2nd September 2012)

  3. #2
    Sergeant EvoloZz's Avatar
    Join Date
    Sep 2012
    Location
    Helsinki, Finland
    Posts
    360
    Thanks
    314
    Thanked 167 Times in 120 Posts
    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

  4. #3
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    Quote Originally Posted by EvoloZz View Post
    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.

  5. The Following 2 Users Say Thank You to Tally For This Useful Post:

    2ReaL (11th November 2012),kung foo man (4th November 2012)

  6. #4
    Sergeant EvoloZz's Avatar
    Join Date
    Sep 2012
    Location
    Helsinki, Finland
    Posts
    360
    Thanks
    314
    Thanked 167 Times in 120 Posts
    Quote Originally Posted by Tally View Post
    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

  7. #5
    Corporal Killer.Pro's Avatar
    Join Date
    Jul 2012
    Location
    belgium
    Posts
    274
    Thanks
    102
    Thanked 213 Times in 141 Posts
    Bro i've been busy now a days but i'll tell you everything through teamviewer after 1-2 days
    Please call me Killer.Pro

  8. The Following 2 Users Say Thank You to Killer.Pro For This Useful Post:

    2ReaL (11th November 2012),kung foo man (6th November 2012)

  9. #6
    Private
    Join Date
    Nov 2012
    Location
    Turkey
    Posts
    44
    Thanks
    77
    Thanked 24 Times in 16 Posts
    Thank you for this lots of information ^^

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •