Liberty Unleashed

Scripting => Script Help => Topic started by: Motley on April 14, 2016, 06:13:48 pm

Title: Show mouse CMD
Post by: Motley on April 14, 2016, 06:13:48 pm
I really could use some help with a command client side to turn the mouse on and off in one Command, This Is really helpful to me. If someone can help lead me to the correct method that would be appreciated,. This command will have a bind key as well so there is other options.

Fixed weird bug on my part was not related. This should been the wiki version not the version someone added
http://liberty-unleashed.co.uk/LUWiki/Squirrel/Client/Functions/Controls/ShowMouseCursor (http://liberty-unleashed.co.uk/LUWiki/Squirrel/Client/Functions/Controls/ShowMouseCursor)
Code: [Select]
function onClientCommand(cmd, text)
{
    if(cmd == "mouse")
    {
          if ( text == "on" )
  {
ShowMouseCursor( true );
Message("Show Mouse Cursor on");
  }
  else if ( text == "off" )
  {
ShowMouseCursor( false );
Message("Show Mouse Cursor off");

  }
  else Message( "You must write /mouse on or /mouse off." );
}
}
Title: Re: Show mouse CMD
Post by: Theremin on April 14, 2016, 08:35:41 pm
I don't get it, does it work for you or not? I tested it and it works as a charm, the only bug I found is: if you set true or false several times then you will have to set the opposite for the same times. E.g. if you type /mouse on two times, then you will have to type /mouse off two times to hide it.
Title: Re: Show mouse CMD
Post by: Vortrex on April 15, 2016, 01:26:07 am
Maybe something like this would fix that, Theremin?
Code: [Select]
while( IsMouseCursorShowing( ) ) {
ShowMouseCursor( false );
}

Not sure. I haven't tested it.
Title: Re: Show mouse CMD
Post by: Motley on April 15, 2016, 06:46:27 am
Yea, so sorry I did fix my problem. Sorry for the late response I was at work.

Vortex is correct as what he suggested is what I used,.

Code: [Select]
function onClientCommand(cmd, text)
{
    if(cmd == "mouse")
    {
          if ( text == "on" )
  {
      while( !IsMouseCursorShowing( ) )
      {
ShowMouseCursor( true );
Message("Show Mouse Cursor on", RED);
      }
  }
  else if ( text == "off" )
  {
      while( IsMouseCursorShowing( ) )
      {
         ShowMouseCursor( false );
Message("Show Mouse Cursor off", RED);
      }
  }
  else Message( "You must write /mouse on or /mouse off." );
    }
}

Sorry if the code moved around,

btw if you want to have the player bind that function in a menu window then i suggest to use this

Code: [Select]
BindKey(KEY_F1, BINDTYPE_DOWN, "onClientCommand", "mouse", "on");
BindKey(KEY_F1, BINDTYPE_UP, "onClientCommand", "mouse", "off");

the objective is to hold it down and when finished release it
"Not needed on scriptload"