Liberty Unleashed
Scripting => Script Help => Topic started 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)
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." );
}
}
-
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.
-
Maybe something like this would fix that, Theremin?
while( IsMouseCursorShowing( ) ) {
ShowMouseCursor( false );
}
Not sure. I haven't tested it.
-
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,.
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
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"