Jump to content

getVehicleOccupant help


kevincouto6

Recommended Posts

Hello, I tried several ways but it is not possible to make time to enter the vehicle, The error that is happening is this

ERROR: GUImission/server.lua:512: Bad argument @ 'getVehicleOccupants'{expected vehicle at argument 1, got nill}

ERROR: GUImission/server.lua:512: Bad argument #1 to "pairs' (table expected, got boolean)

veh6 = {}

 -- Recomendo que evite posições decimais muito grandes. Use só até 3 casas decimais.
localitionveh6 = {
    [1] = {433, 290, 2041, 18.5, 0, 0, 270},
    [2] = {433, 290, 2046, 18.5, 0, 0, 270},
    [3] = {433, 290, 2051, 18.5, 0, 0, 270},
    [4] = {433, 290, 2056, 18.5, 0, 0, 270},
    [5] = {433, 290, 2061, 18.5, 0, 0, 270},
 -- O primeiro, quinto e sexto valor das posições não estão sendo usados. Recomendo que delete-os.
}

i = 1 -- contador global

function inicio6 ()
    if isElement (veh6[client]) then -- Client = localPlayer, somente neste caso.
        destroyElement (veh6[client])
        veh6[client] = nil
    end
    local vx ,vy, vz, vrot = localitionveh6[ i ][ 2 ], localitionveh6[ i ][ 3 ], localitionveh6[ i ][ 4 ], localitionveh6[ i ][ 7 ]
    i = i + 1
    if i > #localitionveh6 then -- se i > 5, então:
        i = 1
    end
    Trabalho = true
    veh6[client] = createVehicle ( 433, vx, vy, vz, 0, 0, vrot )
    setElementVisibleTo (Bfim6, client, true)
    outputChatBox ("#ffff00Drive the veh6icle to the checkpoint. Note: You cannot leave the car during the mission.", client, 0, 0, 0, true)
    
    local counter = 0
    
    setTimer(function(source)
        for seat, player6 in pairs(getVehicleOccupants(veh6[client])) do
            counter = counter + 1
        end
        if counter > 0 then
            outputChatBox ( "Voçê esta no veh6icle", getRootElement(), 255, 255, 255, true )
        else
            outputChatBox ( "Voçê Nao entrou no veiculo a tempo mission failed", getRootElement(), 255, 255, 255, true )
            destroyElement (veh6[source])
    end
        counter = 0
    end, 5000, 1)
    
    local player6 = client
    addEventHandler ( "onvehicleExplode", veh6[client], function ()
        if (veh6[player6]) and isElement(veh6[player6]) then
            destroyElement (source)
            takePlayerMoney ( player6, 5000 )
            setElementVisibleTo ( Bfim6, player6, false )
            outputChatBox("Mission failed, your veh6icle blew up.", player6 , 255, 0, 0)
        end
    end)
end
addEvent ("iniciaJob6", true) -- Cria o evento "iniciaJob e permite que ele seja chamado pelo client.
addEventHandler ("iniciaJob6", getRootElement(), inicio6) -- Executa essa função quando o evento "iniciaJob" for chamado.

 

Edited by kevincouto6
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...