Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2019-11-08, 19:41


Kulegg







Wiek: 46
Na forum: 3125 dni
Posty: 283

Piwa: 20

Respekt: 50

Hej,
Gdy pracuje na magazynier i chc? zako?czy? prac? na nim to musze wpisa? /zakoncz.magazynier.
Po wpisaniu tego, blipy(cel?w, czyli marker?w tam gdzie oddajemy skrzynke) znikaj? oraz praca si? zaka?cza, jednak?e tym samym obiekt(skrzynka), kt?ry trzymam po rozpocz?ciu tej pracy, dodany w skrypcie gdy pracujemy aby ta praca wygl?da?a "realistyczniej", nie znika. Ma?o tego, Po umarciu nadal mam t? skrzynk?, i tylko reconnect pomaga.


local startPracy =  createMarker(1788.29, -2056.4712.58"cylinder"1.513313313350)
setElementData(startPracy,"custom44"true)
createBlipAttachedTo(startPracy46)

local punktyOgrodnik = {
{1802.99, -2031.3713.52},
{1787.07, -2024.8313.48},
{1796.59, -2038.0313.53},
{1806.03, -2051.7813.56},
{1788.29, -2044.6113.54},
{1768.58, -2040.6613.53},
{1780.94, -2035.4413.51},
{1779.75, -2071.7913.59},
{1766.35, -2056.1713.59},
{1753.01, -2072.8013.63},
}

x,guiGetScreenSize()
pxpy = (x/1024), (y/768)

