Jump to content

Problem with warpPedIntoVehicle


Recommended Posts

function checkPlayersVehicles() 
    for i, player in ipairs(getElementsByType("player")) do 
        if not isPedInVehicle(player) then 
            warpPedIntoVehicle(player, __playerVehicles[player], 0) 
            outputDebugString("Warping " ..getPlayerName(player).. " into vehicle " ..getVehicleName(__playerVehicles[player])) 
        end 
    end 
end 

warpPedIntoVehicle is just doing nothing.. and the function is in a timer.

Link to comment
function checkPlayersVehicles() 
    for i, player in ipairs(getElementsByType("player")) do 
        if not isPedInVehicle(player) and getElementData(player, "State") == "alive" and isElement(__playerVehicles[player]) then 
            local result = warpPedIntoVehicle(player, __playerVehicles[player], 0) 
            outputDebugString("'warpPedIntoVehicle' player = " ..getPlayerName(player).. ", vehicle = " ..getVehicleName(__playerVehicles[player]).. ", result = " ..tostring(result)) 
        end 
    end 
end 

[2012-03-07 03:47:03] INFO: 'warpPedIntoVehicle' player = ~[ERU]~Feche, vehicle = RC Bandit, result = false 
[2012-03-07 03:47:05] INFO: 'warpPedIntoVehicle' player = ~[ERU]~Feche, vehicle = RC Bandit, result = false 
[2012-03-07 03:47:06] INFO: 'warpPedIntoVehicle' player = ~[ERU]~Feche, vehicle = RC Bandit, result = false 
[2012-03-07 03:47:08] INFO: 'warpPedIntoVehicle' player = ~[ERU]~Feche, vehicle = RC Bandit, result = false 

__playerVehicles[player] it's a variable that creates a vehicle when a player joins

addEventHandler("onPlayerJoin", g_Root, 
    function() 
        __playerVehicles[source] = createVehicle(math.random(400, 611), 0, 0, 2) 
        setElementSyncer(__playerVehicles[source], false) 
    end 
) 

So, there is no reason to return false.. plus I can't get it working.

Link to comment

I dont think you can create a vehicle and then warp ped into the vehicle when using race gamemode, because race has a timer that check player vehicles and removes and puts the players into them when needed. So even if you got it to work, it wont work in the end.

Link to comment
I've tested the code you've posted and it worked fine, I got warped to the vehicle.

Lollllll, so why it isn't working on my private server? It's a Linux VPS, but it doesn't work on my pc either, and it's Windows, so I guess that it isn't an OS problem..

What release is the server that you tested it?

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