Scripting/Squirrel/Client Functions/GUI::GetMousePos: Difference between revisions

From Vice City Multiplayer
Jump to navigation Jump to search
Caution icon
This wiki is using an old backup from 2020
Some information may be old/missing
(Created page with "This function returns mouse position of the player. == Syntax == <pre>GUI.GetMousePos()</pre> == Return type == '''VectorScreen''' == Example == <source lang=squirrel> /*...")
 
 
Line 20: Line 20:


if ( mousePos ) {
if ( mousePos ) {
    /* Send message to player about his mouse position */
    /* Send message about mouse position to local player/self */
Console.Print( "Mouse position - X: "+ mousePos.X +", Y: "+ mousePos.Y );
Console.Print( "Mouse position - X: "+ mousePos.X +", Y: "+ mousePos.Y );
}
}

Latest revision as of 14:27, 2 October 2018

This function returns mouse position of the player.

Syntax

GUI.GetMousePos()

Return type

VectorScreen

Example

/* Player::PlayerDeath is triggered whenever someone die, we are going to use this for the sake of example */
function Player::PlayerDeath( player ) 
{
	/* Check whether the player that just died is local player/self by comparing ID */
	if ( player.ID == World.FindLocalPlayer( ).ID )
	{
		/* Get player's mouse position */
		local mousePos = GUI.GetMousePos( );

		if ( mousePos ) {
		    /* Send message about mouse position to local player/self */
			Console.Print( "Mouse position - X: "+ mousePos.X +", Y: "+ mousePos.Y );
		}
	}
}

Notes

Player::PlayerDeath, World::FindLocalPlayer and Console::Print were used in this example, more info about them in the corresponding pages.