local mousePoints = {
{246*px387*py15*px15*px},
{276*px370*py15*px15*px},
{302*px377*py15*px15*px},
{342*px377*py15*px15*px},
{372*px360*py15*px15*px},
{402*px387*py15*px15*px},
{432*px387*py15*px15*px},
{442*px365*py15*px15*px},
{478*px365*py15*px15*px},
{498*px383*py15*px15*px},
{549*px366*py15*px15*px},
{569*px373*py15*px15*px},
{589*px383*py15*px15*px},
{595*px356*py15*px15*px},
{629*px373*py15*px15*px},
{649*px373*py15*px15*px},
{679*px390*py15*px15*px},
{699*px373*py15*px15*px},
{729*px363*py15*px15*px},
{759*px373*py15*px15*px},
{779*px373*py15*px15*px},
}
target=0
addEventHandler("onClientMarkerHit"startPracy, function(h)
    if ~= localPlayer then return end
    if isPedInVehicle(localPlayerthen return end
    setElementData(localPlayer"praca:ogrodnik:gui"true)
    showCursor(true)
end)

function isMouseIn xywidthheight )
    if ( not isCursorShowing( ) ) then
        return false
    end
    local sxsy guiGetScreenSize ( )
    local cxcy getCursorPosition ( )
    local cxcy = ( cx sx ), ( cy sy )
    if ( cx >= and cx <= width ) and ( cy >= and cy <= height then
        return true
    else
        return false
    end
end

setElementData(localPlayer"ogrodnik:zakonczono"false)

function tworzenieMarkera()
    rnd math.random(1#punktyOgrodnik)
    markerRandomowy createMarker(punktyOgrodnik[rnd][1], punktyOgrodnik[rnd][2], punktyOgrodnik[rnd][3], 'corona'1.5)
    blipRandomowy createBlipAttachedTo(markerRandomowy41)
end

        function onRandom(h)
        if ~= localPlayer then return end
        if isPedInVehicle(localPlayerthen return end
            target target+1
            setElementData(localPlayer"ogrodnik:zakonczono"false)
            addEventHandler("onClientRender"root, function()
                if getElementData(localPlayer"ogrodnik:zakonczono"then return end
                dxDrawImage(241*px63*py570*px357*py,"trawa.png")
                dxDrawImage(mousePoints[target][1], mousePoints[target][2], mousePoints[target][3], mousePoints[target][4],"kolo.png")
            end)
            showCursor(true)
            destroyElement(source)
            destroyElement(blipRandomowy)
        end

function gui()
    if not getElementData(localPlayer"praca:ogrodnik:gui") == true then return end
    dxDrawImage(312*px184*py400*px400*py"test.png")
end
addEventHandler("onClientRender"rootgui)

bindKey("mouse1""down", function()
    if not getElementData(localPlayer"praca:ogrodnik:gui") == true then return end
    if isMouseIn(538*px527*py161*px39*pythen
        setElementData(localPlayer"praca:ogrodnik:gui"false)
        showCursor(false)
    end
    if isMouseIn(324*px527*py161*px39*pythen
    if isPedInVehicle(localPlayerthen return end
    if getElementData(localPlayer"praca"then outputChatBox("Posiadasz aktywn? prac?!"25500) return end
        outputChatBox("Rozpoczynasz prac? magazyniera. Aby zako?czy? wpisz /zakoncz.magazynier"100100250)
        setElementData(localPlayer"praca""ogrodnik")
        setElementData(localPlayer"praca:ogrodnik:gui"false)
      --  outputChatBox("* Od??? skrzynk? na p??k?.")
        setPedAnimation localPlayer"CARRY""crry_prtial"1,true )
        local skrzynia createObject(1271000)
        attachElements skrzynialocalPlayer00.80.5)

        showCursor(false)
        tworzenieMarkera()
        addEventHandler("onClientMarkerHit"markerRandomowyonRandom)
    end
end)

function kliki()
    if getElementData(localPlayer"praca") ~= "ogrodnik" then return end
    if isMouseIn(mousePoints[target][1], mousePoints[target][2], mousePoints[target][3], mousePoints[target][4]) then
        target target+1
        if target == #mousePoints then
            if not getElementData(localPlayer"player:premium"then
            triggerServerEvent("hajsOgrodnik"localPlayermath.random(20,50))
            else
            triggerServerEvent("hajsOgrodnik"localPlayermath.random(30,80))
            end
            target 0

            setElementData(localPlayer"ogrodnik:zakonczono"true)
                        destroyElement(skrzynia)
                        setPedAnimation(localPlayerfalse)
                        setElementData(el"praca"false)
            showCursor(false)
            tworzenieMarkera()
            addEventHandler("onClientMarkerHit"markerRandomowyonRandom)
        end
        return
    end
end
bindKey("mouse1""down"kliki)

addCommandHandler("zakoncz.magazynier", function()
    if getElementData(localPlayer"praca") ~= "ogrodnik" then
        outputChatBox("Nie posiadasz aktywnej pracy magazyniera."25500)
        return
    end
    setElementData(localPlayer"praca"nil)
    destroyElement(markerRandomowy)
    destroyElement(blipRandomowy)
        destroyElement(skrzynia)
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-11-08, 19:54


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8


Więcej informacji znajdziesz w Wikipedii MTA:

destroyElement


Musisz u?y? zmiennej globalnej na skrzyni ?eby m?c j? potem usun??.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-11-08, 20:00


Kulegg







Wiek: 46
Na forum: 3125 dni
Posty: 283

Piwa: 20

Respekt: 50

Mam ju? t? funkcj?,

        destroyElement(skrzynia)

na samym dole kodu, jednak?e nadal skrzynka jest widoczna i tylko po reconnect'cie znika.

Zmienna globalnej skrzyni tzn?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-11-08, 21:18


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Musisz usun?? local przy tworzeniu skrzyni, albo zdefiniowa? 'skrzynia' na samym pocz?tku skryptu jako local.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-11-08, 22:20


Kulegg







Wiek: 46
Na forum: 3125 dni
Posty: 283

Piwa: 20

Respekt: 50

Usun??em local z przed "skrzyni" i uda?o si?, po od?o?eniu skrzyni skrzynia znika, lecz gdy od?o?ymy skrzynie to odrazu pojawia si? nast?pny blip, marker itp i to jest normalnie, ale teraz ?e skrzynia znika odrazu po od?o?eniu skrzyni to jest problem bo gdy mamy nastepny marker to nie mamy skrzyni aby wyglada realistycznie.

kod:


local startPracy =  createMarker(1788.29, -2056.4712.58"cylinder"1.513313313350)
setElementData(startPracy,"custom44"true)
createBlipAttachedTo(startPracy46)

local punktyOgrodnik = {
{1802.99, -2031.3713.52},
{1787.07, -2024.8313.48},
{1796.59, -2038.0313.53},
{1806.03, -2051.7813.56},
{1788.29, -2044.6113.54},
{1768.58, -2040.6613.53},
{1780.94, -2035.4413.51},
{1779.75, -2071.7913.59},
{1766.35, -2056.1713.59},
{1753.01, -2072.8013.63},
}

x,guiGetScreenSize()
pxpy = (x/1024), (y/768)

local mousePoints = {
{246*px387*py15*px15*px},
{276*px370*py15*px15*px},
{302*px377*py15*px15*px},
{342*px377*py15*px15*px},
{372*px360*py15*px15*px},
{402*px387*py15*px15*px},
{432*px387*py15*px15*px},
{442*px365*py15*px15*px},
{478*px365*py15*px15*px},
{498*px383*py15*px15*px},
{549*px366*py15*px15*px},
{569*px373*py15*px15*px},
{589*px383*py15*px15*px},
{595*px356*py15*px15*px},
{629*px373*py15*px15*px},
{649*px373*py15*px15*px},
{679*px390*py15*px15*px},
{699*px373*py15*px15*px},
{729*px363*py15*px15*px},
{759*px373*py15*px15*px},
{779*px373*py15*px15*px},
}
target=0
addEventHandler("onClientMarkerHit"startPracy, function(h)
    if ~= localPlayer then return end
    if isPedInVehicle(localPlayerthen return end
    setElementData(localPlayer"praca:ogrodnik:gui"true)
    showCursor(true)
end)

function isMouseIn xywidthheight )
    if ( not isCursorShowing( ) ) then
        return false
    end
    local sxsy guiGetScreenSize ( )
    local cxcy getCursorPosition ( )
    local cxcy = ( cx sx ), ( cy sy )
    if ( cx >= and cx <= width ) and ( cy >= and cy <= height then
        return true
    else
        return false
    end
end

setElementData(localPlayer"ogrodnik:zakonczono"false)

function tworzenieMarkera()
    rnd math.random(1#punktyOgrodnik)
    markerRandomowy createMarker(punktyOgrodnik[rnd][1], punktyOgrodnik[rnd][2], punktyOgrodnik[rnd][3], 'corona'1.5)
    blipRandomowy createBlipAttachedTo(markerRandomowy41)
end

        function onRandom(h)
        if ~= localPlayer then return end
        if isPedInVehicle(localPlayerthen return end
            target target+1
            setElementData(localPlayer"ogrodnik:zakonczono"false)
            addEventHandler("onClientRender"root, function()
                if getElementData(localPlayer"ogrodnik:zakonczono"then return end
                dxDrawImage(241*px63*py570*px357*py,"trawa.png")
                dxDrawImage(mousePoints[target][1], mousePoints[target][2], mousePoints[target][3], mousePoints[target][4],"kolo.png")
            end)
            showCursor(true)
            destroyElement(source)
            destroyElement(blipRandomowy)
        end

function gui()
    if not getElementData(localPlayer"praca:ogrodnik:gui") == true then return end
    dxDrawImage(312*px184*py400*px400*py"test.png")
end
addEventHandler("onClientRender"rootgui)

bindKey("mouse1""down", function()
    if not getElementData(localPlayer"praca:ogrodnik:gui") == true then return end
    if isMouseIn(538*px527*py161*px39*pythen
        setElementData(localPlayer"praca:ogrodnik:gui"false)
        showCursor(false)
    end
    if isMouseIn(324*px527*py161*px39*pythen
    if isPedInVehicle(localPlayerthen return end
    if getElementData(localPlayer"praca"then outputChatBox("Posiadasz aktywn? prac?!"25500) return end
        outputChatBox("Rozpoczynasz prac? magazyniera. Aby zako?czy? wpisz /zakoncz.magazynier"100100250)
        setElementData(localPlayer"praca""ogrodnik")
        setElementData(localPlayer"praca:ogrodnik:gui"false)
      --  outputChatBox("* Od??? skrzynk? na p??k?.")
        setPedAnimation localPlayer"CARRY""crry_prtial"1,true )
        skrzynia createObject(1271000)
        attachElements skrzynialocalPlayer00.80.5)

        showCursor(false)
        tworzenieMarkera()
        addEventHandler("onClientMarkerHit"markerRandomowyonRandom)
    end
end)

function kliki()
    if getElementData(localPlayer"praca") ~= "ogrodnik" then return end
    if isMouseIn(mousePoints[target][1], mousePoints[target][2], mousePoints[target][3], mousePoints[target][4]) then
        target target+1
        if target == #mousePoints then
            if not getElementData(localPlayer"player:premium"then
            triggerServerEvent("hajsOgrodnik"localPlayermath.random(20,50))
            else
            triggerServerEvent("hajsOgrodnik"localPlayermath.random(30,80))
            end
            target 0

            setElementData(localPlayer"ogrodnik:zakonczono"true)
                        destroyElement(skrzynia)
                        setPedAnimation(localPlayerfalse)
                        setElementData(el"praca"false)
            showCursor(false)
            tworzenieMarkera()
            addEventHandler("onClientMarkerHit"markerRandomowyonRandom)
        end
        return
    end
end
bindKey("mouse1""down"kliki)

addCommandHandler("zakoncz.magazynier", function()
    if getElementData(localPlayer"praca") ~= "ogrodnik" then
        outputChatBox("Nie posiadasz aktywnej pracy magazyniera."25500)
        return
    end
    setElementData(localPlayer"praca"nil)
    destroyElement(markerRandomowy)
    destroyElement(blipRandomowy)
        destroyElement(skrzynia)
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-11-08, 22:54


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

No to nie usuwaj skrzyni, kiedy przechodzisz do nast?pnego punktu???
Za to odpowiada ta sama funkcja (destroyElement).
Gdyby? napisa? to sam, to by? si? orientowa? gdzie co jest.

Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
Kulegg
Wysłany: 2019-11-08, 23:12


Kulegg







Wiek: 46
Na forum: 3125 dni
Posty: 283

Piwa: 20

Respekt: 50

Dzi?ki dzia?a, :piwo: dla ciebie za pomoc :)
Chcia?bym umie? tak? prac? napisa? sam xd

Postaw piwo autorowi tego posta
 

 
Tagi: usunięcie :: obiektu(skrzynki) :: zakończeniu :: pracy
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Usunięcie obiektu(skrzynki) po zakończeniu pracy Ten temat jest zablokowany bez możliwości zmiany postów lub pisania odpowiedzi

Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Dodaj temat do Ulubionych
Wersja do druku