Jusonex Posted November 20, 2010 Share Posted November 20, 2010 Hello, how can I calc the coordinates/position from a map/image, like in resource "freeroam". Justus Link to comment
drake989 Posted November 20, 2010 Share Posted November 20, 2010 F1> map or something and you have coordinates x, y , z you can too press p if you have admin rights and too get coordinates ==beside ok, cancel Link to comment
Jusonex Posted November 20, 2010 Author Share Posted November 20, 2010 No, i don't mean that. I want to do this for a taxi system. The co-driver gets a map, if he enters a taxi and he can click on the position (like in freeroam). But how can I create that. (scripting) Sorry for bad english Link to comment
drake989 Posted November 20, 2010 Share Posted November 20, 2010 you mean If some guy enter taxi, shows map and he can choose place? Link to comment
Beluga Posted November 21, 2010 Share Posted November 21, 2010 Maybe you can open the freeroam resource and search where they put the code and learn from it. Link to comment
Jusonex Posted November 21, 2010 Author Share Posted November 21, 2010 Here is the code: function spawnMapDoubleClick(relX, relY) setPlayerPosition(relX*6000 - 3000, 3000 - relY*6000, 0) closeWindow(wndSpawnMap) end function closeSpawnMap() showCursor(false) removeEventHandler('onClientRender', g_Root, updatePlayerBlips) for elem,data in pairs(g_PlayerData) do for i,name in ipairs({'mapBlip', 'mapLabelShadow', 'mapLabel'}) do if data.gui[name] then destroyElement(data.gui[name]) data.gui[name] = nil end end end end wndSpawnMap = { 'wnd', text = 'Select spawn position', width = g_MapSide + 20, controls = { {'img', id='map', src='map.png', width=g_MapSide, height=g_MapSide, ondoubleclick=spawnMapDoubleClick}, {'lbl', text='Welcome to freeroam. Double click a location on the map to spawn.', width=g_MapSide-60, align='center'}, {'btn', id='close', closeswindow=true} }, oncreate = warpMapInit, onclose = closeSpawnMap } But I don't understand it. Have someone a better and simpler example? Link to comment
Jusonex Posted November 24, 2010 Author Share Posted November 24, 2010 (edited) Now, I habe that: function gui() local screenWidth, screenHeight = guiGetScreenSize() if screenHeight < 700 then g_MapSide = 450 else g_MapSide = 700 end local width = g_MapSide + 20 local height = g_MapSide local X = 0 local Y = 0 wdwMap = guiCreateWindow( X, Y, width, height, "Map", false ) imgMap = guiCreateStaticImage ( X, Y, g_MapSide, g_MapSide, "map.png", false, wdwMap ) addEventHandler("onClientGUIDoubleClick", imgMap, map, false) end function make() gui() if (wdwMap ~= nil) then guiSetVisible(wdwMap, true) else outputChatBox("Ein Problem mit der GUI besteht, bitte benachrichtige einen Admin") end showCursor(true) guiSetInputEnabled(true) end function map(button, state, relX, relY) local px = relX*6000 - 3000 local py = 3000 - relY*6000 outputChatBox(px) end addCommandHandler("taxi", make) But the results are wrong (if i click in the middle of the map i get cords like 400000. What is wrong? Edited August 28, 2012 by Guest Link to comment
MasterTobi Posted November 25, 2010 Share Posted November 25, 2010 hey ClientSide : function gui() local screenWidth, screenHeight = guiGetScreenSize() if screenHeight < 700 then g_MapSide = 450 else g_MapSide = 700 end local width = g_MapSide + 20 local height = g_MapSide local X = 0 local Y = 0 wdwMap = guiCreateWindow( X, Y, width, height, "Map", false ) imgMap = guiCreateStaticImage ( X, Y, g_MapSide, g_MapSide, "map.png", false, wdwMap ) addEventHandler("onClientGUIDoubleClick", imgMap, map, false) end function make() gui() if (wdwMap ~= nil) then guiSetVisible(wdwMap, true) else outputChatBox("Ein Problem mit der GUI besteht, bitte benachrichtige einen Admin") end showCursor(true) guiSetInputEnabled(true) end function map(button, state, relX, relY) px = ((relX*6000 /g_MapSide)-3000) py = (3000 - (relY*6000/g_MapSide)) triggerServerEvent("sp",getLocalPlayer(),px,py) guiSetVisible(wdwMap, false) showCursor(false) guiSetInputEnabled(false) end addCommandHandler("t", make) ServerSide function createmaker(x, y) createMarker ( x,y,13) end addEvent("sp",true) addEventHandler("sp",getRootElement(),createmaker,px,py) Link to comment
Jusonex Posted November 25, 2010 Author Share Posted November 25, 2010 thank you very very very much 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