Jump to content

warpPedIntoVehicle!!


Xwad

Recommended Posts

I added some skins to vehicles so when i try to enter a vehicle i can cuz of the skin. So i decided to make a script that instantly warps the player into the vehicle when the player is trying to enter it. The only problem is that the player does not warp into the car..:/ i got no debugscript

  
  
tanks = { [541]=true,[415]=true,[480]=true,[562]=true,[587]=true } 
  
function enterVehicle ( player, seat, jacked )  
if ( tanks[getElementModel(source)] ) then  
    outputChatBox ( "enter" ) 
        cancelEvent() 
    local x,y,z = getElementPosition(player) 
    local x,y,z = getElementPosition(source) 
        warpPedIntoVehicle ( player, source )  
    end 
end 
addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) 
  
  
  

Link to comment

I think the problem why you cannot warp the player into the vehicle is because the default seat is occupied "seat id 0". So I would make a revision of the occupied seats in the vehicle and then warp the player into a free seat.

getVehicleOccupants 

That's gonna return you a table, just make a "for" and look for the nil value in any of the keys to see any free seat in the vehicle.

Link to comment
  
tanks = { [541]=true,[415]=true,[480]=true,[562]=true,[587]=true } 
  
function enterVehicle ( player, seat, jacked ) 
if ( tanks[getElementModel(source)] ) then 
    outputChatBox ( "enter" ) 
     cancelEvent() 
     warpPedIntoVehicle ( player, source,0 ) 
    end 
end 
addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) 
  

Link to comment
  
  
tanks = { [541]=true,[415]=true,[480]=true,[562]=true,[587]=true } 
  
function enterVehicle ( player, seat, jacked ) 
if ( tanks[getElementModel(source)] ) then 
    outputChatBox ( "enter" ) 
     cancelEvent() 
    setTimer(  warpPedIntoVehicle, 1500, 1, player, source,0 ) 
    end 
end 
addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) 
  

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