undefined Posted July 24, 2014 Share Posted July 24, 2014 Hi guys. Im work on the new freeroam. I have question on the map option. When the player click on the map image, how to get map position? Link to comment
Bonsai Posted July 24, 2014 Share Posted July 24, 2014 Math. Image has a certain size, gta world is 3000x3000 units as far as I remember, so you can calculate it. Link to comment
undefined Posted July 24, 2014 Author Share Posted July 24, 2014 I'm try to do but can't. Can you give some insight? Link to comment
Blaawee Posted July 26, 2014 Share Posted July 26, 2014 Look for 'updatePlayerBlips' function at the freeroam resource. Maybe you will find out what do you need. Link to comment
iMr.TZ[W]ER Posted July 26, 2014 Share Posted July 26, 2014 just copy the original codes from the original freeroam Link to comment
undefined Posted September 1, 2014 Author Share Posted September 1, 2014 addEventHandler("onClientGUIClick", guiRoot, function(button, state, absoluteX, absoluteY) if source == mapImage then local imgX, imgY = guiGetSize(mapImage, false) local relX = absoluteX/imgX local relY = absoluteY/imgY local x = relX*6000 - 3000 local y = 3000 - relY*6000 local hit, hitX, hitY, hitZ hit, hitX, hitY, hitZ = processLineOfSight(x, y, 3000, x, y, -3000) guiSetText(mapXedit, x) guiSetText(mapYedit, y) guiSetText(mapZedit, hitZ or 0) end end) It's my code. I did got a sample from Freeroam. But it's not work true. How to make it? Help Link to comment
Skuleris Posted September 2, 2014 Share Posted September 2, 2014 (edited) addEventHandler("onClientGUIClick", guiRoot, function(button, state, absoluteX, absoluteY) if source == mapImage then local relX, relY = guiGetSize(mapImage, true) local x = relX*6000 - 3000 local y = 3000 - relY*6000 local hit, hitX, hitY, hitZ = processLineOfSight(x, y, 3000, x, y, -3000) guiSetText(mapXedit, x) guiSetText(mapYedit, y) guiSetText(mapZedit, hitZ or 0) end end) Maybe this Edited September 2, 2014 by Guest Link to comment
Karuzo Posted September 2, 2014 Share Posted September 2, 2014 Math.Image has a certain size, gta world is 3000x3000 units as far as I remember, so you can calculate it. It is 6000x6000. Tho it can go up to 8192 or smth like that (but that is just water). Link to comment
undefined Posted September 2, 2014 Author Share Posted September 2, 2014 addEventHandler("onClientGUIClick", guiRoot, function(button, state, absoluteX, absoluteY) if source == mapImage then local relX, relY = guiGetSize(mapImage, true) local x = relX*6000 - 3000 local y = 3000 - relY*6000 local hit, hitX, hitY, hitZ = processLineOfSight(x, y, 3000, x, y, -3000) guiSetText(mapXedit, x) guiSetText(mapYedit, y) guiSetText(mapZedit, hitZ or 0) end end) Maybe this No, it's not work. Because you're get the only image size. It's need the clicked position. Help Link to comment
Bonsai Posted September 2, 2014 Share Posted September 2, 2014 Sorry, but there is a freeroam resource thats does exactly the same thing. Just search those files until u find the stuff that you need. Takes 20 minutes. Link to comment
undefined Posted September 2, 2014 Author Share Posted September 2, 2014 I was searched this but i didn't find it. Link to comment
Et-win Posted September 2, 2014 Share Posted September 2, 2014 Just search for (Probably) 'onClient(GUI)Click'.. (Or maybe double-click) Link to comment
undefined Posted September 2, 2014 Author Share Posted September 2, 2014 (edited) -- [fr_client.lua] onClick function fillInPosition(relX, relY, btn) -- Line 624 if (btn == 'right') then closeWindow (wndSetPos) return end local x = relX*6000 - 3000 local y = 3000 - relY*6000 local hit, hitX, hitY, hitZ hit, hitX, hitY, hitZ = processLineOfSight(x, y, 3000, x, y, -3000) setControlNumbers(wndSetPos, { x = x, y = y, z = hitZ or 0 }) end -- [gui.lua] define the relX and relY function _buildWindow(wnd, baseWnd, parentWnd) -- Line 136 local wndClass = wnd[1] if wndClass == 'br' then return end local relX, relY, relWidth, relHeight if parentWnd then if wnd.x and wnd.y then relX = wnd.x/parentWnd.width relY = wnd.y/parentWnd.height end relWidth = wnd.width / parentWnd.width relHeight = wnd.height / parentWnd.height end local elem if wndClass == 'wnd' then local screenWidth, screenHeight = guiGetScreenSize() if not wnd.x then wnd.x = screenWidth/2 - wnd.width/2 else local i, f = math.modf(wnd.x) if f ~= 0 then wnd.x = screenWidth * wnd.x end if wnd.x < 0 then wnd.x = screenWidth - math.abs(wnd.x) - wnd.width end end if not wnd.y then wnd.y = screenHeight/2 - wnd.height/2 else local i, f = math.modf(wnd.y) if f ~= 0 then wnd.y = screenHeight * wnd.y end if wnd.y < 0 then wnd.y = screenHeight - math.abs(wnd.y) - wnd.height end end -- Bla bla bla bla if wnd.controls then for id, controlwnd in pairs(wnd.controls) do _buildWindow(controlwnd, baseWnd or wnd, wnd) end end if wnd.tabs then for id, tab in pairs(wnd.tabs) do _buildWindow(tab, baseWnd, wnd) end end -- Bla bla bla bla end parentWnd.width = map image x size parentWnd.height = map image y size But i dont understand wnd.x and wnd.y Edited September 2, 2014 by Guest Link to comment
Et-win Posted September 2, 2014 Share Posted September 2, 2014 Search for 'wnd' then, because it's a table. Link to comment
undefined Posted September 3, 2014 Author Share Posted September 3, 2014 I can't. I can't find defined the wnd.x and wnd.y... Link to comment
Skuleris Posted September 3, 2014 Share Posted September 3, 2014 --gui.lua:232 local imgX, imgY = getControlScreenPos(wnd) wnd.onclick((x - imgX)/wnd.width, (y - imgY)/wnd.height, btn) I figured out that this is where it calculates clicked position. getControlScreenPos returns the window offset to x,y locations. x,y position is 400,80 and gui offset is 200,50. You subtract from clicked position offset position and get exactly map position, which is divided by window size. Link to comment
undefined Posted September 3, 2014 Author Share Posted September 3, 2014 When the clicked on the image, the game is give very lag then it's give this error; Link to comment
Skuleris Posted September 4, 2014 Share Posted September 4, 2014 I think you used getScreenControlPos function? Try instead guiGetPosition 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