Results 1 to 1 of 1

Thread: [advanced] One menu-item for both the allies and axis zombieshop

  1. #1
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts

    [advanced] One menu-item for both the allies and axis zombieshop

    So, you are here because
    1) You are bored or
    2) because you want to learn how to fix your mod so you only have one item in your quickmessage menu for both teams

    If you are of type 1), you probably have better things to do. Go write your own tutorial for example.

    If you are here because of 2), read on.



    In order to make the menu accessible for both allies AND axis, you can make all items in said menu into cvars. This is a lot of work and requires a lot of cvar-pushing from the server, which is bad.

    So, you create an "in between" menu, which i call "zomshop_open", which is a menu file that opens either the allies or axis menu based on what team you are on (more on that later). This means, contrary to the method where the script catches the menuresponses and makes you open a menu file, your chat window will still be available. Which is nice.

    Now, without further delay, here is the .menu file you need:

    Code:
    #include "ui_mp/menudef.h"
    {
    	menuDef
    	{
    		name			"zomshop_open"
    		rect			0 0 640 480
    		focuscolor		GLOBAL_FOCUSED_COLOR
    		style			WINDOW_STYLE_EMPTY
    		blurWorld		5.0
    		onOpen 
    		{
    			uiScript openMenuOnDvar ui_zomshop_team allies zomshop_allies;
    			uiScript openMenuOnDvar ui_zomshop_team axis zomshop_axis;
    			close zomshop_open;
    		}
    	}
    }
    Closer inspection might result in the conclusion that this menu relies on the cvar "ui_zomshop_team". This is correct.

    You will need to write this cvar every time a player changes team. Best way to do this is to write it on spawn(). I leave it up to the reader to figure this out (hint: self setclientcvar("ui_zomshop_team", self.pers["team"]); ) Also make sure that if your mod does not "sneak past" this function, so dont have any bonus for players to switch teams without passing through spawnplayer();.

    Now, to make this thingy foolproof you also need to protect yourself from zombies buying hunter items and vice-versa. This means you need to check the team of the player and the menu which was called.
    This can easily be done by something like:

    Code:
    	if(menu==game["menu_zomshop_allies"]&&self.pers["team"]!="allies")
    	{
    		self iprintlnbold("You cannot visit the hunter shop at this time");
    		self closemenu();
    		return;
    	}
    	else if(menu==game["menu_zomshop_axis"]&&self.pers["team"]!="axis")
    	{
    		self iprintlnbold("You cannot visit the zombie shop at this time");
    		self closemenu();
    		return;
    	}
    But this I also leave up to the interpretation of the reader.

    Good luck guys

  2. The Following 3 Users Say Thank You to IzNoGoD For This Useful Post:

    kung foo man (26th October 2012),Lonsofore (10th March 2017),STAUFFi (26th October 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
  •