Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- kocsi = { [420]=true }
- local isDragging = false
- local windowOffsetX, windowOffsetY = 0, 0
- local myFont = dxCreateFont("taximeter/roboto.ttf",14)
- local sx, sy = guiGetScreenSize()
- windowWidth, windowsHeight = 552, 202
- posX = sx-400
- posY = sy-350
- local clockFont = dxCreateFont("taximeter/font.ttf",20)
- local megtettMeterek = 0
- local convertMeterToKm
- local showtaximeter = false
- local started = false
- addEvent('nullazas', true)
- addEventHandler('nullazas', root, function()
- local veh = getPedOccupiedVehicle(localPlayer)
- setElementData(veh,"taxi.megtettmeter",0)
- setElementData(veh,"taxi.ar",0)
- setElementData(veh,"taxi.megtettkm",0)
- megtettMeterek = 0
- end)
- function taxi (thePlayer)
- if showtaximeter then
- if getPedOccupiedVehicleSeat(localPlayer) == 0 then
- local vehicle = getPedOccupiedVehicle(getLocalPlayer())
- if getElementData(vehicle, "taxi.megtettmeter") == 0 or getElementData(vehicle, "taxi.megtettmeter") == nil or getElementData(vehicle, "taxi.megtettmeter") == false then
- setElementData(vehicle,"taxi.megtettmeter",0)
- end
- if isCursorShowing() then
- cursorX, cursorY = getCursorPosition()
- cursorX, cursorY = cursorX * sx, cursorY * sy
- end
- if isDragging then
- posX, posY = cursorX + windowOffsetX, cursorY + windowOffsetY
- end
- if started == false then
- color = tocolor(108, 172, 111, 160)
- elseif started == true then
- color = tocolor(207, 0, 15, 160)
- end
- if started == false then
- if isCursorInRectangle(posX+13, posY + 90, 274, 45) then
- color = tocolor(108, 172, 111, 200)
- end
- elseif started == true then
- if isCursorInRectangle(posX+13, posY + 90, 274, 45) then
- color = tocolor(207, 0, 15, 200)
- end
- end
- dxDrawRectangle(posX, posY, 300, 150, tocolor(0, 0, 0, 160))
- dxDrawRectangle(posX+13, posY + 35, 274, 35, tocolor(0, 0, 0, 180))
- dxDrawRectangle(posX+13, posY + 90, 274, 45, color)
- dxDrawText('#F7CA18SosaCity Taxi #ffffff- Viteldíj (Ft):', posX+26, posY+5, sx, sy, tocolor(255, 255, 255, 255), 1, myFont, 'left', 'top', false, false, true, true)
- if started then
- dxDrawText('Leállítás', posX+300, posY+225, posX, posY, tocolor(255, 255, 255, 255), 1, myFont, 'center', 'center')
- else
- dxDrawText('Elindítás', posX+300, posY+225, posX, posY, tocolor(255, 255, 255, 255), 1, myFont, 'center', 'center')
- end
- convertMeterToKm = math.ceil((getElementData(getPedOccupiedVehicle(localPlayer),"taxi.megtettmeter")/1000))
- local maxNulla = 14
- local actualCharAmount = maxNulla - string.len(tostring(getElementData(getPedOccupiedVehicle(localPlayer),"taxi.megtettmeter")))
- local finalString = ""
- for i = 0, actualCharAmount, 1 do
- finalString = finalString .. "0"
- end
- dxDrawText(finalString .. "#7CC576" .. getElementData(vehicle,"taxi.megtettmeter"), posX+13+9, posY + 35, sx, sy, tocolor (255,255,255, 255), 1, clockFont, "left","top",true,true,true,true,true)
- else
- local vehicle = getPedOccupiedVehicle(getLocalPlayer())
- if getElementData(vehicle, "taxi.megtettmeter") == 0 or getElementData(vehicle, "taxi.megtettmeter") == nil or getElementData(vehicle, "taxi.megtettmeter") == false then
- setElementData(vehicle,"taxi.megtettmeter",0)
- end
- if isCursorShowing() then
- cursorX, cursorY = getCursorPosition()
- cursorX, cursorY = cursorX * sx, cursorY * sy
- end
- if isDragging then
- posX, posY = cursorX + windowOffsetX, cursorY + windowOffsetY
- end
- dxDrawRectangle(posX, posY, 300, 150, tocolor(0, 0, 0, 160))
- dxDrawRectangle(posX+13, posY + 35, 274, 35, tocolor(0, 0, 0, 180))
- dxDrawText('#F7CA18SosaCity Taxi #ffffff- Viteldíj (Ft):', posX+26, posY+5, sx, sy, tocolor(255, 255, 255, 255), 1, myFont, 'left', 'top', false, false, true, true)
- convertMeterToKm = math.ceil((getElementData(getPedOccupiedVehicle(localPlayer),"taxi.megtettmeter")/1000))
- local maxNulla = 14
- local actualCharAmount = maxNulla - string.len(tostring(getElementData(getPedOccupiedVehicle(localPlayer),"taxi.megtettmeter")))
- local finalString = ""
- for i = 0, actualCharAmount, 1 do
- finalString = finalString .. "0"
- end
- dxDrawText(finalString .. "#7CC576" .. getElementData(vehicle,"taxi.megtettmeter"), posX+13+9, posY + 35, sx, sy, tocolor (255,255,255, 255), 1, clockFont, "left","top",true,true,true,true,true)
- end
- end
- end
- addEventHandler("onClientRender", getRootElement(), taxi)
- 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
- function calculateMeters(vehicle)
- local x, y, z = getElementPosition(vehicle)
- if (math.ceil(getDistanceBetweenPoints2D(oldX, oldY, x, y))-1 >= 1) then
- megtettMeterek = megtettMeterek+math.ceil(getDistanceBetweenPoints2D(oldX, oldY, x, y))-1
- oldX, oldY = x, y
- -- Adatok Beállítása
- triggerServerEvent("setTaxiDataToValue",localPlayer,localPlayer,getPedOccupiedVehicle(localPlayer),megtettMeterek,convertMeterToKm,convertMeterToKm * 10)
- end
- end
- function initializeCounter(s)
- if s then
- local vehicle = getPedOccupiedVehicle(localPlayer)
- if (not vehicle) then return end
- local x, y, z = getElementPosition(vehicle)
- oldX, oldY, oldZ = x, y, z
- meterCounter = setTimer(calculateMeters, 1000, 0, vehicle)
- else
- if isTimer(meterCounter) then
- killTimer(meterCounter)
- end
- megtettMeterek = getElementData(getPedOccupiedVehicle(localPlayer),"taxi.megtettmeter")
- convertMeterToKm = getElementData(getPedOccupiedVehicle(localPlayer),"taxi.megtettkm")
- end
- end
- function menuClick(gomb,stat,x,y)
- if gomb == "left" and stat == "down" then
- if showtaximeter then
- if getPedOccupiedVehicleSeat(localPlayer) == 0 then
- if dobozbaVan(posX+13, posY + 90, 274, 45,x,y) then
- local vehicle = getPedOccupiedVehicle(localPlayer)
- if started == false then
- started = true
- setElementData(vehicle, "started", false)
- initializeCounter(true)
- local alap = playSound('taximeter/taxibutton.mp3')
- setSoundVolume(alap, 0.2)
- elseif started == true then
- started = false
- setElementData(vehicle, "started", true)
- initializeCounter(false)
- local alap2 = playSound('taximeter/taxibutton.mp3')
- setSoundVolume(alap2, 0.2)
- if getElementData(vehicle,"taxi.megtettmeter") > 0 then
- local alap3 = playSound('taximeter/taxiprint.mp3')
- setSoundVolume(alap3, 0.2)
- local x, y, z = getElementPosition(vehicle)
- oldX, oldY, oldZ = x, y, z
- initializeCounter(false)
- end
- end
- end
- end
- if x >= posX and x < posX + 300 and y >= posY and y < posY + 35 then
- windowOffsetX, windowOffsetY = (posX) - x, (posY) - y
- isDragging = true
- end
- end
- end
- if gomb == "left" and stat == "up" and isDragging then
- if showtaximeter then
- isDragging = false
- end
- end
- end
- addEventHandler("onClientClick", getRootElement(), menuClick)
- 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 isInSlot(xS,yS,wS,hS)
- if(isCursorShowing()) then
- XY = {guiGetScreenSize()}
- local cursorX, cursorY = getCursorPosition()
- cursorX, cursorY = cursorX*XY[1], cursorY*XY[2]
- if(dobozbaVan(xS,yS,wS,hS, cursorX, cursorY)) then
- return true
- else
- return false
- end
- end
- end
- function EnterVehicle(thePlayer,seat)
- if thePlayer ~= getLocalPlayer() then return end
- if getElementModel(source) == 420 or getElementModel(source) == 438 then
- showtaximeter = true
- outputChatBox("#ffffff[#6cac6fSosa #ffffff- #FFA700Taxi#ffffff] A Taxiórát a '#53bfdc/togtaximeter#ffffff' parancsal tudod eltüntetni.",255,0,0,true)
- outputChatBox("#ffffff[#6cac6fSosa #ffffff- #FFA700Taxi#ffffff] Kifizetni az utat a '#53bfdc/paytaxi#ffffff' parancsal tudod elvégezni.",255,0,0,true)
- end
- end
- addEventHandler("onClientVehicleEnter",getRootElement(),EnterVehicle)
- function ExitVehicle(thePlayer,seat)
- if thePlayer ~= getLocalPlayer() then return end
- if getElementModel(source) == 420 or getElementModel(source) == 438 then
- showtaximeter = false
- end
- end
- addEventHandler("onClientVehicleExit",getRootElement(),ExitVehicle)
- function togtax()
- if not showtaximeter then
- showtaximeter = true
- elseif showtaximeter then
- showtaximeter = false
- end
- end
- addCommandHandler("togtaximeter",togtax)
Add Comment
Please, Sign In to add comment