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

Wysłany: 2020-12-26, 00:33


NoNamik







Wiek: 35
Na forum: 2326 dni
Posty: 288
Nick w MP: JestemNoNamem

Piwa: 379

Respekt: 60

Witam nie dziala praca dojenie kr?w kt?r? posiadam z YNE



createBlip (-1427.06,2171.40,50.63,46)
local tloPojazdy = {
{573,-1419.67,2181.15,51.32,2.7,4.4,11.7},
}

for i,v in ipairs(tloPojazdy) do
local vehicle = createVehicle(v[1],v[2],v[3],v[4],v[5],v[6],v[7])
setElementFrozen(vehicle,true)
for i=0,5 do
--setVehicleDoorState(vehicle,i,4)
--setVehiclePanelState ( vehicle, i, 3 )
end
end

local sw,sh = guiGetScreenSize()
local k_j = {}

local elements = {}
-------------------------------------------
function isEventHandlerAdded(sEventName,pElementAttachedTo,func)
    if type(sEventName)=='string' and isElement(pElementAttachedTo) and type(func)=='function' then local aAttachedFunctions = getEventHandlers(sEventName,pElementAttachedTo)
    if type(aAttachedFunctions)=='table' and #aAttachedFunctions > 0 then for i,v in ipairs(aAttachedFunctions) do if v==func then return true end end end
    end return false
end
-------------------------------------------
function checkButtons(pcl)
    if (pcl==localPlayer) then
        for _,v in ipairs(elements) do
            if isElement(v) then
                destroyElement(v)
            end
        end
    end
    if isEventHandlerAdded("onClientRender",root,onRender) then
        removeEventHandler("onClientRender",root,onRender)
    end
    showCursor(false)
end

function showButtons(pcl)
    if (pcl==localPlayer) then
        checkButtons(pcl)
        showCursor(true)
        addEventHandler("onClientRender",root,onRender)
        elements[1]=guiCreateButton(sw/2-(190/2),sh/2+80,190,50,"rozpocznij prace[1]",false)
        elements[2]=guiCreateButton(sw/2+300-25,sh/2+150-20,25,20,"zamknij[1]",false)
        for _,v in ipairs(elements) do if isElement(v) then guiSetAlpha(v,0) end end
    end
end

function gui_transportt()
    dxDrawImage(sw/2-400, sh/2-200, 701, 350,"tlo_job.png",0,0,0,tocolor(255,255,255,200), false)
    dxDrawImage(sw/2-(190/2), sh/2+80, 190, 50,"button_job.png",0,0,0,tocolor(255,255,255,240), false)
    dxDrawImage(sw/2+300-25, sh/2+150-20, 25, 20,"zamknij.png",0,0,0,tocolor(255,255,255,255), false)
    text = "Praca Dorywcza\nDojenie kr?w\n\n\nKa?dy w dzieci?stwie widzia? krow?\nale nie ka?dy m?g? t? krow? wydoi?, na naszym serwerze\njest to mo?liwe u nas, mo?esz wydoi? krow? :)"
    dxDrawText(tostring(text),sw/2, sh/2-125, sw/2, sh/2-140,tocolor(255,255,255,255),1.5,"default","center", false)
    dxDrawText("Rozpocznij prac?",sw/2, sh/2+93, sw/2, sh/2+93,tocolor(255,255,255,255),1.25,"default","center", false)
end

addEventHandler("onClientGUIClick",resourceRoot,function()
    local txt = guiGetText(source)
    if txt == "rozpocznij prace[1]" then
        checkButtons(localPlayer)
        startJob(localPlayer)
    elseif txt == "zamknij[1]" then
        checkButtons(localPlayer)
    end
end)
local start=createElement("text")
setElementData(start,"name","Praca Dorywcza\nDojenie kr?w")
setElementPosition(start, -1427.06,2171.40,50.63)

