fairyoggy Posted July 26, 2019 Share Posted July 26, 2019 Does anyone have such a script? or help write pls smth like map teleport from freeroom Window with a picture map and 3 edit's. When you click on the map area, coordinates are recorded in edits. Link to comment
HassoN Posted July 26, 2019 Share Posted July 26, 2019 With some calculations you may achieve your goal: addEventHandler -- onClientClick getPlayerMapBoundingBox -- calculations to get X,Y of the map getGroundPosition -- to get the Z position. setElementPosition -- send your player. Link to comment
fairyoggy Posted July 27, 2019 Author Share Posted July 27, 2019 UP. I do not understand how to do it . pls help Link to comment
fairyoggy Posted August 9, 2019 Author Share Posted August 9, 2019 (edited) up Edited August 9, 2019 by slapz0r Link to comment
fairyoggy Posted August 12, 2019 Author Share Posted August 12, 2019 (edited) local sx, sy = guiGetScreenSize() function centerWindow(center_window) local screenW,screenH=guiGetScreenSize() local windowW,windowH=guiGetSize(center_window,false) local x,y = (screenW-windowW)/2,(screenH-windowH)/2 guiSetPosition(center_window,x,y,false) end wndTpMap = guiCreateWindow(0,0,700,700,"Teleport map",false) centerWindow(wndTpMap) mapBlip = guiCreateStaticImage(40, 30, 610, 610, 'map.png', false, wndTpMap) close_TpMap = guiCreateButton(520,655,130,20,"Cancel",false,wndTpMap) wndTpMapX = guiCreateEdit(40,655,150,20,"",false,wndTpMap) wndTpMapY = guiCreateEdit(200,655,150,20,"",false,wndTpMap) wndTpMapZ = guiCreateEdit(360,655,150,20,"",false,wndTpMap) local targetBlipIcon = 41 local screenSize = Vector2(guiGetScreenSize()) local wasLeftMouseButtonPressed, wasRightMouseButtonPressed, targetBlip = false, false local function handleMapTargetBlip() if not isPlayerMapVisible() then showCursor(false, false) wasLeftMouseButtonPressed, wasRightMouseButtonPressed = false, false return end if not isCursorShowing() then showCursor(true, false) end local isLeftMouseButtonPressed = getKeyState("mouse1") if isLeftMouseButtonPressed and isLeftMouseButtonPressed ~= wasLeftMouseButtonPressed then local cursorPos, mapMin, mapMax = Vector2(getCursorPosition()) cursorPos.x, cursorPos.y = cursorPos.x * screenSize.x, cursorPos.y * screenSize.y do local mx, my, Mx, My = getPlayerMapBoundingBox() mapMin = Vector2(mx, my) mapMax = Vector2(Mx, My) end if cursorPos.x >= mapMin.x and cursorPos.y >= mapMin.y and cursorPos.x <= mapMax.x and cursorPos.y <= mapMax.y then local relPos = Vector2((cursorPos.x - mapMin.x) / (mapMax.x - mapMin.x), (cursorPos.y - mapMin.y) / (mapMax.y - mapMin.y)) local worldPlanePos = Vector2(6000 * (relPos.x - 0.5), 3000 - (relPos.y * 6000)) local worldPos = Vector3(worldPlanePos.x, worldPlanePos.y, getGroundPosition(worldPlanePos.x, worldPlanePos.y, 3000)) if not targetBlip then targetBlip = createBlip(worldPos, targetBlipIcon) else setElementPosition(targetBlip, worldPos) guiSetText(wndTpMapX,worldPlanePos.x) end end end local isRightMouseButtonPressed = getKeyState("mouse2") if targetBlip then if isRightMouseButtonPressed and isRightMouseButtonPressed ~= wasRightMouseButtonPressed then destroyElement(targetBlip) targetBlip = nil end end wasLeftMouseButtonPressed, wasRightMouseButtonPressed = isLeftMouseButtonPressed, isRightMouseButtonPressed end addEventHandler("onClientRender", root, handleMapTargetBlip) Now it's put a red mark on the map with a left click. How to use it in the picture? "mapBlip = guiCreateStaticImage(40, 30, 610, 610, 'map.png', false, wndTpMap)" Now it works for the map on f11 but i need for "mapBlip" Edited August 12, 2019 by slapz0r Link to comment
fairyoggy Posted August 15, 2019 Author Share Posted August 15, 2019 Still need help on this. Link to comment
WorthlessCynomys Posted August 15, 2019 Share Posted August 15, 2019 I do not understand what you want to achieve. Please provide further explanation of your goal so I/others can understand It and become able to help you! Link to comment
fairyoggy Posted August 16, 2019 Author Share Posted August 16, 2019 14 hours ago, WorthlessCynomys said: I do not understand what you want to achieve. Please provide further explanation of your goal so I/others can understand It and become able to help you! Above code: 1) Used map on f11 2) Left-clicking on the map creates a red mark 3) Coordinate(x) are recorded in edit (in the same way and (y) coordinate record on edit.) How to use a similar method, but for my map(map.png)? I mean, I created a window with a staticimage(map.png) and how to use the same method, but for this picture instead of the map on f11 ? Link to comment
DNL291 Posted August 20, 2019 Share Posted August 20, 2019 https://community.multitheftauto.com/index.php?p=resources&s=details&id=1970 Just edit the resource according to your needs. 1 Link to comment
fairyoggy Posted August 20, 2019 Author Share Posted August 20, 2019 3 minutes ago, DNL291 said: https://community.multitheftauto.com/index.php?p=resources&s=details&id=1970 Just edit the resource according to your needs. The file is compiled Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now