Jump to content

Teleport in car


Mat101

Recommended Posts

Hello, I'm here agian, and i need your help guys, i created lots and lots of teleports, and they working fine but if the ped/player is in car it doesnt work, It says the message that i set example You have been teleported to .. but it doesnt teleport to pos if the player in the car

Oh and i have another question , I just seen this on lots of server.. When a player join it show a image file.. Can someone do it for me? my folder of the pic is img\title.png

Thanks for help :D

Link to comment

Thanks varez for that GUI Tut

Oh and here's the code sorry, this is one of my teleport

  
function aa (source) 
setElementPosition ( source, 384.0750,2541.4612,16.5391) 
outputChatBox ( "You Have Been Teleported To The Old Airport!!", source, 0, 255, 0 ) 
end 
addCommandHandler ( "aa", aa ) 
  

Link to comment
Thanks varez for that GUI Tut

Oh and here's the code sorry, this is one of my teleport

  
function aa (source) 
setElementPosition ( source, 384.0750,2541.4612,16.5391) 
outputChatBox ( "You Have Been Teleported To The Old Airport!!", source, 0, 255, 0 ) 
end 
addCommandHandler ( "aa", aa ) 
  

you got totally wrong, first you need to do getPedOccupiedVehicle then you can teleport it etc, here is the code done and working :P

function aa (source) 
local vehicle = getPedOccupiedVehicle(source)  
if vehicle then 
setElementVelocity(vehicle,0,0,0) 
setElementPosition ( vehicle, 384.0750,2541.4612,16.5391) 
outputChatBox ( "You Have Been Teleported To The Old Airport!!", source, 0, 255, 0 ) 
   end   
end 
addCommandHandler ( "aa", aa ) 

Link to comment

do not name your variables as "source"

and Solid's script will only teleport if you are in car.

fixed version

  
function aa (playerSource) 
  local vehicle = getPedOccupiedVehicle(playerSource)  
  if vehicle then 
    setElementVelocity(vehicle,0,0,0) 
    setElementPosition (vehicle, 384.0750,2541.4612,16.5391) 
  else 
    setElementPosition (playerSource, 384.0750,2541.4612,16.5391) 
  end 
  outputChatBox ("You Have Been Teleported To The Old Airport!!", playerSource, 0, 255, 0) 
end 
addCommandHandler ( "aa", aa ) 
  

Link to comment

setElementVelocity(vehicle,0,0,0) 

should go after

setElementPosition (vehicle, 384.0750,2541.4612,16.5391) 

or:

  
function aa (playerSource) 
   local vehicle = getPedOccupiedVehicle(playerSource) 
  if vehicle then 
    setVehicleFrozen(vehicle,true) 
    setElementPosition (vehicle, 384.0750,2541.4612,16.5391) 
    setTimer(setVehicleFrozen,50,1,vehicle,false) 
  else 
     setElementPosition (playerSource, 384.0750,2541.4612,16.5391) 
   end 
   outputChatBox ("You Have Been Teleported To The Old Airport!!", playerSource, 0, 255, 0) 
 end 
 addCommandHandler ( "aa", aa ) 
  

if there is no syntax error ;)

Link to comment
do not name your variables as "source"

It's fine to name variables "source", as long as function isn't attached to any event. I always use "source" as a variable name for the player element in command functions and that doesn't cause any problems.

Only commands and the functions a handler calls can have source as parameter, although if the function is called from a function that is called by an event it will still pass source in.

addEventHandler( "onPlayerJoin", getRootElement(), 
    function( ) 
        playerJoined( ); 
    end 
) 
  
function playerJoined( ) 
    -- notice the source is not a parameter but it's still passed here 
    outputChatBox( getPlayerName( source ) .. " joined the server." ); 
end 
  

I strongly do NOT recommend using source as parameter because if you can easily forget about the difference between command handlers and event handlers.. Or you may want tu use same function for a command and an event.

Wojak - you are not unfrozing the vehicle anywhere..

...

He is...

setTimer(setVehicleFrozen,50,1,vehicle,false) 

But the interval is too short. You should keep the vehicle frozen until collision is fully loaded.

