Jump to content

Another question about teleport -markers


Fabio(GNR)

Recommended Posts

I have finally got a teleport command script thanks to varez, but now i would like to make a onmarkerhit teleport,

Since wiki is down, and it isnt in the old version (cache) Can someone explain this to me? This is the command code:

  
function sls (playerSource) 
   local vehicle = getPedOccupiedVehicle(playerSource) 
  if vehicle then 
    setVehicleFrozen(vehicle,true) 
    setElementPosition (vehicle, 1544.2783203125,-1354.1123046875,329.4729309082) 
    setTimer(setVehicleFrozen,50,1,vehicle,false) 
  else 
     setElementPosition (playerSource,  
1544.2783203125,-1354.1123046875,329.4729309082) 
   end 
   outputChatBox ("You Have Been Teleported To Skydive Los Santos Tower!", playerSource, 0, 255, 0) 
 end 
 addCommandHandler ( "sls", sls ) 

i think i should change addcommandhandler to addeventhandler and then something like onmarkerhit ID??

Link to comment
  
-- before you read this comments, scroll down and look BELOW this function 
-- hitElement is element that hit the marker. it can be player, but also empty vehicle, or any other element. 
function sls(hitElement, matchingDimension) 
-- we don't want to teleport emty vehicles etc, so we are checking what hit the marker 
  if getElementType(hitElement)=="player" then -- if the element that hit marker is type of player (notice: players car are hitting this marker almost in same time, but to avoid teleporting empty cars - we are checking if player (driving, or not) hit element - and we are teleporting him and his car (if he is driving)) 
    local veh = getPedOccupiedVehicle(hitElement) 
    if (veh) then -- if player was driving 
      setElementPosition(veh, 0, 0, 0) -- we are teleporting his car - player will be moved with it -- remember to fill the zeros with position 
    else 
      setElementPosition(hitElement, 0, 0, 0) -- we are moving player 
    end 
  end 
end 
  
-- first you need to createMarker 
local myMarker = createMarker(some,parameters) 
-- then attach and event (onMarkerHit) handler to this marker 
addEventHandler("onMarkerHit", myMarker, sls) 
-- 2nd parameter is element that will react and fire sls function 
-- we can put this one marker, or getRootElement() - but all markers will be teleporting and we don't want it. 
  

you can add velocity reset and outputChatBox by yourself

Link to comment
yup

Ok, should it be in the order it is in your post?

EDIT: wooho wiki is back up :P but what is a string?:D

EDIT2 : It worked!!!!! Spawned me at wrong coordinates but thats my fault :D Thanks for helping me with everything :P

EDIT3: (lol) it works, but how do i exactly change the type i did read about it on wiki but when i tried it it says ''expected '')'' near x'' :?

Link to comment
...

EDIT3: (lol) it works, but how do i exactly change the type i did read about it on wiki but when i tried it it says ''expected '')'' near x'' :?

Change type of what? Error message gives you a lot of hints on what if wrong with your code. You've probably forgotten about ")" somewhere, or you have too many of "(".

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