[SOLVED] How To Show An Menu Item Only When

How To Show The Menu Item (Like Develop New Game…) ONLY When Player Develops A New Game?
Help pl0x

if (GameManager.company.currentGame)
{
    //add menu item
}

I’m pretty sure that works.

Dam, Again forgot to insert that [quote=“Darkly, post:2, topic:10906”]
GameManager
[/quote]

Thanks, I’ll try.

Oh, Nope.

Cannot read property ‘currentGame’ of undefined

So it is not defined yet…

if(GameManager.company.isCurrentlyDevelopingGame())
{
   //add menu item
}

This should do the job for you ^^

2 Likes

Well either you could do this:

if (GameManager.company && GameManager.company.currentGame)

Now There is Cannot call method ‘isCurrentlyDevelopingGame’ of undefined
Cannot Call…

Hmm that’s weird, since it worked for my custom prices. How do you have it in your code?? Maybe that’s where the problem is.

Now It just don’t want to pop-up.

Oh Wait, it doesn’t pop-up even without that.
Something is wrong…

What kind of menu item are you trying to add?

Something like that:

menuItems.push({
label : “Name”.localize(“menu item”),
action : function () {
Sound.click();
GameManager.resume(true);
var div = $("#Derp");

PS. There is No [quote=“Haxor, post:12, topic:10906”]
GameManager.resume(true);
[/quote]

In Code.

It Was Inspired by Black Bull.
(I Did Not copy it!)

That’s alright, you can take code from the Black Bull part, that wasn’t really a part that took me long to make :smile:

Don’t worry Ive just looked at that “div” Part. I’ve did a basic pop-up (It Did Nothing).
And, It Will not restore energy or something.

But can you maybe PM (or here) post the entire code of the function?? If you still have the error ^^

This is how I’d do it:
(btw I’m no real programmer so my code is ugly)

var oriShowMenu = UI.showContextMenu;
var myShowMenu = function(menuItems, f)
{
	if (GameManager.company.isCurrentlyDevelopingGame()) //thanks dzjengiskhan
	{
		menuItems.push(
		{
			label: "menuitemname",
			action: function()
			{
				//do your stuff
			}
		});
	}
			
	oriShowMenu(menuItems, f);
};
UI.showContextMenu = myShowMenu;

It Works!
It displays only when dev. a game!

I’ll Do My Stuff An I Will see.

See told you you needed to override the original function :wink:

Also @Darkly: [quote=“Darkly, post:17, topic:10906”]
(btw I’m no real programmer so my code is ugly)
[/quote]

No real programmer?? F*** you! You made a multiplayer mod for GDT, that instantly makes you a real programmer :stuck_out_tongue:

2 Likes

And That Code Isn’t ugly!
(It is simpler than @DzjengisKhan’s)