Fabio(GNR) Posted September 21, 2010 Share Posted September 21, 2010 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
dzek (varez) Posted September 21, 2010 Share Posted September 21, 2010 -- 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
Fabio(GNR) Posted September 21, 2010 Author Share Posted September 21, 2010 you can add velocity reset and outputChatBox by yourself But it has to not teleport any vehicles so i just delete setelementposition (veh..........)? Thanks by the way Link to comment
Fabio(GNR) Posted September 21, 2010 Author Share Posted September 21, 2010 yup Ok, should it be in the order it is in your post? EDIT: wooho wiki is back up but what is a string? EDIT2 : It worked!!!!! Spawned me at wrong coordinates but thats my fault Thanks for helping me with everything 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
50p Posted September 21, 2010 Share Posted September 21, 2010 ...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
dzek (varez) Posted September 22, 2010 Share Posted September 22, 2010 but what is a string? One of type of variables, this one is containing text. There Was wiki page about types i think. maybe string have even its separate page? I don't know, search Link to comment
Fabio(GNR) Posted September 22, 2010 Author Share Posted September 22, 2010 Ok, thanks 50p i ment the cylinder, arrow etc. It works thanks to you guys and the wiki , thanks again! 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