Advertisement
OneTallor

Untitled

Jul 2nd, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.42 KB | None | 0 0
  1. local activeTab = nil
  2. local sx, sy = guiGetScreenSize()
  3. local tabW, tabH, tabX, tabY = 400, 300, sx/2 - 200, sy/2 - 150
  4. local dxFont = dxCreateFont("font.ttf", 10*2, false)
  5.  
  6. addEventHandler('onClientResourceStart', root, function()
  7.     setElementData(localPlayer, 'working', 0)
  8. end)
  9.  
  10. local carMarker = {
  11.     {1089.845703125, -1246.544921875, 14.82715034484},
  12.     {1097.19921875, -1246.59765625, 14.8203125},
  13.     {1106.87109375, -1228.31640625, 14.827150344849},
  14.     {1095.9873046875, -1227.8359375, 14.8203125},
  15. }
  16.  
  17. local boxMarker = {
  18.     {1084.9228515625, -1219.7275390625, 16.812009811401},
  19.     {1086.806640625, -1186.3486328125, 17.308547973633},
  20.     {1098.7294921875, -1182.3349609375, 17.40899848938},
  21. }
  22.  
  23. local endMarker = {
  24.     {2868.5654296875, -1457.73046875, 9.963136672974},
  25.     {2407.0810546875, -1958.0478515625, 12.546875},
  26.     {2246.4541015625, -1966.4228515625, 12.548511505127},
  27.     {1941.3876953125, -2086.052734375, 12.556798934937},
  28.     {1155.4501953125, -1859.5244140625, 12.546908378601},
  29.     {333.654296875, -1373.0556640625, 13.299780845642},
  30. }
  31.  
  32. for k, v in ipairs (carMarker) do
  33.     marker = createMarker(v[1], v[2], v[3], "checkpoint", 3, 108, 172, 111, 180)
  34.     setElementData(marker, 'job', 1)
  35. end
  36.  
  37. for k, v in ipairs (boxMarker) do
  38.     marker = createMarker(v[1], v[2], v[3], "checkpoint", 2, 249, 105, 14, 180)
  39.     setElementData(marker, 'csomagfelvetel', 1)
  40. end
  41.  
  42. addEventHandler("onClientKey", root, function(gomb, state)
  43.     if getElementData(localPlayer, "csomaghordas") == 1 then
  44.     if gomb == "mouse1" or gomb == "mouse2" or gomb == "mouse3" or gomb == "lshift" or gomb == "space" or gomb == "c" or gomb == "lctrl" or gomb == "rctrl" and state then
  45.         cancelEvent()
  46.     end
  47.     end
  48. end)
  49.  
  50. addEventHandler('onClientMarkerHit', root,
  51.     function(hitElement, hitDimension)
  52.         if getElementData(source, 'job') == 1 and hitElement == localPlayer and getElementData(hitElement, "job") == 1 then
  53.             local kocsi = getPedOccupiedVehicle(hitElement)
  54.             if not kocsi and getElementData(hitElement, "working") == 0 then
  55.                 activeTab = 'carChoose'
  56.                 setElementFrozen(hitElement, true)
  57.             elseif kocsi and getElementModel(kocsi) == 456 then
  58.                 activeTab = 'carDelete'
  59.                 setElementFrozen(kocsi, true)
  60.                 toggleControl("enter_exit", false)
  61.             end
  62.         elseif getElementData(source, 'csomag') == 1 and hitElement == localPlayer and getElementData(hitElement, "job") == 1 then
  63.             if getElementData(hitElement, 'csomaghordas') == 1 then
  64.                 local veh = getElementData(source, 'car')
  65.                 if getElementData(veh, "id") == getElementData(hitElement, "playerid") then
  66.                     triggerServerEvent("deAttachBox", hitElement, hitElement)
  67.                     if getElementData(veh, "boxes") < 20 then
  68.                         setElementData(veh, "boxes", getElementData(veh, "boxes") + 1)
  69.                         outputChatBox("Bent lévő dobozok: "..getElementData(veh, "boxes").." a 20-ból.", 255, 255, 255, true)
  70.                     elseif getElementData(veh, "boxes") == 20 then
  71.                         local rand = math.random(#endMarker)
  72.                         marker = createMarker(endMarker[rand][1], endMarker[rand][2], endMarker[rand][3], 'checkpoint', 2, 207, 0, 15, 100)
  73.                         setElementData(marker, 'leadas', 1)
  74.                         outputChatBox("A jármű raktere tele van. Mehetsz fuvaroni.", 255, 255, 255, true)
  75.                     end
  76.                 end
  77.             end
  78.         elseif getElementData(source, 'csomagfelvetel') == 1 and hitElement == localPlayer and getElementData(hitElement, "job") == 1 then
  79.             felvesz()
  80.         elseif getElementData(source, 'leadas') == 1 and hitElement == localPlayer and getElementData(hitElement, "job") == 1 then
  81.             local kocsi = getPedOccupiedVehicle(hitElement)
  82.             if kocsi then
  83.                 if getElementData(kocsi, "id") == getElementData(hitElement, "playerid") then
  84.                     if getElementData(kocsi, "boxes") > 0 then
  85.                         setElementData(kocsi, "boxes", 0)
  86.                         destroyElement(marker)
  87.                         outputChatBox("A munkások lepakolták az árut. Menj vissza telepre egy új járműért és kezd el a munkát megint.", 255, 255, 255, true)
  88.                     end
  89.                 end
  90.             end
  91.         end
  92.     end
  93. )
  94.  
  95. function felvesz()
  96.     if getElementData(localPlayer, "csomaghordas") == 1 then return end
  97.     triggerServerEvent("attachBox", localPlayer, localPlayer)
  98. end
  99.  
  100. addEventHandler('onClientRender', root,
  101.     function()
  102.         if activeTab == 'carChoose' then
  103.             local color, color2 = tocolor(0, 0, 0, 180), tocolor(0, 0, 0, 180)
  104.  
  105.             if isCursorInRectangle(sx/2 - 100, sy/2 - 45/2 + 70, 200, 45) then
  106.                 color = tocolor(108, 172, 111, 180)
  107.             elseif isCursorInRectangle(sx/2 - 100, sy/2 - 45/2 + 120, 200, 45) then
  108.                 color2 = tocolor(207, 0, 15, 180)
  109.             end
  110.  
  111.             dxDrawRectangle(tabX, tabY, tabW, tabH, tocolor(0, 0, 0, 180))
  112.  
  113.             --dxDrawRectangle(sx/2 - 175, sy/2 - 125, 350, 150, tocolor(0, 0, 0, 180))
  114.  
  115.             dxDrawRectangle(sx/2 - 100, sy/2 - 45/2 + 70, 200, 45, color)
  116.             dxDrawText('EZT KÉREM', 0, 150, sx, sy, tocolor(255, 255, 255, 255), 1, dxFont, 'center', 'center')
  117.             dxDrawRectangle(sx/2 - 100, sy/2 - 45/2 + 120, 200, 45, color2)
  118.             dxDrawText('KILÉPÉS', 0, 250, sx, sy, tocolor(255, 255, 255, 255), 1, dxFont, 'center', 'center')
  119.         elseif activeTab == 'carDelete' then
  120.             local color, color2 = tocolor(0, 0, 0, 180), tocolor(0, 0, 0, 180)
  121.  
  122.             if isCursorInRectangle(sx/2 - 100, sy/2 - 45/2 + 70, 200, 45) then
  123.                 color = tocolor(207, 0, 15, 180)
  124.             elseif isCursorInRectangle(sx/2 - 100, sy/2 - 45/2 + 120, 200, 45) then
  125.                 color2 = tocolor(207, 0, 15, 180)
  126.             end
  127.  
  128.             dxDrawRectangle(tabX, tabY, tabW, tabH, tocolor(0, 0, 0, 180))
  129.  
  130.             --dxDrawRectangle(sx/2 - 175, sy/2 - 125, 350, 150, tocolor(0, 0, 0, 180))
  131.  
  132.             dxDrawRectangle(sx/2 - 100, sy/2 - 45/2 + 70, 200, 45, color)
  133.             dxDrawText('leadás', 0, 150, sx, sy, tocolor(255, 255, 255, 255), 1, dxFont, 'center', 'center')
  134.             dxDrawRectangle(sx/2 - 100, sy/2 - 45/2 + 120, 200, 45, color2)
  135.             dxDrawText('KILÉPÉS', 0, 250, sx, sy, tocolor(255, 255, 255, 255), 1, dxFont, 'center', 'center')
  136.         end
  137.     end
  138. )
  139.  
  140. addEventHandler('onClientClick', root,
  141.     function(g, s, x, y)
  142.         if g == 'left' and s == 'down' then
  143.             if activeTab == 'carChoose' then
  144.                 if dobozbaVan(sx/2 - 100, sy/2 - 45/2 + 120, 200, 45, x, y) then
  145.                     activeTab = nil
  146.                     setElementFrozen(localPlayer, false)
  147.                 elseif dobozbaVan(sx/2 - 100, sy/2 - 45/2 + 70, 200, 45, x, y) then
  148.                     triggerServerEvent('job:addCar', localPlayer, localPlayer, 456)
  149.                     activeTab = nil
  150.                     setElementData(localPlayer, "working", 1)
  151.                 end
  152.             elseif activeTab == 'carDelete' then
  153.                 if dobozbaVan(sx/2 - 100, sy/2 - 45/2 + 120, 200, 45, x, y) then
  154.                     activeTab = nil
  155.                     local kocsi = getPedOccupiedVehicle(localPlayer)
  156.                     setElementFrozen(kocsi, false)
  157.                     toggleControl("enter_exit", true)
  158.                 elseif dobozbaVan(sx/2 - 100, sy/2 - 45/2 + 70, 200, 45, x, y) then
  159.                     local kocsi = getPedOccupiedVehicle(localPlayer)
  160.                     if getElementData(kocsi, "id") == getElementData(localPlayer, "playerid") then
  161.                         triggerServerEvent('job:deleteCar', localPlayer, localPlayer, kocsi)
  162.                         activeTab = nil
  163.                         setElementData(localPlayer, "working", 0)
  164.                     else
  165.                         outputChatBox("Ez nem a te kocsid!", 255, 255, 255, true)
  166.                     end
  167.                 end
  168.             end
  169.         end
  170.     end
  171. )
  172.  
  173. function dobozbaVan(dX, dY, dSZ, dM, eX, eY)
  174.     if(eX >= dX and eX <= dX+dSZ and eY >= dY and eY <= dY+dM) then
  175.         return true
  176.     else
  177.         return false
  178.     end
  179. end
  180.  
  181. function isCursorInRectangle(x,y,w,h)
  182.     if isCursorShowing() then
  183.     local mx,my = getCursorPosition()
  184.     local cursorx,cursory = mx*sx,my*sy
  185.         if cursorx > x and cursorx < x + w and cursory > y and cursory < y + h then
  186.             return true
  187.         else
  188.             return false
  189.         end
  190.     end
  191. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement