Jump to content

Marker dont want to teleport vehicle


maffius97

Recommended Posts

franMark1 = createMarker(1762.6, -1813.4, 12.6, "cylinder", 5, 255, 0, 0, 35)
franMark2 = createMarker(1805, -1748.6, 51.5, "cylinder", 5, 255, 0, 0, 115)
 
function teleport(player)
	if (source == franMark1) then
		if is_group(player) or is_admin(player) then
        setElementPosition(player, 1791, -1780, 53)
        setElementFrozen(player, true)
        setTimer(setElementFrozen, 300, 1, player, false)
		elseif isPedInVehicle(player) then
		local vehicle = getPedOccupiedVehicle(player)
		setElementPosition(vehicle, 1791, -1780, 53)
        setElementFrozen(vehicle, true)
        setTimer(setElementFrozen, 300, 1, vehicle, false)
		end
    elseif (source == franMark2) then
        if is_group(player) or is_admin(player) then
		setElementPosition(player, 1775.8, -1821.3, 14.5)
        setElementFrozen(player, true)
        setTimer(setElementFrozen, 300, 1, player, false)
		end
    end
end
addEventHandler("onMarkerHit", root, teleport)

It teleport player without car but dont want to teleport player and vehicle when he is in vehicle. What is wrong?

Edited by maffius97
Link to comment

well at line 10 you wrote  elseif isPedInVehicle(player) then

what if the hitElement you defined as player was a vehicle your asking your script to check that is your vehicle inside your vehicle

would it not be more suitable to use elseif getElementType(player) == "vehicle" then 

something like this

franMark1 = createMarker(1762.6, -1813.4, 12.6, "cylinder", 5, 255, 0, 0, 35)
franMark2 = createMarker(1805, -1748.6, 51.5, "cylinder", 5, 255, 0, 0, 115)
 
function teleport(player)
	if (source == franMark1) then
		
		if is_group(player) or is_admin(player) then
        setElementPosition(player, 1791, -1780, 53)
        setElementFrozen(player, true)
        setTimer(setElementFrozen, 300, 1, player, false)
		elseif getElementType(player) == 'vehicle' then
		  vehiclesit = getVehicleOccupant(player,0)
		  if vehiclesit then
		setElementPosition(player, 1791, -1780, 53)
        setElementFrozen(player, true)
        setTimer(setElementFrozen, 300, 1, player, false)
		end
		end
	
    elseif (source == franMark2) then
        if is_group(player) or is_admin(player) then
		setElementPosition(player, 1775.8, -1821.3, 14.5)
        setElementFrozen(player, true)
        setTimer(setElementFrozen, 300, 1, player, false)
		end
    end
	end

addEventHandler("onMarkerHit", root, teleport)

(not tested)

Link to comment
local franMark1 = createMarker ( 1762.6,-1813.4,12.6,'cylinder',5,255,0,0,35 )
local franMark2 = createMarker ( 1805,-1748.6,51.5,'cylinder',5,255,0,0,115 )
function teleport ( player )
    if ( getElementType ( player ) == 'player' ) then
        local aPlayer = isPedInVehicle ( player ) and getPedOccupiedVehicle ( player ) or player
      if ( source == franMark1 ) then
        if is_group ( player ) or is_admin ( player ) then
            setElementPosition (  aPlayer,1791,-1780,53)
            setElementFrozen ( aPlayer,true )
            setTimer ( setElementFrozen,300,1,aPlayer,false )
        end
    elseif ( source == franMark2 ) then
       if is_group ( player ) or is_admin ( player ) then
            setElementPosition ( aPlayer,1775.8,-1821.3,14.5 )
            setElementFrozen ( aPlayer,true)
            setTimer ( setElementFrozen,300,1,aPlayer,false )
            end
        end
    end
end
addEventHandler ( 'onMarkerHit',root,teleport )

 

Link to comment
local franMark1 = createMarker ( 1762.6,-1813.4,12.6,'cylinder',5,255,0,0,35 )
local franMark2 = createMarker ( 1805,-1748.6,51.5,'cylinder',5,255,0,0,115 )

function teleport ( player )
    if player and isElement(player) and getElementType ( player ) == 'player' then
        if is_group ( player ) or is_admin ( player ) then
            local aPlayer = isPedInVehicle (player) and getPedOccupiedVehicle (player) or player
            if ( source == franMark1 ) then
                setElementPosition (  aPlayer,1791,-1780,53)
                setElementFrozen ( aPlayer,true )
                setTimer ( setElementFrozen,300,1,aPlayer,false )
            elseif ( source == franMark2 ) then
                setElementPosition ( aPlayer,1775.8,-1821.3,14.5 )
                setElementFrozen ( aPlayer,true)
                setTimer ( setElementFrozen,300,1,aPlayer,false )
            end
        end
    end
end
addEventHandler ('onMarkerHit',root,teleport)

 

  • Like 1
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...