Om. Posted December 5, 2016 Share Posted December 5, 2016 --[[ -- Resource Name: Information. -- Author: Om (RipeMangoes69) -- Date: 4/12/2016 -- File: client.lua ]]-- -- GUI GUIEditor = { window = {}, label = {}, memo = {} } function createInfoObjects() local markers = { {area = "Los Santos Airport", x = 1582.45, y = -2286.32, z = 12}, {area = "Las Vegas Airport", x = 1674.30859375, y = 1444.9501953125, z = 9.2} } for _, m in ipairs(markers) do local marker = createMarker(m.x, m.y, m.z, "cylinder", 1, 255, 255, 255, 100) GUIEditor.window[1] = guiCreateWindow(645, 250, 266, 378, "Information: " .. m.area, false) guiWindowSetSizable(GUIEditor.window[1], false) guiSetVisible(GUIEditor.window[1], false) GUIEditor.label[1] = guiCreateLabel(5, 353, 190, 15, "* Click anywhere on GUI Window to close it.", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[1], "default-small") GUIEditor.memo[1] = guiCreateMemo(9, 24, 247, 324, "", false, GUIEditor.window[1]) guiMemoSetReadOnly(GUIEditor.memo[1], true) end end addEventHandler("onClientResourceStart", getRootElement(), createInfoObjects) function openGUI( hitElement, matchingDimension ) if getElementType( hitElement ) == "player" then if isPedInVehicle(hitElement) then outputChatBox("You cannot access GUI from vehicle!", 255, 0, 0) guiSetVisible(GUIEditor.window[1], false) showCursor(false) else guiSetVisible(GUIEditor.window[1], true) showCursor(true) end end end addEventHandler("onClientMarkerHit", resourceRoot, openGUI) function closeGUI() guiSetVisible(GUIEditor.window[1], false) showCursor(false) end addEventHandler("onClientGUIClick", resourceRoot, closeGUI) How am i suppose to "change" the GUI Title ? (area in the table). thanks. Link to comment
LoPollo Posted December 5, 2016 Share Posted December 5, 2016 Honestly if you need to change a window title... it's very possible that there's a better way to do it (or at least respecting mta's limits) Yep, there's no function to change the title. A workaround may be crating a temp window with the new title, move all elements of the old window to the new one, destroy the old window and assign the temp window to the old var Link to comment
Om. Posted December 5, 2016 Author Share Posted December 5, 2016 2 minutes ago, LoPollo said: Honestly if you need to change a window title... it's very possible that there's a better way to do it (or at least respecting mta's limits) Yep, there's no function to change the title. A workaround may be crating a temp window with the new title, move all elements of the old window to the new one, destroy the old window and assign the temp window to the old var gotta try it' thanks Link to comment
Savannah Posted December 5, 2016 Share Posted December 5, 2016 Won't GuiSetText work? 1 Link to comment
LoPollo Posted December 5, 2016 Share Posted December 5, 2016 2 hours ago, Savannah said: Won't GuiSetText work? I tested and it's working. @Om. now has his answer, and @Savannah gets my +1. I didn't knew this, ty Link to comment
Om. Posted December 6, 2016 Author Share Posted December 6, 2016 23 hours ago, Savannah said: Won't GuiSetText work? It works, but it does not change, it remains stable. since last is SF Airport, Title comes of SF for all GUIs. anyways this is solved, thank you 20 hours ago, LoPollo said: I tested and it's working. @Om. now has his answer, and @Savannah gets my +1. I didn't knew this, ty You probably tested only in easten bay airport. Link to comment
LoPollo Posted December 6, 2016 Share Posted December 6, 2016 2 hours ago, Om. said: You probably tested only in easten bay airport. I only tested if the function works with a windows elements, before i thought that it would only work with text in the "body" of a gui, like buttons. I don't have much time and so usually i can't test the a whole script. Link to comment
Swagy Posted December 6, 2016 Share Posted December 6, 2016 --[[ -- Resource Name: Information. -- Author: Om (RipeMangoes69) -- Date: 4/12/2016 -- File: client.lua ]]-- -- GUI GUIEditor = { window = {}, label = {}, memo = {} } GUIEditor.window[1] = guiCreateWindow(645, 250, 266, 378, "Information: " .. m.area, false) guiWindowSetSizable(GUIEditor.window[1], false) guiSetVisible(GUIEditor.window[1], false) GUIEditor.label[1] = guiCreateLabel(5, 353, 190, 15, "* Click anywhere on GUI Window to close it.", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[1], "default-small") GUIEditor.memo[1] = guiCreateMemo(9, 24, 247, 324, "", false, GUIEditor.window[1]) guiMemoSetReadOnly(GUIEditor.memo[1], true) local markers = {} function createInfoObjects() local markers = { {area = "Los Santos Airport", x = 1582.45, y = -2286.32, z = 12}, {area = "Las Vegas Airport", x = 1674.30859375, y = 1444.9501953125, z = 9.2} } for i, m in ipairs(markers) do local marker = createMarker(m.x, m.y, m.z, "cylinder", 1, 255, 255, 255, 100) markers[marker] = i end end addEventHandler("onClientResourceStart", getRootElement(), createInfoObjects) function openGUI( hitElement, matchingDimension ) if getElementType( hitElement ) == "player" and markers[source] then if isPedInVehicle(hitElement) then outputChatBox("You cannot access GUI from vehicle!", 255, 0, 0) guiSetVisible(GUIEditor.window[1], false) showCursor(false) else guiSetVisible(GUIEditor.window[1], true) guiSetText(GUIEditor.window[1],makers[source]["area"]) showCursor(true) end end end addEventHandler("onClientMarkerHit", resourceRoot, openGUI) function closeGUI() guiSetVisible(GUIEditor.window[1], false) showCursor(false) end addEventHandler("onClientGUIClick", resourceRoot, closeGUI) Link to comment
Sticmy Posted December 7, 2016 Share Posted December 7, 2016 Try to try so, I am Latin and I do not know much English. GUIEditor = { window = {}, label = {}, memo = {} } function createInfoObjects() local markers = { {"Los Santos Airport", 582.45, -2286.32, 12}, {"Las Vegas Airport", 1674.30859375, 1444.9501953125, 9.2} } for _, v in ipairs(markers) do local marker = createMarker(m.x, m.y, m.z, "cylinder", 1, 255, 255, 255, 100) GUIEditor.window[1] = guiCreateWindow(645, 250, 266, 378, "Information: " .. v.[1], false) guiWindowSetSizable(GUIEditor.window[1], false) guiSetVisible(GUIEditor.window[1], false) GUIEditor.label[1] = guiCreateLabel(5, 353, 190, 15, "* Click anywhere on GUI Window to close it.", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[1], "default-small") GUIEditor.memo[1] = guiCreateMemo(9, 24, 247, 324, "", false, GUIEditor.window[1]) guiMemoSetReadOnly(GUIEditor.memo[1], true) end end addEventHandler("onClientResourceStart", getRootElement(), createInfoObjects) 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