maffius97 Posted October 9, 2016 Share Posted October 9, 2016 (edited) 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 October 9, 2016 by maffius97 Link to comment
ali Posted October 10, 2016 Share Posted October 10, 2016 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
iPrestege Posted October 10, 2016 Share Posted October 10, 2016 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
Walid Posted October 10, 2016 Share Posted October 10, 2016 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) 1 Link to comment
maffius97 Posted October 10, 2016 Author Share Posted October 10, 2016 Thanks Walid, working. Link to comment
Walid Posted October 10, 2016 Share Posted October 10, 2016 9 minutes ago, maffius97 said: Thanks Walid, working. np 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