Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.26 KB | None | 0 0
  1. local names = {}
  2. names[1] = "Anthony"
  3. names[2] = "Andrzej"
  4. names[3] = "Mark"
  5. names[4] = "Edward"
  6. names[5] = "Adam"
  7.  
  8. local sx, sy = guiGetScreenSize()
  9. local mWindow = guiCreateWindow(700*sx/1920, 700*sy/1080, 560*sx/1920, 190*sy/1080, " ", false)
  10. local buttonagree = guiCreateButton(70*sx/1920, 105*sy/1080, 170*sx/1920, 50*sy/1080, "Biorę", false, mWindow)
  11. local buttondisagree = guiCreateButton(320*sx/1920, 105*sy/1080, 170*sx/1920, 50*sy/1080, "Odmawiam", false, mWindow)
  12. local myLabel = guiCreateLabel(50*sx/1920, 50*sy/1080, 510*sx/1920, 35*sy/1080, " ", false, mWindow)
  13. guiSetVisible(mWindow, false)
  14. guiWindowSetMovable(mWindow, false)
  15. guiWindowSetSizable(mWindow, false)
  16.  
  17. local markers = {}
  18. markers[1] = createMarker(1698.44, -2094.60, 10.55, "cylinder", 3.5, 120, 120, 120, 150)
  19.  
  20. local secondMarker = nil
  21. local secondBlip = nil
  22.  
  23. local thirdMarker = nil
  24. local thirdBlip = nil
  25.  
  26. local dilers = {
  27. {1691.80, -2124.44, 12.55},
  28. {1717.84, -2122.80, 12.55},
  29. {1734.50, -2100.83, 12.55}
  30. }
  31.  
  32. local destinationsDilers = {
  33. {1696.08, -2090.62, 12.55},
  34. {1699.10, -2090.43, 12.55},
  35. {1701.98, -2090.40, 12.55}
  36. }
  37.  
  38. local carsallowed = {[554] = true, [442] = true, [600] = true, [543] = true, [478] = true, [500] = true}
  39.  
  40. function showDialog(cena)
  41. guiSetVisible(mWindow, true)
  42. local dialognr = math.random(1, 5)
  43. if dialognr == 1 then
  44. guiSetText(myLabel, names[tonumber(math.random(1, #names))] .. ": Chcę za towar " .. cena .. "$, pasuje?")
  45. elseif dialognr == 2 then
  46. guiSetText(myLabel, names[tonumber(math.random(1, #names))] .. ": Interesują mnie poważne kwoty. Co powiesz na " .. cena .. "$?")
  47. elseif dialognr == 3 then
  48. guiSetText(myLabel, names[tonumber(math.random(1, #names))] .. ": Nie sprzedaję tego tanio, nawet nie myśl. Coś koło " .. cena .. "$, co ty na to?")
  49. elseif dialognr == 4 then
  50. guiSetText(myLabel, names[tonumber(math.random(1, #names))] .. ": U mnie najtaniej, nawet " .. cena .. "$ za paczkę, pasi?")
  51. elseif dialognr == 5 then
  52. guiSetText(myLabel, names[tonumber(math.random(1, #names))] .. ": Słuchaj, kupujesz albo nie. " .. cena .. "$ i bierzesz, jasne?")
  53. end
  54. end
  55.  
  56. addEventHandler("onClientMarkerHit", markers[1], function(el, md)
  57. local veh = getPedOccupiedVehicle(el)
  58. local _, _, z = getElementPosition(el)
  59.  
  60. if not md then return end
  61. if el ~= localPlayer then return end
  62. if getElementData(el, "isWorking") == true then outputChatBox("Już tutaj pracujesz!") return end
  63. if not veh then outputChatBox("Musisz posiadać swój samochód aby rozpocząć handel!") return end
  64. if z > 18 or z < 9 then return end
  65. if not carsallowed[getElementModel(veh)] then outputChatBox("Musisz posiadać jeden z pickupów aby rozpocząc handel!") return end
  66. local rnd = tonumber ( math.random ( 1, #dilers ) )
  67. secondMarker = createMarker ( dilers[rnd][1], dilers[rnd][2], dilers[rnd][3], "cylinder", 1.3, 255, 0, 0, 200 )
  68. secondBlip = createBlip ( dilers[rnd][1], dilers[rnd][2], dilers[rnd][3], 41 )
  69. outputChatBox("Jedź do dilera oznaczego na mapie i zakup towar")
  70. setElementData(el, "isWorking", true)
  71. addEventHandler("onClientMarkerHit", secondMarker, function(el, md)
  72. if not md then return end
  73. if el ~= localPlayer then return end
  74. if getPedOccupiedVehicle(el) then outputChatBox("Najpierw wyjdz z pojazdu") return end
  75. if isElement(secondMarker) then destroyElement(secondMarker) secondMarker = nil end
  76. if isElement(secondBlip) then destroyElement(secondBlip) secondBlip = nil end
  77. showCursor(true)
  78. toggleControl("fire", false)
  79. local cenatow = math.random(3,14)
  80. setElementData(el, "cenaTowaru", cenatow)
  81. showDialog(cenatow)
  82. setElementFrozen(el, true)
  83. end)
  84. end)
  85.  
  86. function endDilerJob(plr)
  87. if getElementData(plr, "isWorking") then
  88. setElementData(plr, "isWorking", false)
  89. if isElement(secondMarker) then destroyElement(secondMarker) secondMarker = nil end
  90. if isElement(secondBlip) then destroyElement(secondBlip) secondBlip = nil end
  91. if isElement(thirdMarker) then destroyElement(thirdMarker) thirdMarker = nil end
  92. if isElement(thirdBlip) then destroyElement(thirdBlip) thirdBlip = nil end
  93. showCursor(false)
  94. toggleControl("fire", true)
  95. guiSetVisible(mWindow, false)
  96. if isElementFrozen(plr) then setElementFrozen(plr, false) end
  97. end
  98. end
  99.  
  100. function hideGui()
  101. if getElementData(localPlayer, "isWorking") then
  102. showCursor(false)
  103. toggleControl("fire", true)
  104. guiSetVisible(mWindow, false)
  105. guiSetText(myLabel, " ")
  106. end
  107. end
  108.  
  109. function startSecondStage()
  110. local rnd = tonumber ( math.random ( 1, #destinationsDilers ) )
  111. thirdMarker = createMarker ( destinationsDilers[rnd][1], destinationsDilers[rnd][2], destinationsDilers[rnd][3], "cylinder", 1.5, 255, 255, 0, 200 )
  112. thirdBlip = createBlip ( destinationsDilers[rnd][1], destinationsDilers[rnd][2], destinationsDilers[rnd][3], 41 )
  113. outputChatBox("Udaj się do człowieka, zainteresowanego kupnem towaru")
  114. addEventHandler("onClientMarkerHit", thirdMarker, function(el, md)
  115. if not md then return end
  116. if el ~= localPlayer then return end
  117. if getPedOccupiedVehicle(el) then outputChatBox("Najpierw wyjdz z pojazdu") return end
  118. if isElement(thirdMarker) then destroyElement(thirdMarker) thirdMarker = nil end
  119. if isElement(thirdBlip) then destroyElement(thirdBlip) thirdBlip = nil end
  120. triggerServerEvent("finishDilerJobByPlr", localPlayer)
  121. endDilerJob(el)
  122. end)
  123. end
  124.  
  125. addEventHandler("onClientGUIClick", getRootElement(), function(button, state, x, y)
  126. if button ~= "left" then return end
  127. if source == buttonagree then
  128. if getPlayerMoney() < getElementData(localPlayer, "cenaTowaru") then outputChatBox("Nie stac cie na kupno towaru") return end
  129. startSecondStage()
  130. hideGui()
  131. triggerServerEvent("giveMoneyToDiler", localPlayer)
  132. elseif source == buttondisagree then
  133. outputChatBox("Postanowiles nie kupowac towaru, konczysz robotę")
  134. hideGui()
  135. endDilerJob(localPlayer)
  136. end
  137. setElementFrozen(localPlayer, false)
  138. end)
  139.  
  140. addEventHandler("onClientResourceStop", root, function()
  141. endDilerJob(localPlayer)
  142. end)
  143.  
  144. addEventHandler("onClientPlayerWasted", getLocalPlayer(), function()
  145. endDilerJob(source)
  146. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement