Jump to content

[Help] Destroy blips attached to a marker..


Scyrix

Recommended Posts

So i tried to make a script which on client click on gui creates 4 markers randomly selected and to those 4 markers i attached a blip which is deleted with marker on markerhit but the problem i'm having is when the client leaves the vehcile it should destroy all markers and blips attached to it but it only destroys markers and 1 blip. I know my code is messy i'm learning tho ;/

Looking forward for any feedback ;/

Miejsca = {
    {-2374.76,848.06,40.26},
    {-2411.90,917.68,45.58},
    {-2503.44,918.54,64.94},
    {-2502.92,899.47,64.90},
}
Miejsca2 = {
    {-2175.37,-42.62,35.31},
    {-2078.89,-1.16,35.32},
    {-2027.23,-51.83,35.37},
    {-2158.88,-6.57,35.32},
}
Miejsca3 = {
    {-2509.17,-109.50,25.62},
    {-2514.50,-190.11,25.15},
    {-2540.79,-144.05,15.88},
    {-2576.06,-142.61,6.54},
}
Miejsca4 = {
    {-1929.75,1189.20,45.45},
    {-1956.40,1189.02,45.45},
    {-2053.97,1193.66,45.46},
    {-2065.96,1161.57,46.66},
}
Miejsca5 = {
    {-2575.85,1148.27,55.73},
    {-2534.61,1141.51,55.73},
    {-2479.18,1141.16,55.73},
    {-2451.32,1139.70,55.73},
}
Miejsca6 = {
    {-2880.85,737.10,29.49},
    {-2863.24,682.77,23.44},
    {-2877.86,797.28,35.74},
    {-2837.11,877.44,44.06},
}
miejscaa = 0
function Rozwoz(plr) 
    if plr == localPlayer then 
        miejscaa = math.random(1,6)
            if miejscaa == 1 then 
                Miejsca = Miejsca
            elseif miejscaa == 2 then 
                Miejsca = Miejsca2
            elseif miejscaa == 3 then
                Miejsca = Miejsca3
            elseif miejscaa == 4 then 
                Miejsca = Miejsca4 
            elseif miejscaa == 5 then 
                Miejsca = Miejsca5
            elseif miejscaa == 6 then 
                Miejsca = Miejsca6
            end 
        end 
        StartPracaa(plr)
    end 
punktyp = 0 
maxpunktyp = 4
markerdelete = createElement("markerusune")


function StartPracaa(plr)
    if plr == localPlayer then 
        for _,v in ipairs(Miejsca) do 
        local blipGroupElement = createElement("blipGroupElement")
        markerPizzaStart = createMarker(v[1],v[2],v[3],"cylinder",3.0,255,255,255)
        blipPizzaStart = createBlipAttachedTo(markerPizzaStart,12)
            setElementParent(blipPizzaStart, blipGroupElement) 
            setElementParent(markerPizzaStart,markerdelete)

        

            addEventHandler("onClientMarkerHit",markerPizzaStart,function(plr)
                if plr == localPlayer then 
                    
                punktyp = punktyp + 1 
                if punktyp < maxpunktyp then
                    outputChatBox("Trwa Oddawanie pizzy..")
                    fadeCamera(false)
                    triggerServerEvent("Freeze",localPlayer,localPlayer)
                    setTimer(function()
                        fadeCamera(true)
                        outputChatBox("Jedz oddaj kolejna pizze")
                        triggerServerEvent("unFreeze",localPlayer,localPlayer)
                    end,5000,1)
                    if isElement(blipGroupElement) then 
                        destroyElement(blipGroupElement) end
                setElementData( localPlayer, 'm', source) 
                usunmarker(hitElement)
                    elseif punktyp == maxpunktyp then 
                        if isElement(blipGroupElement) then 
                            destroyElement(blipGroupElement) end
                        fadeCamera(false)
                        setElementData( localPlayer, 'm', source) 
                        usunmarker(hitElement)
                        triggerServerEvent("Freeze",localPlayer,localPlayer)
                        setTimer(function()
                        outputChatBox("wracaj na baze")
                        fadeCamera(true)
                        triggerServerEvent("unFreeze",localPlayer,localPlayer)
                        end,5000,1)
                    end
                            
                end
            end)
        end 
    end 
end 

function usunmarker(hitElement)
    destroyElement(getElementData(localPlayer, 'm') ) 
end
function guipizza()
    dxDrawImage(10/scale, 0/scale, 1920/scale, 1080/scale, ":AC-Kosiarki/tlop.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
    dxDrawImage(383/scale, 154/scale, 411/scale, 304/scale, ":AC-Kosiarki/logo.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
    exports['yd-gui_system']:customButton('Rozpocznij Prace',799/scale, 457/scale, 323/scale, 167/scale)
    exports['yd-gui_system']:customButton('Zakoncz Prace',799/scale, 624/scale, 323/scale, 167/scale)
    pizzaokno = true
end 
function guiTimer()
    dxDrawText("Trwa zaladunek pizzy , Dostawca skonczy zamowienie za  : "..czas.." sekund", 733, 28, 1143, 128, tocolor(255, 255, 255, 255), 1.00, "default", "center", "top", false, false, false, false, false)
end 

function zakonczprace(plr)
    if plr == localPlayer then 
        triggerServerEvent("ZniszczPojazdPizza",localPlayer,localPlayer)
            destroyElement(markerdelete)
            outputChatBox("zakonczyles\as prace")
        end
    end 

addEventHandler("onClientVehicleExit",resourceRoot,function(plr)
    if plr == localPlayer then 
        zakonczprace(plr)
    end 
end)

 

Edited by Scyrix
Link to comment
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...