Hero192 Posted February 21, 2016 Share Posted February 21, 2016 Well, Basically I am doing a mission inside an "Interior", and want to find a way to check when the player is left the interior that's mean he's on interior 0. The simple check, if getElementInterior(source) then == 0 end doesn't work in my case. So, I used to do this way in below, it print a Mission Passed on the leave, I want it be printed only if the dist is >= 100 meters addEvent("removePlayerAnim",true) addEventHandler("removePlayerAnim", root, function() setPedAnimation(source) _getElementInterior(source, 0) end) function _getElementInterior(element, int) if isElement(element) and getElementType(element) == "player" and int == 0 then timer = setTimer( function() local x, y, z = getElementPosition(element) local px, py, pz = 1199.1300048828, -918.07098388672, 43.124603271484 local dist = getDistanceBetweenPoints3D(x, y, z, px, py, pz) if getElementInterior(element, int) == 0 and dist >= 100 then givePlayerMoney(element, 1000) outputChatBox("Mission Passed", element, 22,22,200) end end,1000,0) end end Link to comment
Hero192 Posted February 22, 2016 Author Share Posted February 22, 2016 Anyone please can give me a hand Link to comment
Tox Posted February 22, 2016 Share Posted February 22, 2016 are you sure event "removePlayerAnim" triggers correctly? you can output a message to make sure it works Link to comment
Hero192 Posted February 22, 2016 Author Share Posted February 22, 2016 It works but I 5old you the problem in my first post Link to comment
tosfera Posted February 22, 2016 Share Posted February 22, 2016 Is the robbery cancelled if the user walks? Or can they just walk where ever they want in the robbery's progress? If you want to do it in a squishy way, you can do something like this; function renderDistanceCheck () if ( robMarker [ localPlayer ] and isElement ( robMarker [ localPlayer ] ) and percent [ localPlayer ] < 100 ) then local x, y, z = getElementPosition ( robMarker [ localPlayer ] ); if ( getDistanceBetweenPoints3D ( x, y, z, getElementPosition ( localPlayer ) ) >= 100 and getElementInterior ( localPlayer ) == 0 ) then -- the player is way too far, cancel the robbery. end end end Make sure to also add this somewhere; addEventHandler ( "onClientRender", getRootElement(), renderDistanceCheck ); Add it when the robbery starts, remove it when the robbery is over or cancelled. (took some info from PMs ) Link to comment
Hero192 Posted February 22, 2016 Author Share Posted February 22, 2016 Thanks alot for everything and for your time @ tosfera, you are really a good man glad to meet you here, I'll test it now and tell you the results Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now