Results 1 to 6 of 6

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

Threaded View

Previous Post Previous Post   Next Post Next Post
  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)

Posting Permissions

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