PDA

View Full Version : openMenu not working



DjTranceFire
10th November 2013, 22:58
Hey guys..
I'm trying to add a small admin menu to my mod.
I want that its only possible to open the menu for specific guids.
So i created a menu file and changed wm_quickmessage
In _menus.gsc onMenuResponse() i added:



if(response == "admin")
{
if(self getGuid() == 0)
{
self playLocalSound("granted");
self openMenu(game["menu_admin"]);
}
else
{
self iprintlnbold("^1Access Denied!");
self playLocalSound("denied");
}
continue;
}


If i open the menu it plays the sound but it wont open the menu..
I precached the menu and if i open it directly without scriptMenuResponse "admin" everything is working
Whats wrong? :(

Sorry for my bad english! :x

YuriJurek
10th November 2013, 23:24
Try to make sure all other menus are closed, closeMenu(); function would help if you put it before openMenu.

malyczolg
10th November 2013, 23:27
your precache llooks like this?


game["menu_admin"] = "admin";
precacheMenu(game["menu_admin"]);


if yes , error must be on admin.menu
developer 1 and look for errors in the console in admin.menu

need help ?
xf ; czolk

IzNoGoD
11th November 2013, 00:21
you cant open a menu when quickmessage is open. Make sure you have close quickmessage/quickcommands in the execkey in your menu.

DjTranceFire
11th November 2013, 00:54
Try to make sure all other menus are closed, closeMenu(); function would help if you put it before openMenu.


Done!


{
self closeMenu();
self closeInGameMenu();
self openMenu(game["menu_admin"]);
self playLocalSound("granted");
}

Still not working...


your precache llooks like this?


game["menu_admin"] = "admin";
precacheMenu(game["menu_admin"]);


if yes , error must be on admin.menu
developer 1 and look for errors in the console in admin.menu

need help ?
xf ; czolk
The menu is working if i open it from another menu.
It only wont work with _menus.gsc
There are no errors and yes its precached like this! :P


you cant open a menu when quickmessage is open. Make sure you have close quickmessage/quickcommands in the execkey in your menu.

Done.. Still not working.. :(

execKey "8" { close quickmessage; scriptMenuResponse "admin" }

IzNoGoD
11th November 2013, 01:31
Done!

Done.. Still not working.. :(

execKey "8" { close quickmessage; scriptMenuResponse "admin" }

Are you sure the menu you're calling this from is the quickmessage menu?

Also, are you sure the menu is precached? have you checked the client's console for any errors concerning .menu files?

Tally
11th November 2013, 01:54
Why not just use the quickmessage menu to open the admin menu?


execKey "8" { close quickmessage; open admin }

Then, monitor if the admin menu is open:


if( menu == "admin")
{
if(self getGuid() == 0)
{
self playLocalSound("granted");
self openMenu(game["menu_admin"]);
}
else
{
self iprintlnbold("^1Access Denied!");
self playLocalSound("denied");
}

continue;
}


Seems a lot easier than all this messing around trying to get openMenu() to work.

NB - make sure your admin.menu has the menu item name of "admin". The item script name is what the engine looks for. Not the name of the menu file.

DjTranceFire
11th November 2013, 02:25
Are you sure the menu you're calling this from is the quickmessage menu?

Also, are you sure the menu is precached? have you checked the client's console for any errors concerning .menu files?

Yes, its preached and its called from wm_quickmessage.menu
Its working if i use:
execKey "8" { close quickmessage; open admin }
But its not working if i use
execKey "8" { close quickmessage; scriptMenuResponse "admin" }
There are no errors in the console and yes i'm using developer 1


Why not just use the quickmessage menu to open the admin menu?


execKey "8" { close quickmessage; open admin }

Then, monitor if the admin menu is open:


if( menu == "admin")
{
if(self getGuid() == 0)
{
self playLocalSound("granted");
self openMenu(game["menu_admin"]);
}
else
{
self iprintlnbold("^1Access Denied!");
self playLocalSound("denied");
}

continue;
}


Seems a lot easier than all this messing around trying to get openMenu() to work.

NB - make sure your admin.menu has the menu item name of "admin". The item script name is what the engine looks for. Not the name of the menu file.

Of course i could use it like this but i want that it cant be opened if you dont have the right guid.

Tally
11th November 2013, 11:31
Well then, you must be doing something wrong. Post your wm_quickmessage menu, and your admin menu.

PatmanSan
11th November 2013, 14:21
If using a scriptMenuResponse in quickmessage, like this:


execKey "8" { close quickmessage; scriptMenuResponse "admin" }

Check for menu "-1" in _menus.gsc.


if(menu == "-1")
{
if(response == "admin")
{
if(self getGuid() == 0)
{
self playLocalSound("granted");
self openMenu(game["menu_admin"]);
}
else
{
self iprintlnbold("^1Access Denied!");
self playLocalSound("denied");
}
continue;
}
}

I have to add that this is the way it's done in the eXtreme mod, which handles quickmessages slightly different, so your mileage may vary.

Ni3ls
11th November 2013, 15:03
Maybe the menu has an error? Can you post your menu here?

DjTranceFire
11th November 2013, 17:39
If using a scriptMenuResponse in quickmessage, like this:


execKey "8" { close quickmessage; scriptMenuResponse "admin" }

Check for menu "-1" in _menus.gsc.


if(menu == "-1")
{
if(response == "admin")
{
if(self getGuid() == 0)
{
self playLocalSound("granted");
self openMenu(game["menu_admin"]);
}
else
{
self iprintlnbold("^1Access Denied!");
self playLocalSound("denied");
}
continue;
}
}

I have to add that this is the way it's done in the eXtreme mod, which handles quickmessages slightly different, so your mileage may vary.

I tested it but its still the same problem.
It plays the sound but it doesnt open the menu..

wm_quickmessage.menu:
http://pastebin.com/1LUxk242

admin.menu:
http://pastebin.com/t4HhbRjM

As i said.. There cant be any errors in the menu's because if i just open them its working.
Its just not working with openMenu()

Ni3ls
11th November 2013, 18:42
and show ur _menus with the parts we need

DjTranceFire
11th November 2013, 18:45
onMenuResponse()
{
for(;;)
{
self waittill("menuresponse", menu, response);

if(response == "admin")
{
if(self getGuid() == 0)
{
self closeMenu();
self closeInGameMenu();
self openMenu(game["menu_admin"]);
self playLocalSound("granted");
}
else
{
self closeMenu();
self closeInGameMenu();
self iprintlnbold("^1Access Denied!");
self playLocalSound("denied");
}
}

YuriJurek
11th November 2013, 19:00
Another thing you want to try is to play around with wait statements, add one between closing and opening the menu again and make sure the menu is really closed.
In the past I had the same problem and as I remmember I added a wait somewhere, sorry but I've lost my laptop yesterday and can't look up the actual code -.-

serthy
11th November 2013, 20:10
You could try to change the order in your execKey parameter:
instead of closing your menu first and then sending a response, send the menuresponse first.

execKey "8" { scriptMenuResponse "admin"; play "mouse_over"; close quickmessage; }

if a menuresponse occurs with a menu of "-1", as far as i can say from my expirience, in most cases an indicator of a not precached menu.
I also added a debug-sound in the response to see if it is properly triggered. You should also do something like this:

self waittill( "menuresponse" , menu , response );
iPrintLn( "Menu: " + menu + " Response: " + response );

as additional debug.

PatmanSan
11th November 2013, 20:21
...
if a menuresponse occurs with a menu of "-1", as far as i can say from my expirience, in most cases an indicator of a not precached menu.
...

So what you're saying is that _menus::onMenuResponse() was able to get a response from a menu that was not precached?!
Wouldn't that be highly unlikely, if not impossible?

Tally
11th November 2013, 20:21
Ok, to stop this thread becoming too long, I jumped in and did some testing:

1. Using the admin menu you provided, and changing wm_quickmessage.menu's third button to an "admin" button, and using your menu waiter script in maps\mp\gametypes\_menus.gsc:



onMenuResponse()
{

for( ;; )
{
self waittill( "menuresponse", menu, response );

if( response == "admin" )
{
if( self getGuid() == 0 )
{
self closeMenu();
self closeInGameMenu();
self openMenu( "admin" );
}
else
self iprintlnbold( "invalid menu" );

continue;
}

----------- snip --------------



This is what the result I got:

http://www.xfire.com/videos/61626c

2. As you can see, no problem opening the admin menu at all.

3. Conclusion:

You must be doing something wrong somewhere, or something else is preventing the menu opening.

DjTranceFire
11th November 2013, 23:30
Ok, the problem is solved.. :D
The reason for the problem is simple..


you cant open a menu when quickmessage is open. Make sure you have close quickmessage/quickcommands in the execkey in your menu.

Its not about quickmessage or quickcommands...
But i'm using menu files to check the FPS of a player.
To get it working i open it again and again..^^
If i remove this FPS check its working fine! :P
But now i have to get a new way to check the FPS for my custom hud... :'(
Thank you all <3

Tally
11th November 2013, 23:51
Ok, the problem is solved.. :D
The reason for the problem is simple..



Its not about quickmessage or quickcommands...
But i'm using menu files to check the FPS of a player.
To get it working i open it again and again..^^
If i remove this FPS check its working fine! :P
But now i have to get a new way to check the FPS for my custom hud... :'(
Thank you all <3

As I thought - something else was preventing the menu opening.