Jump to content

Script rotas/corrida


Recommended Posts

config = {
    markerInicio = {x, y, z},
}

markers = {
    [1] = {x, y, z},
    [2] = {x, y, z},
}

marker = createMarker(config.markerInicio[1], config.markerInicio[2], config.markerInicio[3], "cylinder", 2.0, 255, 255, 255)

addEventHandler("onMarkerHit", marker, function(source)
    if getPedOccupiedVehicle(source) then
        outputChatBox("Use /corrida para iniciar a corrida")
    end
end)

addCommandHandler("corrida", function(source)
    if isElementWithinMarker(source, marker) then
        setElementPosition(source, x, y, z)
            veh = createVehicle(vehicleID, x, y, z)
                warpPedIntoVehicle(source, veh)
            setElementData(source, "Wolf.Marker", 1)
        criarMarker(source)
    end
end

function criarMarker(element)
    if isElement(element) then
        local number = tonumber((getElementData(element, "Wolf.Marker") or 1))
        local x, y, z = markers[number][1], markers[number][2], markers[number][3]
        markerCheckpoint = createMarker(x, y, z , "checkpoint", 2.0, 255, 255, 255)
addEventHandler("onMarkerHit", markerCheckpoint, function(source)
    if source == element then
        setElementData(source, "Wolf.marker", number +1)
            destroyElement(markerCheckpoint)
                criarMarker(source)
            end
        end)
    end
end

eu gostaria de saber como eu posso checar se os checkpoints acabaram para entregar a recompensa do player po ter finalizado a rota

Link to comment

Here is an idea of how to do it :

local rutas = {
    [1] = {
        {x,y,z},
        {x,y,z}
        ...
    },
    [2] = {
        {x,y,z},
        {x,y,z}
        ...
    }
};

local ruta_markers = {};

addEventHandler('onResourceStart',resourceRoot,function()
    for i,ruta in pairs(rutas)do
        ruta_markers[i] = {};
        for num,data in pairs(ruta)do            
            local m = createMarker(data[1],data[2],data[3],'cylinder',...);
            ruta_markers[i][num] = m;
        end
    end
end)

function setPlayerRoute(player,ruta)
    setElementData(player,"Ruta",ruta);
end

addEventHandler('onMarkerHit',root,function(player)
    local ruta = getElementData(player,'Ruta');
    if(ruta_markers[ruta])then
        ...
    end
end)

 

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