Click: Difference between revisions
CocaColaBear (talk | contribs) (Created page with "This event is triggered when a player use mouse click. ==Parameters== * '''absoluteX: <span style="color:#008017>Number</span>''' * '''absoluteY: <span style="color:#008017>N...") |
mNo edit summary |
||
| (2 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
{{ClientsideCsJsEvent}} | |||
{{CSharpContainer| | |||
<syntaxhighlight lang="c#"> | |||
public delegate void OnClickDelegate(int x, int y, bool up, bool right); | |||
</syntaxhighlight> | |||
{{Parameters}} | |||
* '''x''': x expects, '''System.Int32''' | |||
* '''y''': y expects, '''System.Int32''' | |||
* '''up''': up expects, '''System.Boolean''' | |||
* '''right''': right expects, '''System.Boolean''' | |||
{{Example}} | |||
<syntaxhighlight lang="c#"> | |||
Events.OnClick += OnClick; | |||
</syntaxhighlight> | |||
<syntaxhighlight lang="c#"> | |||
public void OnClick(int x, int y, bool up, bool right) | |||
{ | |||
//Do stuff | |||
} | |||
</syntaxhighlight> | |||
}} | |||
{{JSContainer| | |||
This event is triggered when a player use mouse click. | This event is triggered when a player use mouse click. | ||
{{Parameters}} | |||
* '''absoluteX: | * '''absoluteX''': '''Number''' | ||
* '''absoluteY: | * '''absoluteY''': '''Number''' | ||
* '''upOrDown: | * '''upOrDown''': '''String''' | ||
* '''leftOrRight: | * '''leftOrRight''': '''String''' | ||
* '''relativeX: | * '''relativeX''': '''Number''' | ||
* '''relativeY: | * '''relativeY''': '''Number''' | ||
* '''worldPosition: | * '''worldPosition''': '''Vector3''' | ||
* '''hitEntity: | * '''hitEntity''': '''Number''' | ||
{{Example}} | |||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> | ||
// | mp.events.add('click', (x, y, upOrDown, leftOrRight, relativeX, relativeY, worldPosition, hitEntity) => { | ||
mp.gui.chat.push("Mouse X:" + x + " | Mouse Y:" + y); // Displays mouse position on click. | |||
if (upOrDown == "up") | |||
mp.gui.chat.push("Mouse Clicked Up with " + leftOrRight + " button."); | |||
if (upOrDown == "down") | |||
mp.gui.chat.push("Mouse Clicked Down with " + leftOrRight + " button."); | |||
}); | |||
</syntaxhighlight> | </syntaxhighlight> | ||
}} | |||
==See also== | ==See also== | ||
{{Player_events}} | {{Player_events}} | ||
[[Category:Client-side Event]] | |||
Latest revision as of 11:10, 30 April 2019
Client-Side Event
C# Syntax
public delegate void OnClickDelegate(int x, int y, bool up, bool right);
Parameters
- x: x expects, System.Int32
- y: y expects, System.Int32
- up: up expects, System.Boolean
- right: right expects, System.Boolean
Example
Events.OnClick += OnClick;
public void OnClick(int x, int y, bool up, bool right)
{
//Do stuff
}
JavaScript Syntax
This event is triggered when a player use mouse click.
Parameters
- absoluteX: Number
- absoluteY: Number
- upOrDown: String
- leftOrRight: String
- relativeX: Number
- relativeY: Number
- worldPosition: Vector3
- hitEntity: Number
Example
mp.events.add('click', (x, y, upOrDown, leftOrRight, relativeX, relativeY, worldPosition, hitEntity) => {
mp.gui.chat.push("Mouse X:" + x + " | Mouse Y:" + y); // Displays mouse position on click.
if (upOrDown == "up")
mp.gui.chat.push("Mouse Clicked Up with " + leftOrRight + " button.");
if (upOrDown == "down")
mp.gui.chat.push("Mouse Clicked Down with " + leftOrRight + " button.");
});
See also
Checkpoint
Colshape
Entity
Player
- playerChat
- playerCommand
- playerDamage
- playerDeath
- playerJoin
- playerQuit
- playerReady
- playerSpawn
- playerWeaponChange
Streaming
Vehicle
- playerStartEnterVehicle
- playerEnterVehicle
- playerStartExitVehicle
- playerExitVehicle
- trailerAttached
- vehicleDamage
- vehicleDeath
- vehicleHornToggle
- vehicleSirenToggle