Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tow =
- {
- towary = { },
- last =
- {
- select = false,
- text = "",
- grupa = "",
- },
- grupa = {},
- labelRed = { },
- przesylki = {}
- }
- rozladunki_window, tab1 = guiCreateWindow(screenX / 2 - 175, screenY / 2 - 75, 350, 150, "Rozladunek", false)
- rozladunki_text = guiCreateLabel(10, 15, 320, 80, "Witaj, tutaj możesz załadowac / rozładować towar.\n\nWystarczy, ze klikniesz na odpowiedni przycisk.", false, tab1)
- guiLabelSetHorizontalAlign(rozladunki_text, "left", true)
- rozladunki_button = guiCreateButton(20, 100, 150, 20, "Załaduj", false, tab1)
- rozladunki_zamknij = guiCreateButton(180, 100, 150, 20, "Zamknij", false, tab1)
- guiSetVisible(rozladunki_window, false)
- towary_lista_window, tab2 = guiCreateWindow(screenX / 2 - 550 / 2, screenY / 2 - 400 / 2, 550, 400, "Towary", false)
- rozladunek_scroll = guiCreateScrollPane(10, 30, 550 - 20, 400 - 90, false, tab2)
- guiScrollPaneSetScrollBars(rozladunek_scroll, false, false)
- guiSetProperty(rozladunek_scroll, "VertStepSize", "0.05")
- guiSetProperty(rozladunek_scroll, "HorzStepSize", "0.05")
- guiCreateLabel(60, 10, 50, 20, "Nazwa", false, tab2)
- guiCreateLabel(170, 10, 50, 20, "Score", false, tab2)
- guiCreateLabel(280, 10, 50, 20, "Ilość", false, tab2)
- guiCreateLabel(450, 10, 50, 20, "Załaduj", false, tab2)
- rozladunek_zamknij = guiCreateButton(550 / 2 - 50, 400 - 50, 100, 20, "Zamknij", false, tab2)
- guiSetVisible(towary_lista_window,false)
- waga_okno,tab3 = guiCreateWindow(screenX / 2 - 145, screenY / 2 - 50, 290, 160, "Ilość towaru", false)
- waga_ladowanie = guiCreateScrollBar(5, 10, 280, 18, true, false, tab3)
- guiSetProperty(waga_ladowanie, "StepSize", "0.01")
- guiScrollBarSetScrollPosition(waga_ladowanie, 50)
- guiCreateStaticImage(232, 0, 2, 30, "files/dot.png", false, waga_ladowanie)
- guiCreateLabel(20, 0, 30, 40, "10%", false, waga_ladowanie)
- guiCreateLabel(235, 0, 30, 40, "110%", false, waga_ladowanie)
- waga_stan_bg = guiCreateStaticImage(5, 34, 280, 20, "files/capture_bg.png", false, tab3)
- waga_stan_stan = guiCreateStaticImage(0, 0, 140, 20, "files/capture.png", false, waga_stan_bg)
- waga_tekst = guiCreateLabel(5, 60, 280, 50, "Przeładowując pojazd narażasz się na mandat od\nfunkcjonariuszy policji. Jeżeli nie chcesz dostać kary\nprzesuń suwak do czerwonek kreski", false, tab3)
- guiLabelSetHorizontalAlign(waga_tekst, "left", true)
- waga_stan_tekst = guiCreateLabel(0, 0, 280, 20, "60%", false, waga_stan_bg)
- guiLabelSetHorizontalAlign(waga_stan_tekst, "center", true)
- waga_button = guiCreateButton(95, 110, 100, 20, "Ładuj", false, tab3)
- waga_wstecz = guiCreateButton(10, 112, 60, 18, "Wróć", false, tab3)
- guiSetVisible(waga_okno, false)
- zapytanie_window,tab4 = guiCreateWindow(screenX / 2 - 150, screenY / 2 - 62, 300, 124, "Kolejny rozładunek", false)
- zapytanie_text = guiCreateLabel(10, 6.5, 280, 46, "Czy chcesz, aby system wylosował docelowy\nrozładunek? Czy wolisz sam wybrać gdzie chcesz\ndowieźć towar? Wciśnij odpowiedni przycisk.", false, tab4)
- guiLabelSetHorizontalAlign(zapytanie_text, "left", true)
- zapytanie_1 = guiCreateButton(60, 62, 100, 28, "Skrypt", false, tab4)
- zapytanie_2 = guiCreateButton(170, 62, 100, 28, "Sam wybiorę", false, tab4)
- zapytanie_wstecz = guiCreateButton(10, 70, 40, 20, "Wróć", false, tab4)
- guiSetVisible(zapytanie_window, false)
- TruckWorld_ZmianaScrolla = function()
- local stan = guiScrollBarGetScrollPosition(waga_ladowanie)
- guiSetSize(waga_stan_stan, stan * 2.8, 18, false)
- guiSetText(waga_stan_tekst, tostring(stan + 10) .. "%")
- end
- addEventHandler("onClientGUIScroll", waga_ladowanie, TruckWorld_ZmianaScrolla)
- addEvent("show",true)
- addEventHandler("show",root,function(id,towary)
- local x,y,z = getElementPosition(getMarkerByID(id))
- -- guiText:visible(true)
- -- guiText:text("Zatrąb, aby otworzyć menu\n\nStrefa załadunku "..id.."\n\n"..getZoneName(x,y,z).."")
- exports["es-komunikaty"]:komunikat("Zatrąb, aby otworzyć menu\n\nStrefa załadunku "..id.."\n\n"..getZoneName(x,y,z).."", plr)
- marid = id
- towtable = split(towary,',')
- bindKey("H","down",open_window)
- if getVehicleTowedByVehicle(getPedOccupiedVehicle(localPlayer)) then
- veh = getVehicleTowedByVehicle(getPedOccupiedVehicle(localPlayer))
- else
- veh = getPedOccupiedVehicle(localPlayer)
- end
- end)
- addEvent("close",true)
- addEventHandler("close",root,function(id)
- marid = false
- unbindKey("H","down",open_window)
- -- guiText:visible(false)
- -- guiText:text("")
- end)
- function open_window()
- guiSetVisible(rozladunki_window,true)
- showCursor(true)
- unbindKey("H","down",open_window)
- triggerServerEvent("blokujJazde",localPlayer,localPlayer,"Tak")
- if getElementData(veh,"zaladowany") == true then
- guiSetText(rozladunki_button,"Rozładuj")
- else
- guiSetText(rozladunki_button,"Załaduj")
- end
- end
- addEventHandler("onClientGUIClick",root,function()
- if source == rozladunki_zamknij then
- guiSetVisible(rozladunki_window,false)
- showCursor(false)
- bindKey("H","down",open_window)
- close_praca()
- triggerServerEvent("blokujJazde",localPlayer,localPlayer,"Nie")
- elseif source == rozladunki_button then
- if guiGetText(rozladunki_button) == "Załaduj" then
- close_praca()
- unbindKey("H","down",open_window)
- guiSetVisible(rozladunki_window,false)
- guiSetVisible(towary_lista_window,true)
- createTowary()
- else
- if getElementData(veh,"zaladowany") == true then
- if getElementData(veh,"rozladowac_moze") == true then
- if getElementData(veh,"rozladunek_typ") == "Skrypt" then
- if getElementData(veh,"rozladunek_id") == marid then
- rozladuj()
- else
- outputMessage("To nie jest twoje miejsce rozładunku","warning","",false)
- end
- else
- rozladuj()
- end
- else
- outputMessage("Nie możesz jeszcze rozładować towaru","warning","",false)
- end
- end
- end
- elseif source == rozladunek_zamknij then
- guiSetVisible(towary_lista_window,false)
- showCursor(false)
- close_praca()
- bindKey("H","down",open_window)
- triggerServerEvent("blokujJazde",localPlayer,localPlayer,"Nie")
- elseif source == tak then
- closeMessageBox()
- guiSetVisible(towary_lista_window,false)
- guiSetVisible(waga_okno,true)
- close_praca()
- elseif source == nie then
- closeMessageBox()
- elseif source == waga_wstecz then
- guiSetVisible(towary_lista_window,true)
- guiSetVisible(waga_okno,false)
- createTowary()
- elseif source == waga_button then
- local stan = guiScrollBarGetScrollPosition(waga_ladowanie)
- waga = tonumber(stan+10)
- guiSetVisible(zapytanie_window,true)
- guiSetVisible(waga_okno,false)
- elseif source == zapytanie_1 then
- zaladuj(towar,kategoria,czas,waga,"Skrypt")
- guiSetVisible(zapytanie_window,false)
- showCursor(false)
- elseif source == zapytanie_2 then
- zaladuj(towar,kategoria,czas,waga,"Sam wybiore")
- guiSetVisible(zapytanie_window,false)
- showCursor(false)
- end
- end)
- function close_praca()
- for k,v in ipairs(getElementChildren(rozladunek_scroll)) do
- destroyElement(v)
- end
- tow.last.text = ""
- tow.labelRed = {}
- tow.towary = { }
- tow.last.select = false
- end
- addEvent("uzupclient",true)
- addEventHandler("uzupclient",getRootElement(),
- function(tows,ka)
- tow = tows
- kate = ka
- end
- )
- function iniciateZapisData()
- local mar = getMarkerByID(marid)
- for num,data in ipairs(towtable) do
- setElementData(mar,"towar_"..tostring(data['towarName']),tonumber(data['wartosc']))
- end
- end
- function createTowary()
- iniciateZapisData()
- local id = 0
- for l,a in ipairs(split(getDane("zal"),',')) do
- guiCreateLabel(0, id * 25 + 1, 500, 20, a, false, rozladunek_scroll)
- guiCreateStaticImage(0, id * 25 + 20, 500, 1, "files/capture.png", false, rozladunek_scroll)
- id = id+1
- for i,v in ipairs(tow.grupa[a]) do
- local labelname = guiCreateLabel(20, (id) * 25, 135, 20, v[1], false, rozladunek_scroll)
- local labelscore = guiCreateLabel(170, (id) * 25, 30, 20, v[2], false, rozladunek_scroll)
- local podkladimage = guiCreateStaticImage(210, (id) * 25 + 1, 200, 18, "files/capture_bg.png", false, rozladunek_scroll)
- local minlabel = guiCreateButton(420, (id) * 25, 65, 20, "Załaduj", false, rozladunek_scroll)
- setElementData(minlabel, "towar_id", v[1], false)
- setElementData(minlabel, "towar_czas", v[5], false)
- setElementData(minlabel, "towar_kategoria", v[7], false)
- addEventHandler("onClientGUIClick", minlabel, pytanie)
- tow.towary[v[1]] =
- {
- labelname,
- labelscore,
- podkladimage,
- minlabel,
- v[5],
- a
- }
- setElementSource(labelname,labelname)
- setElementSource(labelscore,labelname)
- setElementSource(minlabel,labelname)
- local postepbar = guiCreateStaticImage(0, 0, 0, 18, "files/capture.png", false, podkladimage)
- local mar = getMarkerByID(marid)
- if mar then
- local data = getElementData(mar,"towar_"..tostring(v[1]))
- if tonumber(data) then
- setProggesPasek(postepbar,data)
- else
- setProggesPasek(postepbar,100)
- setElementData(mar,"towar_"..tostring(v[1]),100)
- end
- end
- if tonumber(v[2]) > tonumber(getElementData(localPlayer,"Score")) then
- guiSetAlpha(labelname,0.5)
- guiSetAlpha(labelscore,0.5)
- guiSetAlpha(labelscore,0.5)
- guiSetAlpha(postepbar,0.5)
- guiSetAlpha(podkladimage,0.5)
- guiSetEnabled(minlabel,false)
- end
- id = id+1
- end
- end
- end
- function setElementSource(element,elementtosource)
- return setElementData(element,"source_Element",elementtosource)
- end
- function getElementSource(element)
- return getElementData(element,"source_Element")
- end
- function setProggesPasek(ele,postep)
- guiSetSize(ele, tonumber(postep)*2, 26, false)
- end
- function getDane(typ)
- for a,marker in ipairs(getElementsByType("colshape",getResourceRootElement(getThisResource()))) do
- if getElementData(marker,"id") == marid then
- return getElementData(marker,typ)
- end
- end
- return false
- end
- function getMarkerByID(id)
- for a,marker in ipairs(getElementsByType("colshape",getResourceRootElement(getThisResource()))) do
- if getElementData(marker,"id") == id then
- return marker
- end
- end
- return false
- end
- function pytanie()
- towar = getElementData(source,"towar_id")
- kategoria = getElementData(source,"towar_kategoria")
- czas = getElementData(source,"towar_czas")
- tak, nie = outputMessage("Czy chcesz załadować towar "..towar.."?","info","",true)
- end
- function getWynagrodzenie(app)
- return tonumber(tow.przesylki[app].min) or tonumber(0), tonumber(tow.przesylki[app].max) or tonumber(5000)
- end
- function zaladuj(towar,kategoria,czas,waga,typ)
- outputMessage("Trwa ładowanie towaru..","info","",false)
- loadingTimer = exports.missiontimer:createMissionTimer((czas*60000),true,"%m:%s",0.5,20,true,"default-bold",1,255,255,255)
- addEventHandler("onClientMissionTimerElapsed", loadingTimer, loadingEnd)
- setElementData(localPlayer,"laduje",true)
- ladTimer = setTimer(function()
- triggerServerEvent("TruckWorld_ZaladunekPrzetworz",localPlayer,localPlayer,marid,towar,kategoria,waga,typ,czas)
- outputMessage("Pomyślie załadowano","info","",false)
- odczekajTimer = exports.missiontimer:createMissionTimer((5*60000),true,"%m:%s",0.5,20,true,"default-bold",1,255,255,255)
- addEventHandler("onClientMissionTimerElapsed", odczekajTimer, odczekajEnd)
- setElementData(localPlayer,"laduje",false)
- setElementData(veh,"rozladowac_moze",false)
- triggerServerEvent("blokujJazde",localPlayer,localPlayer,"Nie")
- end,(czas*60000),1)
- end
- addEvent("towar_pasek",true)
- addEventHandler("towar_pasek",root,
- function(pojazd,towar,kategoria,waga,typ)
- if typ == "Skrypt" then
- local x,y,z = getElementPosition(getMarkerByID(getElementData(pojazd,"rozladunek_id")))
- renderTowar_new("Towar: "..towar..", kategoria: "..kategoria..", waga: "..waga.." kg, cel: "..getZoneName(x,y,z).."("..getElementData(pojazd,"rozladunek_id")..")")
- else
- renderTowar_new("Towar: "..towar..", kategoria: "..kategoria..", waga: "..waga.." kg")
- end
- end
- )
- function rozladuj()
- triggerServerEvent("blokujJazde",localPlayer,localPlayer,"Tak")
- guiSetVisible(rozladunki_window,false)
- showCursor(false)
- outputMessage("Trwa rozładowywanie towaru..","info","",false)
- loadingTimer = exports.missiontimer:createMissionTimer((getElementData(veh,"czas")*60000),true,"%m:%s",0.5,20,true,"default-bold",1,255,255,255)
- addEventHandler("onClientMissionTimerElapsed", loadingTimer, loadingEnd)
- setElementData(localPlayer,"rozladowywuje",true)
- ladTimer = setTimer(function()
- local min,max = getWynagrodzenie(getElementData(veh,"towar"))
- local gwarantowane = math.random(min,max)
- triggerServerEvent("TruckWorld_RozladunekPrzetworz",localPlayer,localPlayer,veh,gwarantowane)
- setElementData(localPlayer,"rozladowywuje",false)
- setElementData(veh,"rozladowac_moze",false)
- triggerServerEvent("blokujJazde",localPlayer,localPlayer,"Nie")
- renderTowar_new(false)
- end,(getElementData(veh,"czas")*60000),1)
- end
- function loadingEnd()
- destroyElement(source)
- end
- function odczekajEnd()
- destroyElement(source)
- setElementData(veh,"rozladowac_moze",true)
- outputMessage("Już możesz rozładować swój towar","info","",false)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement