Jump to content

[AJUDA]Bug Sistema De Modos ( Colisão Veiculo )


Recommended Posts

addEventHandler("onClientPlayerVehicleEnter", getRootElement(),
    function(vehicle, seat)
        setVehicleGhost(vehicle, hasDriverGhost(vehicle))
    end
)

addEventHandler("onClientVehicleExit", getRootElement(),
    function(vehicle, seat)
        setVehicleGhost(vehicle, hasDriverGhost(vehicle))
    end
)

function onStreamIn()
    if getElementType(source) ~= "vehicle" then return end
    setVehicleGhost(source, hasDriverGhost(source))
end
addEventHandler("onClientElementStreamIn", root, onStreamIn)
function setVehicleGhost(target, value)
    for _,vehicle in ipairs(getElementsByType("vehicle")) do
        local vehicleGhost = hasDriverGhost(vehicle)
        if isElement(target) and isElement(vehicle) then
            setElementCollidableWith(target, vehicle, not value)
            setElementCollidableWith(vehicle, target, not value)
        end
        if value == false and vehicleGhost == true and isElement(target) and isElement(vehicle) then
            setElementCollidableWith(target, vehicle, not vehicleGhost)
            setElementCollidableWith(vehicle, target, not vehicleGhost)
        end
    end
    for _,player in ipairs(getElementsByType("player")) do
        if isElement(target) and isElement(player) then
            setElementCollidableWith(target, player, not value)
            setElementCollidableWith(player, target, not value)
        end
    end
end

function hasDriverGhost(vehicle)

    if not isElement(vehicle) then return end
    if getElementType(vehicle) ~= "vehicle" then return end

    local driver = getVehicleController(vehicle)
    if ( driver ) then
        if ( getElementData(driver, "Foxim.ModoJogoPassivo") ) then 
            return true 
        end
    end
    return false

end 

Estou Fazendo um sistema de passivo e ativo, quando ele esta no passivo, se o player entrar em um veiculo ele não ira colidir com outros veiculos ate aqui tudo certo

O PROBLEMA é que quando um player entra e sai de um veiculo aleatorio este veiculo recebe sua colisão novamente, assim o player passivo ira colidir com este veiculo
em veiculos que o player não entrou e saiu, esta funcionando normalmente.

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