You can check if collision has loaded with processLineOfSight in client-side script but if you think it'll be too complicated for you to make, then use higher interval value like 1000.

Link to comment
setElementVelocity(vehicle,0,0,0) 

should go after

setElementPosition (vehicle, 384.0750,2541.4612,16.5391) 

or:

  
function aa (playerSource) 
   local vehicle = getPedOccupiedVehicle(playerSource) 
  if vehicle then 
    setVehicleFrozen(vehicle,true) 
    setElementPosition (vehicle, 384.0750,2541.4612,16.5391) 
    setTimer(setVehicleFrozen,50,1,vehicle,false) 
  else 
     setElementPosition (playerSource, 384.0750,2541.4612,16.5391) 
   end 
   outputChatBox ("You Have Been Teleported To The Old Airport!!", playerSource, 0, 255, 0) 
 end 
 addCommandHandler ( "aa", aa ) 
  

if there is no syntax error ;)

Ok Thanks it works but **** keep's comming, Now the teleport works only on /aa .. i do lots of teleports but none of them works only /aa ..

Link to comment
...

Ok Thanks it works but **** keep's comming, Now the teleport works only on /aa .. i do lots of teleports but none of them works only /aa ..

You're doing something wrong.. that's why.

Like what? Should i post one of the teleport that is not working?

Of course... How do you expect us to know your code?

Link to comment
 function aa (playerSource) 
   local vehicle = getPedOccupiedVehicle(playerSource) 
  if vehicle then 
    setVehicleFrozen(vehicle,true) 
    setElementPosition (vehicle, 384.0750,2541.4612,16.5391) 
    setTimer(setVehicleFrozen,500,1,vehicle,false) 
  else 
     setElementPosition (playerSource, 384.0750,2541.4612,16.5391) 
   end 
   outputChatBox ("You Have Been Teleported To The Old Airport!!", playerSource, 0, 255, 0) 
 end 
 addCommandHandler ( "aa", aa ) 
  
  
---- This Command above works fine... 
Now this doesnt work see 
  
function sf (source) 
   local vehicle = getPedOccupiedVehicle(playerSource) 
  if vehicle then 
    setVehicleFrozen(vehicle,true) 
    setElementPosition (vehicle, -2621.7676,1396.3899,7.1016) 
    setTimer(setVehicleFrozen,500,1,vehicle,false) 
  else 
     setElementPosition (playerSource, -2621.7676,1396.3899,7.1016) 
   end 
   outputChatBox ("You Have Been Teleported To San Fierro!!", playerSource, 0, 255, 0) 
end 
addCommandHandler ( "sf", sf ) 

Edit : By the way im getting those warnings in the console

[2010-09-10 13:55:26] WARNING: play\broph.lua:115: Bad argument @ 'getPedOccupiedVehicle'

[2010-09-10 13:55:26] WARNING: play\broph.lua:121: Bad argument @ 'setElementPosition'

[2010-09-10 13:55:28] WARNING: play\broph.lua:115: Bad argument @ 'getPedOccupiedVehicle'

[2010-09-10 13:55:28] WARNING: play\broph.lua:121: Bad argument @ 'setElementPosition'

[2010-09-10 13:55:32] WARNING: play\broph.lua:115: Bad argument @ 'getPedOccupiedVehicle'

[2010-09-10 13:55:32] WARNING: play\broph.lua:121: Bad argument @ 'setElementPosition'

[2010-09-10 13:55:34] WARNING: play\broph.lua:115: Bad argument @ 'getPedOccupiedVehicle'

[2010-09-10 13:55:34] WARNING: play\broph.lua:121: Bad argument @ 'setElementPosition'

[2010-09-10 13:55:39] CHAT: Mat101: sf

[2010-09-10 13:55:40] WARNING: play\broph.lua:115: Bad argument @ 'getPedOccupiedVehicle'

[2010-09-10 13:55:40] WARNING: play\broph.lua:121: Bad argument @ 'setElementPosition'

[2010-09-10 13:55:45] QUIT: Mat101 left the game [Quit]

P.S Im editing broph..

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