Author Topic: Show mouse CMD  (Read 1135 times)

Motley

  • Full Member
  • ***
  • Posts: 252
  • Karma: +32/-34
    • View Profile
Show mouse CMD
« on: April 14, 2016, 07: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
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." );
}
}
« Last Edit: April 14, 2016, 08:00:04 pm by Motley »

Theremin

  • Full Member
  • ***
  • Posts: 154
  • Karma: +48/-18
  • Worst Server Owner
    • View Profile
    • Visit my YouTube channel
Re: Show mouse CMD
« Reply #1 on: April 14, 2016, 09: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.

Vortrex

  • Full Member
  • ***
  • Posts: 267
  • Karma: +54/-73
    • View Profile
Re: Show mouse CMD
« Reply #2 on: April 15, 2016, 02:26:07 am »
Maybe something like this would fix that, Theremin?
Code: [Select]
while( IsMouseCursorShowing( ) ) {
ShowMouseCursor( false );
}

Not sure. I haven't tested it.

Motley

  • Full Member
  • ***
  • Posts: 252
  • Karma: +32/-34
    • View Profile
Re: Show mouse CMD
« Reply #3 on: April 15, 2016, 07: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"
« Last Edit: April 15, 2016, 08:08:43 am by Motley »

 

© Liberty Unleashed Team.