Jump to content

onClientMarkerHit?


Recommended Posts

Hi, i created a marker and it's small, and whenever I hit it, it gives out some functions, the problem is, it works, but if the marker is below me, it still works.

EX: im in a roof and the marker is inside the building, whenever my position matches with the marker no matter how high up i am, it still triggers the onClientMarkerHit, do i need a col for my marker or theres something wrong.

weapmarker = createMarker(-1519.1829833984, 2587.1801757813, 55.3,"cylinder",1.0,0,255,0,100)

addEventHandler ( "onClientMarkerHit", resourceRoot, 
    function ( hitPlayer ) 
            if ( hitPlayer == localPlayer and getElementType ( hitPlayer ) == "player" ) then 
             if not isPedInVehicle ( hitPlayer ) then
              if (interact == false) then
             interact = true;
            addEventHandler("onClientPreRender", getRootElement(), drawh);
            end
    end
end
end)

 

 

Link to post

 

Get players z position and make a condition

Ex:

local x,y,z = getElementPosition(localPlayer)

if z > 20 then
   return 
end

OBS:  ( the 20 is just an example get your player position in marker and add more o less depending where is your marker )

Edited by Furzy
Link to post
9 hours ago, Shaman123 said:

col for my marker or theres something wrong

Colshapes are more reliable.
 

You could try these functions:

https://wiki.multitheftauto.com/wiki/GetElementColShape < use on marker

https://wiki.multitheftauto.com/wiki/GetColShapeSize

If there is some abnormality in height --> https://wiki.multitheftauto.com/wiki/CreateColTube

(https://forum.mtasa.com/topic/100069-tut-addeventhandler-on-a-group-of-elements-small-tutorial/)

 

Edited by IIYAMA
Link to post

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...