Gandon Posted February 18, 2012 Share Posted February 18, 2012 Here's a script that I've done but the problem is that if the player is in a vehicle then he can't be teleported function Teleport() marker_areabase_gate_in = createMarker(2492.8999023438,2773.3000488281,9.6000003814697,"cylinder",7, 91, 0, 0, 26 ) marker_areabase_gate_out = createMarker(2502.1999511719,2773.3000488281,9.6000003814697,"cylinder",7, 91, 0, 0, 26 ) end addEventHandler ("onResourceStart",resourceRoot,Teleport) function teleport_areabase_gate1(thePlayer, hitElement) local skin = getElementModel (thePlayer) if ( skin == 130 or skin == 160) then if source == marker_areabase_gate_in then setElementPosition ( thePlayer, 2509.3999023438, 2773.5, 11,false) end end end addEventHandler ("onMarkerHit",getRootElement(),teleport_areabase_gate1) function teleport_areabase_gate2(thePlayer, hitElement) local skin = getElementModel (thePlayer) if ( skin == 130 or skin == 160) then if source == marker_areabase_gate_out then setElementPosition ( thePlayer, 2485.6999511719, 2773.5, 11,false) end end end addEventHandler ("onMarkerHit",getRootElement(),teleport_areabase_gate2) Link to comment
drk Posted February 18, 2012 Share Posted February 18, 2012 Maybe because you are setting the player position, not the vehicle? function teleport_areabase_gate1(thePlayer,hitElement) local skin = getElementModel(thePlayer) if skin == 130 or skin == 160 then if source == marker_areabase_gate_in then local vehicle = getPedOccupiedVehicle(thePlayer) if vehicle then setElementPosition(vehicle,2509.3999023438, 2773.5, 11,false) else setElementPosition(thePlayer,2509.3999023438, 2773.5, 11,false) end end end end addEventHandler('onMarkerHit',root,teleport_areabase_gate1) Link to comment
Scooby Posted February 18, 2012 Share Posted February 18, 2012 if u want the player and vehicle to be teleported: function teleport_areabase_gate2(element,dim) if getElementType(element) == "player" and dim then local skin = getElementModel (element) if ( skin == 130 or skin == 160 ) then local vehicle = getPedOccupiedVehicle(element) if vehicle then setElementPosition (vehicle, 2485.6999511719, 2773.5, 11,false) end end end end u can do the same for the other function. Link to comment
Gandon Posted February 18, 2012 Author Share Posted February 18, 2012 Strange both of them doesn't work it only teleport if player is on foot Link to comment
Castillo Posted February 18, 2012 Share Posted February 18, 2012 function Teleport() marker_areabase_gate_in = createMarker(2492.8999023438,2773.3000488281,9.6000003814697,"cylinder",7, 91, 0, 0, 26 ) addEventHandler ("onMarkerHit",marker_areabase_gate_in,teleport_areabase_gate1) marker_areabase_gate_out = createMarker(2502.1999511719,2773.3000488281,9.6000003814697,"cylinder",7, 91, 0, 0, 26 ) addEventHandler ("onMarkerHit",marker_areabase_gate_out,teleport_areabase_gate2) end addEventHandler ("onResourceStart",resourceRoot,Teleport) function teleport_areabase_gate1(hitElement) if (getElementType(hitElement) == "vehicle") then hitPlayer = hitElement skin = getElementModel (getVehicleController(hitPlayer)) elseif (getElementType(hitElement) == "player") then hitPlayer = hitElement local skin = getElementModel (hitPlayer) end if ( skin == 130 or skin == 160) then setElementPosition (hitPlayer, 2509.3999023438, 2773.5, 11,false) end end function teleport_areabase_gate2(hitElement) if (getElementType(hitElement) == "vehicle") then hitPlayer = hitElement skin = getElementModel (getVehicleController(hitPlayer)) elseif (getElementType(hitElement) == "player") then hitPlayer = hitElement skin = getElementModel (hitPlayer) end if ( skin == 130 or skin == 160) then setElementPosition ( hitPlayer, 2485.6999511719, 2773.5, 11,false) end end Link to comment
Kenix Posted February 18, 2012 Share Posted February 18, 2012 local marker_areabase_gate_in = createMarker( 2492.8999023438,2773.3000488281,9.6000003814697,"cylinder",7, 91, 0, 0, 26 ) local marker_areabase_gate_out = createMarker( 2502.1999511719,2773.3000488281,9.6000003814697,"cylinder",7, 91, 0, 0, 26 ) local function teleport( hitElement, dim ) local el if getElementType( hitElement ) == 'player' then el = hitElement elseif getElementType( hitElement ) == 'vehicle' then el = getVehicleController( hitElement ) end local skin = getElementModel( el ) if skin == 130 or skin == 160 then if source == marker_areabase_gate_in then setElementPosition ( hitElement, 2509.3999023438, 2773.5, 11,false ) elseif source == marker_areabase_gate_out then setElementPosition ( hitElement, 2485.6999511719, 2773.5, 11,false ) end end end addEventHandler ( "onMarkerHit",root,teleport ) Updated. Link to comment
Gandon Posted February 18, 2012 Author Share Posted February 18, 2012 Thanks it worked 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