Results 1 to 9 of 9

Thread: How To Find a Player's Cvar Using a Menu?

  1. #1
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts

    How To Find a Player's Cvar Using a Menu?

    Okay, I have searched but couldn't find anything. I am trying to find a certain cvar for a player using a menu. I thought I knew the method, but so far all I get is zip. Anyone advise me how to do it please?

    So that there are no misunderstandings - this is for COD1. There is no method to detect when a player is ADS in COD1 (there is in UO but not COD1). When a player is ADS, it sets a client dvar "cl_run" to 1. If I can return the dvar value, I can detect if they are ADS.

  2. #2
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    bump characters 250

  3. #3
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    openmenuondvar might do the trick (in your menu), which opens another menu with a scriptmenuresponse. As for cod doesnt detect multiple responses per frame (due to waittill waiting at least one frame), you can add another exec in the original .menu file which will also give a response, would look like:
    Code:
    onopen
    {
     openmenuondvar cl_run 1 menu_run;
     exec "scriptmenuresponse menu_run nope";
    }
    with in your onopen of menu_run:
    Code:
    scriptmenuresponse "yep";
    This will produce either a yep or a nope scriptmenuresponse (you might wanna disable the nope for testing purposes and/or make the second scriptmenuresponse into an execnow instead due to timining issues). Another way to detect this would be to automatically query the cvar using getclientinfo(), a function build into libcod (and codextended afaik)

    Disclaimer: menu files are crappy, thus the syntaxis in the snippets posted here might not be correct. Doing this purely from memory. If you find any errors, please post
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  4. #4
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    Quote Originally Posted by IzNoGoD View Post
    openmenuondvar might do the trick (in your menu), which opens another menu with a scriptmenuresponse. As for cod doesnt detect multiple responses per frame (due to waittill waiting at least one frame), you can add another exec in the original .menu file which will also give a response, would look like:
    Code:
    onopen
    {
     openmenuondvar cl_run 1 menu_run;
     exec "scriptmenuresponse menu_run nope";
    }
    with in your onopen of menu_run:
    Code:
    scriptmenuresponse "yep";
    This will produce either a yep or a nope scriptmenuresponse (you might wanna disable the nope for testing purposes and/or make the second scriptmenuresponse into an execnow instead due to timining issues). Another way to detect this would be to automatically query the cvar using getclientinfo(), a function build into libcod (and codextended afaik)

    Disclaimer: menu files are crappy, thus the syntaxis in the snippets posted here might not be correct. Doing this purely from memory. If you find any errors, please post
    Nope, no openmenuondvar in COD1. Is there another way?

  5. #5
    Sergeant serthy's Avatar
    Join Date
    Nov 2012
    Posts
    450
    Thanks
    96
    Thanked 296 Times in 188 Posts
    If cutom keybinds are possible in CoD1 (onOpen in menu etc.)
    maybe something like this might work:
    bind MOUSE2 "openscriptmenu adsmenu ads;toggle_ads";
    + monitor ads via menuresponse's
    (this requires monitoring weaponswitches, spawning, everything else where ads is triggered...)

    or maybe execondvarvalue exists?
    Last edited by serthy; 28th November 2014 at 15:55.

  6. #6
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    it might be an uiscript openmenuondvar, although im not sure.

    If it doesnt work, you're most likely confined to codextended + getuserinfo + making the cvar readable by the server (which is easy tbh)
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  7. #7
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    Quote Originally Posted by serthy View Post
    If cutom keybinds are possible in CoD1 (onOpen in menu etc.)
    maybe something like this might work:
    bind MOUSE2 "openscriptmenu adsmenu ads;toggle_ads";
    + monitor ads via menuresponse's
    (this requires monitoring weaponswitches, spawning, everything else where ads is triggered...)

    or maybe execondvarvalue exists?
    Nope. custom keybinds are out. No openscriptmenu function. That was invented in COD2. I remember there being a whole hive of activity on the forums about it when we first discovered it, and how it could be exploited.
    Last edited by Tally; 28th November 2014 at 16:58.

  8. #8
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    Quote Originally Posted by IzNoGoD View Post
    it might be an uiscript openmenuondvar, although im not sure.

    If it doesnt work, you're most likely confined to codextended + getuserinfo + making the cvar readable by the server (which is easy tbh)
    Nope. there is NO openmenuondvar. The word "dvar" was not invented then. Not until 2005. And yes: I tried "cvar" instead. COD1 is basically a Quake 3 engine. If you don't find it listed on the Quake 3 resources site, then it isn't in COD1.
    Last edited by Tally; 28th November 2014 at 16:59.

  9. #9
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    Okay, I came at the problem from a different direction and solved it:

    Code:
    attachments()
    {
    	if( self.pers["class"] != "sniper" && self.pers["class"] != "engineer" ) return;
    	
    	// wait until the player model is solid on spawn ( otherwise it will return an invalid player model )
    	wait( 1 );
    	
    	if( !isDefined( self.thumbmarker ) )
    	{		
    		self.thumbmarker = spawn( "script_origin", (0,0,0) );
    		self.thumbmarker linkto( self, "TAG_WEAPON_LEFT", (0,0,0) , (0,0,0) );
    	}
    
    	if( !isDefined( self.headmarker ) )
    	{
    		self.headmarker = spawn( "script_origin", (0,0,0) );
    		self.headmarker linkto( self, "TAG_HELMET", (0,0,0) , (0,0,0) );
    	}
    	
    	self thread MonitorforADS();
    }
    
    /*
    	METHOD TO FIND PLAYER ADS
    	-------------------------
    	Origin of the script_origins is relative to character model's origin. So, when 
    	the arm is raised, the thumbmarker is moving further away and so registers as true.
    */
    MonitorforADS()
    {
    	self endon( "death" );
    	self endon( "disconnect" );
    	
    	self.isADS = undefined;
    	for( ;; )
    	{
    		if( isdefined( self.headmarker ) && isDefined( self.thumbmarker ) )
    		{
    			// check for stance changes because the hud elements flash on while changing
    			while( self getStance() != "stand" )
    			{
    				self perks\_binoculars::cleanBinocularHintHud();
    				wait( 1.75 );
    				continue;
    			}
    				
    			// I can only find a workable distance if the player is standing
    			while( self getStance() == "stand" )
    			{			
    				if( [[level.distance2d]]( self.thumbmarker.origin, self.headmarker.origin ) >= 17 )
    					self.isADS = true;
    				else
    					self.isADS = undefined;
    				
    				wait( 0.05 );
    			}
    		}
    		
    		wait( 0.05 );
    	}
    }
    It's a bit limited. You have to be standing still, standing, and not changing stance. But it does work, and allows me to do what I wanted to accomplish. And as far as I can tell by trawling all the old COD1 mods, I am the first to do it for COD1.

Posting Permissions

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