Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local activeTab = nil
- local sx, sy = guiGetScreenSize()
- local tabW, tabH, tabX, tabY = 400, 300, sx/2 - 200, sy/2 - 150
- local dxFont = dxCreateFont("font.ttf", 10*2, false)
- addEventHandler('onClientResourceStart', root, function()
- setElementData(localPlayer, 'working', 0)
- end)
- local carMarker = {
- {1089.845703125, -1246.544921875, 14.82715034484},
- {1097.19921875, -1246.59765625, 14.8203125},
- {1106.87109375, -1228.31640625, 14.827150344849},
- {1095.9873046875, -1227.8359375, 14.8203125},
- }
- local boxMarker = {
- {1084.9228515625, -1219.7275390625, 16.812009811401},
- {1086.806640625, -1186.3486328125, 17.308547973633},
- {1098.7294921875, -1182.3349609375, 17.40899848938},
- }
- local endMarker = {
- {2868.5654296875, -1457.73046875, 9.963136672974},
- {2407.0810546875, -1958.0478515625, 12.546875},
- {2246.4541015625, -1966.4228515625, 12.548511505127},
- {1941.3876953125, -2086.052734375, 12.556798934937},
- {1155.4501953125, -1859.5244140625, 12.546908378601},
- {333.654296875, -1373.0556640625, 13.299780845642},
- }
- for k, v in ipairs (carMarker) do
- marker = createMarker(v[1], v[2], v[3], "checkpoint", 3, 108, 172, 111, 180)
- setElementData(marker, 'job', 1)
- end
- for k, v in ipairs (boxMarker) do
- marker = createMarker(v[1], v[2], v[3], "checkpoint", 2, 249, 105, 14, 180)
- setElementData(marker, 'csomagfelvetel', 1)
- end
- addEventHandler("onClientKey", root, function(gomb, state)
- if getElementData(localPlayer, "csomaghordas") == 1 then
- 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
- cancelEvent()
- end
- end
- end)
- addEventHandler('onClientMarkerHit', root,
- function(hitElement, hitDimension)
- if getElementData(source, 'job') == 1 and hitElement == localPlayer and getElementData(hitElement, "job") == 1 then
- local kocsi = getPedOccupiedVehicle(hitElement)
- if not kocsi and getElementData(hitElement, "working") == 0 then
- activeTab = 'carChoose'
- setElementFrozen(hitElement, true)
- elseif kocsi and getElementModel(kocsi) == 456 then
- activeTab = 'carDelete'
- setElementFrozen(kocsi, true)
- toggleControl("enter_exit", false)
- end
- elseif getElementData(source, 'csomag') == 1 and hitElement == localPlayer and getElementData(hitElement, "job") == 1 then
- if getElementData(hitElement, 'csomaghordas') == 1 then
- local veh = getElementData(source, 'car')
- if getElementData(veh, "id") == getElementData(hitElement, "playerid") then
- triggerServerEvent("deAttachBox", hitElement, hitElement)
- if getElementData(veh, "boxes") < 20 then
- setElementData(veh, "boxes", getElementData(veh, "boxes") + 1)
- outputChatBox("Bent lévő dobozok: "..getElementData(veh, "boxes").." a 20-ból.", 255, 255, 255, true)
- elseif getElementData(veh, "boxes") == 20 then
- local rand = math.random(#endMarker)
- marker = createMarker(endMarker[rand][1], endMarker[rand][2], endMarker[rand][3], 'checkpoint', 2, 207, 0, 15, 100)
- setElementData(marker, 'leadas', 1)
- outputChatBox("A jármű raktere tele van. Mehetsz fuvaroni.", 255, 255, 255, true)
- end
- end
- end
- elseif getElementData(source, 'csomagfelvetel') == 1 and hitElement == localPlayer and getElementData(hitElement, "job") == 1 then
- felvesz()
- elseif getElementData(source, 'leadas') == 1 and hitElement == localPlayer and getElementData(hitElement, "job") == 1 then
- local kocsi = getPedOccupiedVehicle(hitElement)
- if kocsi then
- if getElementData(kocsi, "id") == getElementData(hitElement, "playerid") then
- if getElementData(kocsi, "boxes") > 0 then
- setElementData(kocsi, "boxes", 0)
- destroyElement(marker)
- 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)
- end
- end
- end
- end
- end
- )
- function felvesz()
- if getElementData(localPlayer, "csomaghordas") == 1 then return end
- triggerServerEvent("attachBox", localPlayer, localPlayer)
- end
- addEventHandler('onClientRender', root,
- function()
- if activeTab == 'carChoose' then
- local color, color2 = tocolor(0, 0, 0, 180), tocolor(0, 0, 0, 180)
- if isCursorInRectangle(sx/2 - 100, sy/2 - 45/2 + 70, 200, 45) then
- color = tocolor(108, 172, 111, 180)
- elseif isCursorInRectangle(sx/2 - 100, sy/2 - 45/2 + 120, 200, 45) then
- color2 = tocolor(207, 0, 15, 180)
- end
- dxDrawRectangle(tabX, tabY, tabW, tabH, tocolor(0, 0, 0, 180))
- --dxDrawRectangle(sx/2 - 175, sy/2 - 125, 350, 150, tocolor(0, 0, 0, 180))
- dxDrawRectangle(sx/2 - 100, sy/2 - 45/2 + 70, 200, 45, color)
- dxDrawText('EZT KÉREM', 0, 150, sx, sy, tocolor(255, 255, 255, 255), 1, dxFont, 'center', 'center')
- dxDrawRectangle(sx/2 - 100, sy/2 - 45/2 + 120, 200, 45, color2)
- dxDrawText('KILÉPÉS', 0, 250, sx, sy, tocolor(255, 255, 255, 255), 1, dxFont, 'center', 'center')
- elseif activeTab == 'carDelete' then
- local color, color2 = tocolor(0, 0, 0, 180), tocolor(0, 0, 0, 180)
- if isCursorInRectangle(sx/2 - 100, sy/2 - 45/2 + 70, 200, 45) then
- color = tocolor(207, 0, 15, 180)
- elseif isCursorInRectangle(sx/2 - 100, sy/2 - 45/2 + 120, 200, 45) then
- color2 = tocolor(207, 0, 15, 180)
- end
- dxDrawRectangle(tabX, tabY, tabW, tabH, tocolor(0, 0, 0, 180))
- --dxDrawRectangle(sx/2 - 175, sy/2 - 125, 350, 150, tocolor(0, 0, 0, 180))
- dxDrawRectangle(sx/2 - 100, sy/2 - 45/2 + 70, 200, 45, color)
- dxDrawText('leadás', 0, 150, sx, sy, tocolor(255, 255, 255, 255), 1, dxFont, 'center', 'center')
- dxDrawRectangle(sx/2 - 100, sy/2 - 45/2 + 120, 200, 45, color2)
- dxDrawText('KILÉPÉS', 0, 250, sx, sy, tocolor(255, 255, 255, 255), 1, dxFont, 'center', 'center')
- end
- end
- )
- addEventHandler('onClientClick', root,
- function(g, s, x, y)
- if g == 'left' and s == 'down' then
- if activeTab == 'carChoose' then
- if dobozbaVan(sx/2 - 100, sy/2 - 45/2 + 120, 200, 45, x, y) then
- activeTab = nil
- setElementFrozen(localPlayer, false)
- elseif dobozbaVan(sx/2 - 100, sy/2 - 45/2 + 70, 200, 45, x, y) then
- triggerServerEvent('job:addCar', localPlayer, localPlayer, 456)
- activeTab = nil
- setElementData(localPlayer, "working", 1)
- end
- elseif activeTab == 'carDelete' then
- if dobozbaVan(sx/2 - 100, sy/2 - 45/2 + 120, 200, 45, x, y) then
- activeTab = nil
- local kocsi = getPedOccupiedVehicle(localPlayer)
- setElementFrozen(kocsi, false)
- toggleControl("enter_exit", true)
- elseif dobozbaVan(sx/2 - 100, sy/2 - 45/2 + 70, 200, 45, x, y) then
- local kocsi = getPedOccupiedVehicle(localPlayer)
- if getElementData(kocsi, "id") == getElementData(localPlayer, "playerid") then
- triggerServerEvent('job:deleteCar', localPlayer, localPlayer, kocsi)
- activeTab = nil
- setElementData(localPlayer, "working", 0)
- else
- outputChatBox("Ez nem a te kocsid!", 255, 255, 255, true)
- end
- end
- end
- end
- end
- )
- function dobozbaVan(dX, dY, dSZ, dM, eX, eY)
- if(eX >= dX and eX <= dX+dSZ and eY >= dY and eY <= dY+dM) then
- return true
- else
- return false
- end
- end
- function isCursorInRectangle(x,y,w,h)
- if isCursorShowing() then
- local mx,my = getCursorPosition()
- local cursorx,cursory = mx*sx,my*sy
- if cursorx > x and cursorx < x + w and cursory > y and cursory < y + h then
- return true
- else
- return false
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement