Jump to content

if check dont work


mjau

Recommended Posts

hi i have a problem with my code it should not warp the player if he is in a vehicle but it does anyway

heres my code

function warpPlayerIntoAndro(hitElement, dimensionMatch) 
    outputDebugString("Warp function triggered") 
    if not dimensionMatch then return end    
    if getElementType(hitElement) == "vehicle" then  
    cancelEvent() 
    else 
    setElementInterior(hitElement, 9, 315.48, 984.13, 1959.11 ) 
    end 
    end 

Link to comment
function warpPlayerIntoAndro(hitElement, dimensionMatch) 
    outputDebugString("Warp function triggered")  
    if getElementType(hitElement) == "player" then 
    setElementInterior(hitElement, 9, 315.48, 984.13, 1959.11 ) 
    end 
end 

No need for all this, try that.

Link to comment
function warpPlayerIntoAndro(hitElement, dimensionMatch) 
    outputDebugString("Warp function triggered") 
    if getElementType( hitElement ) ~= "player" then return end 
    if isPedInVehicle(hitElement) then return end 
    setElementInterior(hitElement, 9, 315.48, 984.13, 1959.11 ) 
end 

Link to comment

since this is goin to be release on community ill upload the whole code

function createAndroMarker(thePlayer) 
vehicle = getPedOccupiedVehicle(thePlayer) 
x,y,z = getElementPosition( vehicle ) 
theMarker = createMarker ( x, y + 5, z - 2, "cylinder", 20.5, 0, 0, 255, 170 ) 
setTimer ( removeMarker, 7000, 1 ) 
addEventHandler( "onMarkerHit", theMarker, warpPlayerIntoAndro ) 
end 
addCommandHandler("marker", createAndroMarker) 
  
function warpPlayerIntoAndro(hitElement, dimensionMatch) 
    outputDebugString("Warp function triggered") 
    if getElementType(hitElement) ~= "player" then return end 
    if isPedInVehicle(hitElement) then return end 
    setElementInterior(hitElement, 9, 315.48, 984.13, 1959.11 ) 
end 
  
function removeMarker() 
destroyElement ( theMarker ) 
end 

Link to comment
function createAndroMarker(thePlayer) 
vehicle = getPedOccupiedVehicle(thePlayer) 
x,y,z = getElementPosition( vehicle ) 
theMarker = createMarker ( x, y + 5, z, "cylinder", 20.5, 0, 0, 255, 170 ) 
setTimer ( removeMarker, 7000, 1 ) 
addEventHandler( "onMarkerHit", theMarker, warpPlayerIntoAndro ) 
end 
addCommandHandler("marker", createAndroMarker) 
  
function warpPlayerIntoAndro(hitElement, dimensionMatch) 
    outputDebugString("Warp function triggered") 
    if getElementType(hitElement) ~= "player" then return end 
    if isPedInVehicle(hitElement) then removePedFromVehicle(hitElement) end 
    setElementInterior(hitElement, 9, 315.48, 984.13, 1959.11 ) 
end 
  
function removeMarker() 
destroyElement ( theMarker ) 
end 

Try that.

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