Jump to content

if check dont work


mjau

Recommended Posts

ehh k now i have one last problem before this is finished

i want the player to be warped to the vehicle who created the marker when the player hit a ccolshape the colshape is there since when i enter it it says bad argument at setelementposition

colshape = createColRectangle (313.0009765625, 1033.708984375, 100, 100) 
colshapeinterior = setElementInterior(colshape, 9) 
  
function createAndroMarker(thePlayer) 
x,y,z = getElementPosition( vehicle ) 
vehicle = getPedOccupiedVehicle(thePlayer) 
theMarker = createMarker ( x - 25, y + 5, z, "cylinder", 20.5, 0, 0, 255, 170 ) 
setTimer ( removeMarker, 4000, 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 
  
function warpPlayerOut() 
setElementPosition(hitElement, x, y, z) 
end 
addEventHandler ( "onColShapeHit", colshape, warpPlayerOut ) 

Link to comment

Here:

colshape = createColRectangle (313.0009765625, 1033.708984375, 100, 100) 
colshapeinterior = setElementInterior(colshape, 9) 
  
function createAndroMarker(thePlayer) 
x,y,z = getElementPosition( vehicle ) 
vehicle = getPedOccupiedVehicle(thePlayer) 
theMarker = createMarker ( x - 25, y + 5, z, "cylinder", 20.5, 0, 0, 255, 170 ) 
setTimer ( removeMarker, 4000, 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 
  
function warpPlayerOut(hitElement) 
if getElementType(hitElement) ~= "player" then return end 
setElementPosition(hitElement, x, y, z) 
end 
addEventHandler ( "onColShapeHit", colshape, warpPlayerOut ) 

Link to comment

That's because you made x, y, z global with the creation position.

Try:

colshape = createColRectangle (313.0009765625, 1033.708984375, 100, 100) 
colshapeinterior = setElementInterior(colshape, 9) 
  
function createAndroMarker(thePlayer) 
local x,y,z = getElementPosition( vehicle ) 
vehicle = getPedOccupiedVehicle(thePlayer) 
theMarker = createMarker ( x - 25, y + 5, z, "cylinder", 20.5, 0, 0, 255, 170 ) 
setTimer ( removeMarker, 4000, 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 
  
function warpPlayerOut(hitElement) 
if getElementType(hitElement) ~= "player" then return end 
local x, y, z = getElementPosition( vehicle ) 
setElementPosition(hitElement, x, y, z) 
end 
addEventHandler ( "onColShapeHit", colshape, warpPlayerOut ) 

Link to comment
function warpPlayerIntoAndro(hitElement, matchingDimension) 
    outputDebugString("Warp function triggered") 
    
    local elementType = getElementType(hitElement) 
    if (elementType == "player") then 
        outputDebugString("hitElement verified as a player!") 
         
        setElementInterior(hitElement, 9, 315.48, 984.13, 1959.11) 
    end  
end 

Tell me if the second Debug string comes up.

EDIT: Lol, sorry didn't see there were 3 pages.. Delete this

Link to comment

Why did you remove if not dimensionMatch then return end? That just checks to make sure the hitElement and the colshape/marker are in the same dimension...

Anyway, try:

  
function warpPlayerIntoAndro(hitElement, dimensionMatch) 
    outputDebugString("Warp function triggered") 
    if not dimensionMatch then return end 
     outputDebugString("dimensionMatch") 
    if getElementType == "player" and not isPedInVehicle(hitElement) then 
          outputDebugString("hitElement is player and player is not in vehicle, warping...") 
        setElementInterior(hitElement, 9, 315.48, 984.13, 1959.11 ) 
    end 
end 
  

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