Results 1 to 7 of 7

Thread: check the first letter of scriptmenu response

  1. #1
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts

    check the first letter of scriptmenu response

    Hi all,

    Im making some menu with a lot of scriptmenu responses for primary weapon and secondary weapon in the same .menu file
    for all the primary weapons i put a "x" in front of the name. xgreasegun_mp, xkar98k_mp for example. In front of the the secondary weapons I wrote a "z", like zluger_mp and zcolt_mp.
    I want to make a smart weapon function. If name of the response start with a "x" , remove the "x" and use it as self.primary. If it has a "z" in front, remove the "z" and use it as self.secondary.

    How to do this? I dont have any clue at all

  2. #2
    Private First Class
    Join Date
    Oct 2013
    Posts
    219
    Thanks
    56
    Thanked 105 Times in 66 Posts
    PHP Code:
    if(getSubStr(response01) == "x")
    {
        
    newresponse getSubStr(response1response.size);
        return 
    newresponse;

    Last edited by filthy_freak_; 13th July 2015 at 14:14.

  3. The Following User Says Thank You to filthy_freak_ For This Useful Post:

    Ni3ls (13th July 2015)

  4. #3
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    PHP Code:
    if(response[0] == "x")
    {
         return 
    getsubstr(response1);

    For a single char you dont need to use substr
    Substr will work without a third input, itll just go on until the end (might be lighter on cpu, not sure)
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  5. The Following User Says Thank You to IzNoGoD For This Useful Post:

    Ni3ls (13th July 2015)

  6. #4
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    Trying it with playermodels now
    SNIPPET
    Code:
    if(menu == "huntmodel")
    		{
    			if(response == "menuopen")
    			{
    				self setclientcvar("dvar_yourhelmet", self.helmet);
    				self setclientcvar("dvar_yourbody", self.body);
    				self setclientcvar("dvar_yourhead", self.head);
    			}
    			
    			if(response == "playerbody_american_normandy01")
    			{
       				self.body= response;
    				self setclientcvar("dvar_yourbody", self.body);
    					self closeMenu();
    					self closeInGameMenu();
    				self iprintlnbold("body:"+response);
    			}
    It does show the right dvars when I open it. However, when I click on the first model with response "playerbody_american_normandy01" nothing happens.
    huntmodel.menu
    Code:
    		itemDef 
    		{
    			name			"body"
    			visible			1
    			rect			0 0 70 22
    			origin			ORIGIN_CHOICE5
    			forecolor		GLOBAL_UNFOCUSED_COLOR
    			type			ITEM_TYPE_BUTTON
    			text			"^7Normandy ^31"
    			textfont		UI_FONT_NORMAL
    			textscale		.30
    			textstyle		ITEM_TEXTSTYLE_SHADOWED
    			textaligny		20
    			dvartest        	"language"
    			showDvar       		{ "1" }
    			action
    			{
    				play "mouse_click";
    				scriptMenuResponse "playerbody_american_normandy01";
    			}
    			onFocus
    			{
    				play "mouse_over";
    			}
    		}

  7. #5
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    Sorry for double post but else post will be too long
    Code:
    		else if(menu == "huntmodel")
    		{
    
    			self closeMenu();
    			self closeInGameMenu();
    			self iprintlnbold("Response: "+response);
                    }
    Even this is not working, but the menu is loaded with
    Code:
    					self closeMenu();
    					self closeInGameMenu();
    					self openMenu("huntmodel");
    and does open.
    Tested with developer 1, but how to see if there is an error inside the menu?

  8. #6
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Open extended console, check for errors (clientside)(as menus are mostly clientside)
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  9. #7
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    No errors at all

    EDIT: Found the solution. It had another menudef name, so the menu what was called had another name. Thats why menuopen was working (menudef name is huntmodel) and the other not working (menudef name bodies)
    Last edited by Ni3ls; 14th July 2015 at 10:32.

Posting Permissions

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