Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/03/25 in all areas

  1. function onClientResourceStart() map = Map.new():init() map:setBounds(x*30, y*30, x*1306, y*708) map:setAlpha(200) radar = Map.new():init() radar:setBounds(x*20, y*560, x*281, y*193) radar:setStyle(2) radar:setAlpha(200) radar:setBlipSize(x*24) radar:setVisible(true) -- Variables to track mouse movement mouseDown = false lastX, lastY = 0, 0 map.Switch = function() local wasVisible = map:isVisible() map:setVisible(not wasVisible) radar:setVisible(not wasVisible) showChat(not wasVisible) -- Only show cursor and bind keys when map is visible if not wasVisible then showCursor(true) addEventHandler("onClientCursorMove", root, handleMouseMovement) addEventHandler("onClientMouseWheel", root, handleMouseWheel) addEventHandler("onClientClick", root, handleMouseClick) bindKey("mouse_wheel_up", "down", function() zoomMap("in") end) bindKey("mouse_wheel_down", "down", function() zoomMap("out") end) else showCursor(false) removeEventHandler("onClientCursorMove", root, handleMouseMovement) removeEventHandler("onClientMouseWheel", root, handleMouseWheel) removeEventHandler("onClientClick", root, handleMouseClick) unbindKey("mouse_wheel_up", "down") unbindKey("mouse_wheel_down", "down") end end bindKey('F11', 'down', map.Switch) setPlayerHudComponentVisible("radar", false) toggleControl("radar", false) end -- Function to handle mouse clicks for dragging function handleMouseClick(button, state) if map:isVisible() and button == "left" then if state == "down" then mouseDown = true local x, y = getCursorPosition() lastX, lastY = x, y else mouseDown = false end end end -- Function to handle mouse movement for dragging the map function handleMouseMovement(_, _, x, y) if map:isVisible() and mouseDown then local currentX, currentY = x, y local deltaX, deltaY = currentX - lastX, currentY - lastY -- Move map based on mouse movement local mapX, mapY, mapW, mapH = map:getBounds() -- Adjust movement sensitivity as needed local moveSpeed = 1.5 map:setBounds(mapX - deltaX * moveSpeed, mapY - deltaY * moveSpeed, mapW, mapH) lastX, lastY = currentX, currentY end end -- Function to handle mouse wheel for zooming function handleMouseWheel(direction) if map:isVisible() then zoomMap(direction > 0 and "in" or "out") end end -- Centralized zoom function function zoomMap(direction) if not map:isVisible() then return end local x, y, width, height = map:getBounds() local zoomFactor = 0.1 -- Adjust for faster/slower zooming if direction == "in" then -- Zoom in: decrease size, adjust position to zoom toward center local newWidth = width * (1 - zoomFactor) local newHeight = height * (1 - zoomFactor) local newX = x + (width - newWidth) / 2 local newY = y + (height - newHeight) / 2 map:setBounds(newX, newY, newWidth, newHeight) else -- Zoom out: increase size, adjust position to zoom from center local newWidth = width * (1 + zoomFactor) local newHeight = height * (1 + zoomFactor) local newX = x - (newWidth - width) / 2 local newY = y - (newHeight - height) / 2 map:setBounds(newX, newY, newWidth, newHeight) end end addEventHandler("onClientResourceStart", resourceRoot, onClientResourceStart) function onClientResourceStop() setPlayerHudComponentVisible("radar", true) toggleControl("radar", true) -- Clean up any remaining event handlers if map:isVisible() then removeEventHandler("onClientCursorMove", root, handleMouseMovement) removeEventHandler("onClientMouseWheel", root, handleMouseWheel) removeEventHandler("onClientClick", root, handleMouseClick) end end addEventHandler("onClientResourceStop", resourceRoot, onClientResourceStop)
    1 point
  2. yo puedo venderte uno, hecho desde 0, adaptado a tu servidor. discord: kaosblaze
    1 point
×
×
  • Create New...