Jump to content

Click on object


Recommended Posts


I created an object and i want trigger event when player is clicking at this entity. Here is my code:

Server side:

wheelObject = mp.objects.new(mp.joaat('prop_spraygun_01'), wheelPosition,
rotation: 283.08,
alpha: 255,
dimension: player.dimension


mp.events.add('click', (x, y, upOrDown, leftOrRight, relativeX, relativeY, worldPosition, hitEntity) => {
mp.gui.cursor.show(false, true);
const cursorPosition = new mp.Vector3(x, y, 0);
const objectPosition = new mp.Vector3(766.928, -844.155, 0); //position of wheelObject
const result = mp.raycasting.testCapsule(cursorPosition, objectPosition, 10, localPlayer, 16);
if(result != undefined)
mp.gui.chat.push("Entity:" + result.entity);

result.entity return number, but it is not the same value like have the hash of 'wheelObject'.


What function should I use to get hash of entity clicked by player?

Link to comment
Share on other sites

  • 7 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...