local markerROZP = createMarker(-1427.06,2171.40,50.63-1,"cylinder",1.1,0,0,0)
addEventHandler("onClientMarkerHit",markerROZP,function(pcl,cmd)
    if not isPedInVehicle(localPlayer) then
        if not getElementData(localPlayer,"player:job") then
            if pcl == localPlayer then
                --if getElementData(pcl,"ACL") then else return end -- todo usuni?cia.
                showButtons(pcl)
            end
        end
    end
end)


-----------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------MECHANIZM PRACY----------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------------
local pktdojenia = {
    --{x,y,z,rz},
{-1455.51, 2172.13, 48.34},
{-1467.36, 2159.54, 46.35},
{-1485.89, 2166.39, 47.58},
{-1483.44, 2183.37, 48.47},
{-1490.41, 2198.62, 49.27},
{-1483.79, 2214.22, 47.58},
{-1464.99, 2215.13, 48.52},
{-1449.92, 2230.75, 50.87},
{-1457.13, 2245.56, 51.36},
{-1474.45, 2256.52, 48.82},
{-1494.54, 2269.50, 46.07},
{-1500.41, 2287.94, 44.34},
{-1490.14, 2292.80, 45.28},
{-1480.62, 2301.90, 45.82},
{-1488.28, 2314.11, 47.12},
{-1493.15, 2326.61, 48.11},
{-1497.44, 2341.95, 48.97},
{-1474.73, 2343.28, 51.04},
{-1459.55, 2313.86, 48.75},
{-1458.03, 2277.97, 48.88},
{-1457.69, 2238.16, 50.25},
{-1466.14, 2217.87, 48.54},
{-1460.05, 2204.58, 48.66},
{-1447.47, 2180.08, 49.78}
    }

local silosy = {
    --{x,y,z},
    {-1419.14,2176.95,50.27},
}

function endJob(plr)
    if plr == localPlayer then
        if blip and isElement(blip) then destroyElement(blip) end
        if point and isElement(point) then destroyElement(point) end
    end
end

function startJob(plr)
    if plr == localPlayer then
        if not getElementData(plr,"player:job") then
            if not isPedInVehicle(plr) then
                triggerServerEvent("check:zbiornikMilkPrzepelniony",plr,plr)
            end
        end
    end
end
addEvent("milkingcows:startJob:e",true)
addEventHandler("milkingcows:startJob:e",root,function(plr)
    if plr == localPlayer then
        --outputChatBox("* Praca zosta?a rozpoczeta!",255,255,0,true)
        triggerEvent("onClientAddNotification", plr, "Praca zosta?a rozpoczeta!", "success")
        setElementData(plr,"player:job",true)
        setElementData(plr,"player:job:milkingcows:etap",1)
        startJobEtap(plr)
    end
end)

