Jump to content

Pizza delivery job [Help]


Leonard.DC

Recommended Posts

Posted

Hi, im making a pizza delivery job for a ROL server, and i need little help to finish it, i was testing with /debugscript 3, but it doesn't say me any error. When i enter to the marker to refill pizzas, nothing happen, and when the job start, i have 0 filled pizzas

Client Side:

local pizzaSkins = { [155]=true; } 
local pizzaVehicles = { [448]=true; }
local pizza_money = 500
local max_pizzas = 8
 
local pizzaLocations =
{
    { 1183.80920, -1259.07385, 15.17969 };
    { 818.37964, -1345.92249, 13.52533 };
    { 609.48016, -1349.53735, 13.77307 };
    { 1222.46191, -1814.00232, 16.59375 };
    { 1719.80371, -1837.48755, 13.55041 };
    { 1894.84570, -1883.25708, 13.47901 };
    { 2121.47607, -2166.66943, 13.54688 };
}
 
function randomHouse ()
    return unpack (pizzaLocations [math.random (#pizzaLocations)])
end
 
    local markerpz = createMarker ( 2110.32104, -1788.62524, 13.56085, "cylinder", 2, 193, 218, 81, 56 )
    local markerpz1 = createMarker ( 1363.36572, 258.25174, 19.56693, "cylinder", 2, 193, 218, 81, 56 )
    local markerpz2 = createMarker ( 2335.77515, 80.98492, 26.48217, "cylinder", 2, 193, 218, 81, 56 )
 
local g_screenX, g_screenY = guiGetScreenSize();
    local gScale = 0.3;
    local gAlphaDistance = 25;
    local gMaxDistance = 50; -- Max Distance
    local gTextAlpha = 120;
    local gTextSize = 1;
    local gAlphaDiff = gMaxDistance - gAlphaDistance;
    gScale = 1 / gScale * 800 / g_screenY;
    local gMaxScaleCurve = { { 0, 0 }, { 3, 3 }, { 13, 5 } };
    local gTextScaleCurve = { { 0, 0.8 }, { 0.8, 1.2 }, { 99, 99 } };
    local gTextAlphaCurve = { { 0, 0 }, { 25, 100 }, { 120, 190 }, { 255, 190 } };
   
    addEventHandler ( 'onClientRender', root,
        function ( )
            --
            local x, y, z = getCameraMatrix();
            local x1, y1, z1 = getElementPosition ( markerpz );
            local x2, y2, z2 = getElementPosition ( markerpz1 );
            local x3, y3, z3 = getElementPosition ( markerpz2 );
            local distance_1 = getDistanceBetweenPoints3D( x, y, z, x1, y1, z1 );
            local distance_2 = getDistanceBetweenPoints3D( x, y, z, x2, y2, z2 );
            local distance_3 = getDistanceBetweenPoints3D( x, y, z, x3, y3, z3 );
            --
            -- Marker #1
            if distance_1 <= gMaxDistance then
                local x1_, y1_ = getScreenFromWorldPosition( x1, y1, z1 + 0.95, 0.06 );
                if x1_ and y1_ then
                    --
                    local scale = 1 / ( gScale * ( distance_1 / gMaxDistance ) );
                    local alpha = ( ( distance_1 - gAlphaDistance ) / gAlphaDiff );
                    alpha = ( alpha < 0 ) and gTextAlpha or gTextAlpha - ( alpha * gTextAlpha );
                    scale = math.evalCurve( gMaxScaleCurve, scale );
                    local textscale = math.evalCurve( gTextScaleCurve, scale );
                    local textalpha = math.evalCurve( gTextAlphaCurve, alpha );
                    --
                    dxDrawText( "*****", x1_, y1_, x1_, y1_, tocolor ( 0, 0, 0, textalpha ), textscale * gTextSize, "arial", "center", "bottom", false, false, false, true );
                end
               
                -- Marker #2
            elseif distance_2 <= gMaxDistance then
                local x2_, y2_ = getScreenFromWorldPosition( x2, y2, z2 + 0.95, 0.06 );
                if x2_ and y2_ then
                    --
                    local scale = 1 / ( gScale * ( distance_2 / gMaxDistance ) );
                    local alpha = ( ( distance_2 - gAlphaDistance ) / gAlphaDiff );
                    alpha = ( alpha < 0 ) and gTextAlpha or gTextAlpha - ( alpha * gTextAlpha );
                    scale = math.evalCurve( gMaxScaleCurve, scale );
                    local textscale = math.evalCurve( gTextScaleCurve, scale );
                    local textalpha = math.evalCurve( gTextAlphaCurve, alpha );
                    --
                    dxDrawText( "******", x2_, y2_, x2_, y2_, tocolor ( 0, 0, 0, textalpha ), textscale * gTextSize, "arial", "center", "bottom", false, false, false, true );
                end
                -- Marker #3
            elseif distance_3 <= gMaxDistance then
                local x3_, y3_ = getScreenFromWorldPosition( x3, y3, z3 + 0.95, 0.06 );
                if x3_ and y3_ then
                --
                    local scale = 1 / ( gScale * ( distance_3 / gMaxDistance ) );
                    local alpha = ( ( distance_3 - gAlphaDistance ) / gAlphaDiff );
                    alpha = ( alpha < 0 ) and gTextAlpha or gTextAlpha - ( alpha * gTextAlpha );
                    scale = math.evalCurve( gMaxScaleCurve, scale );
                    local textscale = math.evalCurve( gTextScaleCurve, scale );
                    local textalpha = math.evalCurve( gTextAlphaCurve, alpha );
                    --
                    dxDrawText( "*********", x3_, y3_, x3_, y3_, tocolor ( 0, 0, 0, textalpha ), textscale * gTextSize, "arial", "center", "bottom", false, false, false, true );
                end
                end
                end
                );
     
    function math.evalCurve( curve, input )
        if input < curve[ 1 ][ 1 ] then
            return curve[ 1 ][ 2 ];
        end
        for idx = 2, #curve do
            if input < curve[ idx ][ 1 ] then
                local x1 = curve[ idx - 1 ][ 1 ];
                local y1 = curve[ idx - 1 ][ 2 ];
                local x2 = curve[ idx ][ 1 ];
                local y2 = curve[ idx ][ 2 ];
                local alpha = ( input - x1 ) / ( x2 - x1 );
                return math.lerp( y1, y2, alpha );
            end
        end
        return curve[ #curve ][ 2 ];
    end
     
    function math.lerp( from, to, alpha )
        return from + ( to-from ) * alpha;
    end
               
                Wnd = guiCreateWindow ( 0.2, 0.2, 0.50, 0.60, "********", true )
guiSetAlpha( Wnd, 1 )
 button = guiCreateButton ( 0.5, 0.8, 0.45, 0.15, "******", true, Wnd )
 button1 = guiCreateButton ( 0.01, 0.8, 0.45, 0.15, "*******", true, Wnd )
label = guiCreateLabel ( 0.05, 0.1, 0.9, 0.2, "********.", true, Wnd )
showCursor(false)
guiSetVisible( Wnd, false )
guiWindowSetSizable( Wnd, false )
guiWindowSetMovable( Wnd, false )
 
    skins =
            {
            {"Repartidor", 155},       
            }
     
    skinG = guiCreateGridList(0.01, 0.3, 0.99, 0.5, true, Wnd)
    guiGridListAddColumn(skinG, "Skin", 0.85)
     
    for i,skins in ipairs(skins) do
         row = guiGridListAddRow(skinG)
         --
         guiGridListSetItemText(skinG, row, 1, tostring(skins[1]), false, false)
         guiGridListSetItemData(skinG, row, 1, tostring(skins[2]))
    end
   
function pizzaJob(hitElement)
             if getElementType(hitElement) == "player" and (hitElement == localPlayer) then
                  if not guiGetVisible(Wnd) then
                       guiSetVisible(Wnd, true)
                       showCursor(true)
                  end
             end
        end
       
    addEventHandler("onClientMarkerHit", markerpz, pizzaJob)
    addEventHandler("onClientMarkerHit", markerpz1, pizzaJob)
    addEventHandler("onClientMarkerHit", markerpz2, pizzaJob)
 
     
    function takeJobPz()
        local row, col = guiGridListGetSelectedItem(skinG)  
        if (row and col and row ~= -1 and col ~= -1) then
            local models = tonumber(guiGridListGetItemData(skinG, row, 1))
            if model ~= "" then
                triggerServerEvent("getJobPz", localPlayer, models)
                guiSetVisible(Wnd,false)
            showCursor(false)
            addEventHandler ("onClientRender", getRootElement(), pzDx)
            setTimer(function() removeEventHandler("onClientRender",getRootElement(),pzDx) end,5000,1)
            end
        end
    end
    addEventHandler("onClientGUIClick", button1, takeJobPz, false)
   
    function pzDx ()
        dxDrawText("*******", 197, 338, 765, 393, tocolor(193, 218, 81, 255), 1.40, "diploma", "left", "top", false, false, true, false, false)
    end
 
   
    function close()
    if (source == button) then
    guiSetVisible(Wnd,false)
    showCursor(false)
    end
    end
    addEventHandler("onClientGUIClick", button, close)
     
    function joinTeam(source)
         triggerServerEvent("setRep", localPlayer, localPlayer)
         guiSetVisible(windowjob, false)
         showCursor(false)
    end
     
    function removeMedicWindow()
         guiSetVisible(windowjob, false)
         showCursor(false)
    end
 
addEventHandler ("onClientVehicleEnter", root,
    function ()
        local pizzadriver = getVehicleController (source)
        if pizzaVehicles [getElementModel (source)] and pizzaSkins [getElementModel (pizzadriver)] then
            if getElementData (source, "pizzajob.pizzas") then
                pizzasLeft = guiCreateLabel  (0.02, 0.7, 5, 5, "*******" .. getElementData (source, "pizzajob.pizzas"), true)
            elseif not getElementData (source, "pizzajob.pizzas") then
                pizzasLeft = guiCreateLabel  (0.02, 0.7, 5, 5, "********", true)
            end
            if not pizzadriver then return end
            outputChatBox ("********", 255, 255, 0, true)
            guiSetFont (pizzasLeft, "default-bold-small")
            guiLabelSetColor (pizzasLeft, 255, 100, 0)
            bindKey ("mouse1", "down", throwPizza, pizzadriver)
            refillPizza = createMarker (2096.6, -1807, 12.5, "cylinder", 3.5, 255, 255, 50, 90, pizzadriver)
            if isElement (pizzaHouse) and isElement (pizzaHouseBlip) then return end
            triggerEvent ("startPizzaboy", pizzadriver)
        end
    end
)
 
addEventHandler ("onClientVehicleExit", root,
    function ()
        if pizzaVehicles [getElementModel (source)] and pizzaSkins [getElementModel (localPlayer)] then
            unbindKey ("mouse1", "down", throwPizza)
            if isElement (pizzasLeft) then destroyElement (pizzasLeft) end
            if isElement (refillPizza) then destroyElement (refillPizza) end
            outputChatBox ("*******", 0, 0, 255)
        end
    end
)
 
addEventHandler ("onClientMarkerHit", root,
    function (hitElement)
        if not source == refillPizza then return end
        if hitElement == "player" and isPedInVehicle (hitElement) and pizzaVehicles [getElementModel (getPedOccupiedVehicle (hitElement))] and pizzaSkins [getElementModel (hitElement)] then
            setElementData (getPedOccupiedVehicle (hitElement), "pizzajob.pizzas", tonumber(max_pizzas))
            guiSetText (pizzasLeft, "*********".. getElementData (getPedOccupiedVehicle (hitElement), "pizzajob.pizzas"))
            if not hitElement then return end
            outputChatBox ("********", 193, 218, 81)
        end
    end
)
 
function throwPizza ()
    if not localPlayer then return end
    local playerVehicle = getPedOccupiedVehicle (localPlayer)
    if not playerVehicle then return end
    local pizzaboy = getVehicleController (playerVehicle)
    if not pizzaboy then return end
    local x3, y3, z3 = getElementPosition (pizzaHouse)
    if not x3 then return end
    local x2, y2, z2 = getElementPosition (playerVehicle)
    if not x2 then return end
    if isPedInVehicle (localPlayer) and pizzaVehicles [getElementModel (playerVehicle)] and pizzaSkins [getElementModel (pizzaboy)] and not isTimer (pizzaCooldown) then
        if getElementData (playerVehicle, "pizzajob.pizzas") and getElementData (playerVehicle, "pizzajob.pizzas") > 0 then
            setElementData (playerVehicle, "pizzajob.pizzas", getElementData (playerVehicle, "pizzajob.pizzas") - 1)
           
Posted

Client Side: Line 159 model should be models.

Client Side: Line 229 if hitElement == "player" replace "player" with localPlayer.

And i don't know what these code do in your code.

    function joinTeam(source) 
         triggerServerEvent("setRep", localPlayer, localPlayer) 
         guiSetVisible(windowjob, false) 
         showCursor(false) 
    end 
      
    function removeMedicWindow() 
         guiSetVisible(windowjob, false) 
         showCursor(false) 
    end 

Posted

EPIC FAIL! Sry, I use the one code i was created 1 mouth ago for all the jobs, it is more easy for me, and i make a mistake because my last job is the Medic Job, i will see and try your solution, and i will say it later if it works or not, regards

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