Jump to content

Como coloco para somente o player com a ACL "PF" pegar o veiculo e adicionar um infox com mensagem


Recommended Posts

markerPegar = createMarker(1221.0225830078, -1388.1735839844, 13.442749977112 -1, "cylinder", 1.5, 0,255,0,100)
markerDestruir = createMarker(1223.1115722656, -1388.1994628906, 13.435565948486 -1, "cylinder", 1.5, 255,0,0,100)

 

veh = {}
function pegarVeiculo (source)
    for _, v in ipairs (getElementsByType("player")) do
        if getPedOccupiedVehicle(v) then
            return
        end
        if veh[source] and isElement(veh[source]) then
            destroyElement(veh[source])
        end
        veh[source] = createVehicle(490, 1220.6763916016, -1398.3157958984, 13.185880661011)
        warpPedIntoVehicle(source, veh[source])
    end
end
addEventHandler("onMarkerHit", markerPegar, pegarVeiculo)

function dest (source)
    if veh[source] and isElement(veh[source]) then
    destroyElement (veh[source])
    local name = getPlayerName(source)
end
end
addEventHandler("onMarkerHit", markerDestruir, dest)

function DestroyVeiculo ()
destroyElement (veh[source])
end
addEventHandler ("onPlayerQuit", root, DestroyVeiculo)

 


Link to comment
function pegarVeiculo(hitElement)
    if getElementType(hitElement) == "player" then
        local vehicle = getPedOccupiedVehicle(hitElement)
        if not vehicle then
            local account = getPlayerAccount(hitElement)
            local accountName = getAccountName(account)
            if isObjectInACLGroup("user."..accountName, aclGetGroup("PF")) then
                if isElement(veh[hitElement]) then
                    destroyElement(veh[hitElement])
                end
                veh[hitElement] = createVehicle(490, 1220.6763916016, -1398.3157958984, 13.185880661011)
                warpPedIntoVehicle(hitElement, veh[hitElement])
            else
                outputChatBox("Você não é membro da PF.", hitElement, 255,0,0)
            end
        end
    end
end

Você redefiniu source no seu script, naturalmente em onMarkerHit, source é o próprio elemento marker, e o primeiro parâmetro da função anexada ao evento "onMarkerHit" é o player que de fato entra no marker. Nem sempre source é o player.

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