Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local names = {}
- names[1] = "Anthony"
- names[2] = "Andrzej"
- names[3] = "Mark"
- names[4] = "Edward"
- names[5] = "Adam"
- local sx, sy = guiGetScreenSize()
- local mWindow = guiCreateWindow(700*sx/1920, 700*sy/1080, 560*sx/1920, 190*sy/1080, " ", false)
- local buttonagree = guiCreateButton(70*sx/1920, 105*sy/1080, 170*sx/1920, 50*sy/1080, "Biorę", false, mWindow)
- local buttondisagree = guiCreateButton(320*sx/1920, 105*sy/1080, 170*sx/1920, 50*sy/1080, "Odmawiam", false, mWindow)
- local myLabel = guiCreateLabel(50*sx/1920, 50*sy/1080, 510*sx/1920, 35*sy/1080, " ", false, mWindow)
- guiSetVisible(mWindow, false)
- guiWindowSetMovable(mWindow, false)
- guiWindowSetSizable(mWindow, false)
- local markers = {}
- markers[1] = createMarker(1698.44, -2094.60, 10.55, "cylinder", 3.5, 120, 120, 120, 150)
- local secondMarker = nil
- local secondBlip = nil
- local thirdMarker = nil
- local thirdBlip = nil
- local dilers = {
- {1691.80, -2124.44, 12.55},
- {1717.84, -2122.80, 12.55},
- {1734.50, -2100.83, 12.55}
- }
- local destinationsDilers = {
- {1696.08, -2090.62, 12.55},
- {1699.10, -2090.43, 12.55},
- {1701.98, -2090.40, 12.55}
- }
- local carsallowed = {[554] = true, [442] = true, [600] = true, [543] = true, [478] = true, [500] = true}
- function showDialog(cena)
- guiSetVisible(mWindow, true)
- local dialognr = math.random(1, 5)
- if dialognr == 1 then
- guiSetText(myLabel, names[tonumber(math.random(1, #names))] .. ": Chcę za towar " .. cena .. "$, pasuje?")
- elseif dialognr == 2 then
- guiSetText(myLabel, names[tonumber(math.random(1, #names))] .. ": Interesują mnie poważne kwoty. Co powiesz na " .. cena .. "$?")
- elseif dialognr == 3 then
- guiSetText(myLabel, names[tonumber(math.random(1, #names))] .. ": Nie sprzedaję tego tanio, nawet nie myśl. Coś koło " .. cena .. "$, co ty na to?")
- elseif dialognr == 4 then
- guiSetText(myLabel, names[tonumber(math.random(1, #names))] .. ": U mnie najtaniej, nawet " .. cena .. "$ za paczkę, pasi?")
- elseif dialognr == 5 then
- guiSetText(myLabel, names[tonumber(math.random(1, #names))] .. ": Słuchaj, kupujesz albo nie. " .. cena .. "$ i bierzesz, jasne?")
- end
- end
- addEventHandler("onClientMarkerHit", markers[1], function(el, md)
- local veh = getPedOccupiedVehicle(el)
- local _, _, z = getElementPosition(el)
- if not md then return end
- if el ~= localPlayer then return end
- if getElementData(el, "isWorking") == true then outputChatBox("Już tutaj pracujesz!") return end
- if not veh then outputChatBox("Musisz posiadać swój samochód aby rozpocząć handel!") return end
- if z > 18 or z < 9 then return end
- if not carsallowed[getElementModel(veh)] then outputChatBox("Musisz posiadać jeden z pickupów aby rozpocząc handel!") return end
- local rnd = tonumber ( math.random ( 1, #dilers ) )
- secondMarker = createMarker ( dilers[rnd][1], dilers[rnd][2], dilers[rnd][3], "cylinder", 1.3, 255, 0, 0, 200 )
- secondBlip = createBlip ( dilers[rnd][1], dilers[rnd][2], dilers[rnd][3], 41 )
- outputChatBox("Jedź do dilera oznaczego na mapie i zakup towar")
- setElementData(el, "isWorking", true)
- addEventHandler("onClientMarkerHit", secondMarker, function(el, md)
- if not md then return end
- if el ~= localPlayer then return end
- if getPedOccupiedVehicle(el) then outputChatBox("Najpierw wyjdz z pojazdu") return end
- if isElement(secondMarker) then destroyElement(secondMarker) secondMarker = nil end
- if isElement(secondBlip) then destroyElement(secondBlip) secondBlip = nil end
- showCursor(true)
- toggleControl("fire", false)
- local cenatow = math.random(3,14)
- setElementData(el, "cenaTowaru", cenatow)
- showDialog(cenatow)
- setElementFrozen(el, true)
- end)
- end)
- function endDilerJob(plr)
- if getElementData(plr, "isWorking") then
- setElementData(plr, "isWorking", false)
- if isElement(secondMarker) then destroyElement(secondMarker) secondMarker = nil end
- if isElement(secondBlip) then destroyElement(secondBlip) secondBlip = nil end
- if isElement(thirdMarker) then destroyElement(thirdMarker) thirdMarker = nil end
- if isElement(thirdBlip) then destroyElement(thirdBlip) thirdBlip = nil end
- showCursor(false)
- toggleControl("fire", true)
- guiSetVisible(mWindow, false)
- if isElementFrozen(plr) then setElementFrozen(plr, false) end
- end
- end
- function hideGui()
- if getElementData(localPlayer, "isWorking") then
- showCursor(false)
- toggleControl("fire", true)
- guiSetVisible(mWindow, false)
- guiSetText(myLabel, " ")
- end
- end
- function startSecondStage()
- local rnd = tonumber ( math.random ( 1, #destinationsDilers ) )
- thirdMarker = createMarker ( destinationsDilers[rnd][1], destinationsDilers[rnd][2], destinationsDilers[rnd][3], "cylinder", 1.5, 255, 255, 0, 200 )
- thirdBlip = createBlip ( destinationsDilers[rnd][1], destinationsDilers[rnd][2], destinationsDilers[rnd][3], 41 )
- outputChatBox("Udaj się do człowieka, zainteresowanego kupnem towaru")
- addEventHandler("onClientMarkerHit", thirdMarker, function(el, md)
- if not md then return end
- if el ~= localPlayer then return end
- if getPedOccupiedVehicle(el) then outputChatBox("Najpierw wyjdz z pojazdu") return end
- if isElement(thirdMarker) then destroyElement(thirdMarker) thirdMarker = nil end
- if isElement(thirdBlip) then destroyElement(thirdBlip) thirdBlip = nil end
- triggerServerEvent("finishDilerJobByPlr", localPlayer)
- endDilerJob(el)
- end)
- end
- addEventHandler("onClientGUIClick", getRootElement(), function(button, state, x, y)
- if button ~= "left" then return end
- if source == buttonagree then
- if getPlayerMoney() < getElementData(localPlayer, "cenaTowaru") then outputChatBox("Nie stac cie na kupno towaru") return end
- startSecondStage()
- hideGui()
- triggerServerEvent("giveMoneyToDiler", localPlayer)
- elseif source == buttondisagree then
- outputChatBox("Postanowiles nie kupowac towaru, konczysz robotę")
- hideGui()
- endDilerJob(localPlayer)
- end
- setElementFrozen(localPlayer, false)
- end)
- addEventHandler("onClientResourceStop", root, function()
- endDilerJob(localPlayer)
- end)
- addEventHandler("onClientPlayerWasted", getLocalPlayer(), function()
- endDilerJob(source)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement