Jump to content

Anyone can help me?


Hero192

Recommended Posts

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

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

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