function startJobEtap(plr)
    if plr == localPlayer then
        if getElementData(plr,"player:job:milkingcows:etap") == 1 then
            endJob(plr)
            local rnd = math.random(1,#pktdojenia)
            point = createMarker(pktdojenia[rnd][1],pktdojenia[rnd][2],pktdojenia[rnd][3]-1.2,"cylinder",1.5,255,255,0,100)
            local rot = pktdojenia[rnd][4]
            blip = createBlipAttachedTo(point,12)
            addEventHandler("onClientMarkerHit",point,function(plr)
                if plr == localPlayer then
                    if isPedInVehicle(plr) then return end
                    triggerServerEvent("milkingcows:1",plr,plr,rot or 0)
                    setElementData(plr,"dojeniekrowy:przycisk",true)
                    rot = 0
                    --outputChatBox("* Doisz krow? . . .",255,255,150,true)
                    triggerEvent("onClientAddNotification", plr, "((U?ywaj prawego i lewego przycisku myszy do czasu wydojenia krowy!))", "success")
                    triggerEvent("onClientAddNotification", plr, "Doisz krow?...", "success")
                    --outputChatBox("((U?ywaj prawego i lewego przycisku myszy do czasu wydojenia krowy!))",255,255,150,true)
                    k_j.prog1 = guiCreateProgressBar(sw/2-(400/2),sh/2+sh/3,400,30,false,false)
                    k_j.prog2 = guiCreateProgressBar(sw/2-(400/2),sh/2+sh/3+35,400,30,false,false)
                end
            end)
        elseif getElementData(plr,"player:job:milkingcows:etap") == 2 then
            local rnd = math.random(1,#silosy)
            point = createMarker(silosy[rnd][1],silosy[rnd][2],silosy[rnd][3]-1.2,"cylinder",1.5,255,255,0,100)
            blip = createBlipAttachedTo(point,12)
            addEventHandler("onClientMarkerHit",point,function(plr)
                if plr == localPlayer then
                    if isPedInVehicle(plr) then return end
                    if getElementData(plr,"player:job") then
                        setElementData(plr,"player:job:milkingcows:etap",1)
                        endJob(plr)
                        triggerServerEvent("zarobek:dojenie", plr)
                        triggerEvent("onClientAddNotification", plr, "Udaj si? wydoi? kolejn? krow?!", "success")
                        --outputChatBox("* Udaj si? wydoi? kolejn? krow?!",255,255,0)
                        triggerServerEvent("add:zbiornikmilk",plr,plr)
                        if point and isElement(point) then destroyElement(point) end
                        setTimer(function()
                            startJobEtap(plr)
                        end,200,1)
                    end
                end
            end)
        end
    end
end


local markerzakonczenia = createMarker(-1425.90,2176.68,50.40-1.1,"cylinder",1.5,255,0,0,100)
addEventHandler("onClientMarkerHit",markerzakonczenia,function(plr)
    if plr == localPlayer then
        if getElementData(plr,"player:job") == true then
            if not isPedInVehicle(plr) then
                if getElementData(plr,"player:job:milkingcows:etap") == 1 or getElementData(plr,"player:job:milkingcows:etap") == 2 then
                    setElementData(plr,"player:job",false)
                    setElementData(plr,"player:job:milkingcows:etap",false)
                    endJob(plr)
                    if k_j.prog1 and isElement(k_j.prog1) then destroyElement(k_j.prog1) end
                    if k_j.prog2 and isElement(k_j.prog2) then destroyElement(k_j.prog2) end
                    setElementData(plr,"dojeniekrowy:przycisk",false)
                    setElementData(plr,"dojeniekrowy:prawy",false)
                    setElementData(plr,"dojeniekrowy:lewy",false)
                    --outputChatBox("Praca zosta?a zako?czona!",255,0,0)
                    triggerEvent("onClientAddNotification", plr, "Praca zosta?a zako?czona!", "success")
                end 
            end
        end
    end
end)

addEventHandler("onClientPlayerWasted",root,function()
    if source == localPlayer then
        endJob(source)
        setElementData(source,"player:job",false)
        setElementData(source,"player:job:milkingcows:etap",false)
        setElementData(source,"dojeniekrowy:przycisk",false)
        setElementData(source,"dojeniekrowy:prawy",false)
        setElementData(source,"dojeniekrowy:lewy",false)
        if k_j.prog1 and isElement(k_j.prog1) then destroyElement(k_j.prog1) end
        if k_j.prog2 and isElement(k_j.prog2) then destroyElement(k_j.prog2) end
    end
end)


function added(plr)
    if plr == localPlayer then
        local prawy,lewy = getElementData(plr,"dojeniekrowy:prawy") or 0,getElementData(plr,"dojeniekrowy:lewy") or 0
        if tonumber(prawy) >= 100 and tonumber(lewy) >= 100 then
            setElementData(plr,"dojeniekrowy:przycisk",false)
            endJob(plr)
            setTimer(function()
                startJobEtap(plr)
                triggerServerEvent("milkingcows:stopAnimation",plr,plr)
                setElementData(plr,"dojeniekrowy:prawy",false)
                setElementData(plr,"dojeniekrowy:lewy",false)
                guiProgressBarSetProgress(k_j.prog1,0)
                guiProgressBarSetProgress(k_j.prog2,0)
                if k_j.prog1 and isElement(k_j.prog1) then destroyElement(k_j.prog1) end
                if k_j.prog2 and isElement(k_j.prog2) then destroyElement(k_j.prog2) end
            end,150,1)
        end
    end
end


bindKey("mouse1","down",function() -- lewo
    if getElementData(localPlayer,"dojeniekrowy:przycisk") == true then
        if k_j.prog1 and isElement(k_j.prog1) then else return end
        setElementData(localPlayer,"dojeniekrowy:lewy",(getElementData(localPlayer,"dojeniekrowy:lewy") or 0)+5)
        added(localPlayer)
        guiProgressBarSetProgress(k_j.prog1,guiProgressBarGetProgress(k_j.prog1)+5)
        if guiProgressBarGetProgress(k_j.prog1) > 100 then
            guiProgressBarSetProgress(k_j.prog1,100)
        end
        if isTimer(timer1) then killTimer(timer1) end
        timer1 = setTimer(function()
            if k_j.prog1 and isElement(k_j.prog1) then
                if guiProgressBarGetProgress(k_j.prog1) > 5 then
                    guiProgressBarSetProgress(k_j.prog1,guiProgressBarGetProgress(k_j.prog1)-5)
                    setElementData(localPlayer,"dojeniekrowy:lewy",(getElementData(localPlayer,"dojeniekrowy:lewy") or 0)-5)
                end
            else
                if isTimer(timer1) then killTimer(timer1) end
            end
        end,1500,0)
    end
end)

bindKey("mouse2","down",function() -- prawo
    if getElementData(localPlayer,"dojeniekrowy:przycisk") == true then
        if k_j.prog2 and isElement(k_j.prog2) then else return end
        setElementData(localPlayer,"dojeniekrowy:prawy",(getElementData(localPlayer,"dojeniekrowy:prawy") or 0)+5)
        added(localPlayer)
        guiProgressBarSetProgress(k_j.prog2,guiProgressBarGetProgress(k_j.prog2)+5)
        if guiProgressBarGetProgress(k_j.prog2) > 100 then
            guiProgressBarSetProgress(k_j.prog2,100)
        end
        if isTimer(timer2) then killTimer(timer2) end
        timer2 = setTimer(function()
            if k_j.prog2 and isElement(k_j.prog2) then
                if guiProgressBarGetProgress(k_j.prog2) > 5 then
                    guiProgressBarSetProgress(k_j.prog2,guiProgressBarGetProgress(k_j.prog2)-5)
                    setElementData(localPlayer,"dojeniekrowy:prawy",(getElementData(localPlayer,"dojeniekrowy:prawy") or 0)-5)
                end
            else
                if isTimer(timer2) then killTimer(timer2) end
            end
        end,1500,0)
    end
end)


fileDelete("client.lua")



B?ad jest tu

function showButtons(pcl)
    if (pcl==localPlayer) then
        checkButtons(pcl)
        showCursor(true)
        addEventHandler("onClientRender",root,onRender)

a dokladniej w tej linijce

addEventHandler("onClientRender",root,onRender)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-12-26, 10:36


_jvneczek







Wiek: 22
Na forum: 4467 dni
Posty: 1509
Nick w MP: _jvneczek

Piwa: 3960

Respekt: 337,5
Respekt: 337,5Respekt: 337,5Respekt: 337,5

Ta linijka jest poprawna, poka? mo?e b??d bo czarodziejami nie jeste?my, no i sk?d mamy wiedzie? jaki b??d.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-12-26, 16:12


EnoNeK







Wiek: 21
Na forum: 3428 dni
Posty: 39
Nick w MP: EnoNeK

Piwa: 54

Respekt: 200
Respekt: 200Respekt: 200

A gdzie masz funkcj? onRender, nie ma jej wi?c nie nadasz jej eventu i dlatego wyskakuje b??d.

Postaw piwo autorowi tego posta
 

 
Tagi: praca :: nie :: dziala
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA Odpowiedz do tematu

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