Sign in to follow this  
Om.

[HELP] Information Marker Title.

Recommended Posts

--[[
-- 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.

Share this post


Link to post

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

Share this post


Link to post
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 

Share this post


Link to post
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.

Share this post


Link to post
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. 

Share this post


Link to post
  1. --[[
  2. -- Resource Name: Information.
  3. -- Author: Om (RipeMangoes69)
  4. -- Date: 4/12/2016
  5. -- File: client.lua
  6. ]]--
  7.  
  8. -- GUI
  9.  
  10.  
  11.  
  12. GUIEditor = {
  13. window = {},
  14. label = {},
  15. memo = {}
  16. }
  17.  
  18. GUIEditor.window[1] = guiCreateWindow(645, 250, 266, 378, "Information: " .. m.area, false)
  19. guiWindowSetSizable(GUIEditor.window[1], false)
  20. guiSetVisible(GUIEditor.window[1], false)
  21. GUIEditor.label[1] = guiCreateLabel(5, 353, 190, 15, "* Click anywhere on GUI Window to close it.", false, GUIEditor.window[1])
  22. guiSetFont(GUIEditor.label[1], "default-small")
  23. GUIEditor.memo[1] = guiCreateMemo(9, 24, 247, 324, "", false, GUIEditor.window[1])
  24. guiMemoSetReadOnly(GUIEditor.memo[1], true)
  25. local markers = {}
  26.  
  1. function createInfoObjects()
  2. local markers = {
  3. {area = "Los Santos Airport", x = 1582.45, y = -2286.32, z = 12},
  4. {area = "Las Vegas Airport", x = 1674.30859375, y = 1444.9501953125, z = 9.2}
  5. }
  6.  
  7. for i, m in ipairs(markers) do
  8. local marker = createMarker(m.x, m.y, m.z, "cylinder", 1, 255, 255, 255, 100)
  9. markers[marker] = i
  10. end
  11. end
  12. addEventHandler("onClientResourceStart", getRootElement(), createInfoObjects)
  13.  
  14.  
  15. function openGUI( hitElement, matchingDimension )
  16. if getElementType( hitElement ) == "player" and markers[source] then
  17. if isPedInVehicle(hitElement) then
  18. outputChatBox("You cannot access GUI from vehicle!", 255, 0, 0)
  19. guiSetVisible(GUIEditor.window[1], false)
  20. showCursor(false)
  21. else
  22. guiSetVisible(GUIEditor.window[1], true)
  23. guiSetText(GUIEditor.window[1],makers[source]["area"])
  24. showCursor(true)
  25. end
  26. end
  27. end
  28. addEventHandler("onClientMarkerHit", resourceRoot, openGUI)
  29.  
  30. function closeGUI()
  31. guiSetVisible(GUIEditor.window[1], false)
  32. showCursor(false)
  33. end
  34. addEventHandler("onClientGUIClick", resourceRoot, closeGUI)

Share this post


Link to post

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)

 

Share this post


Link to post

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.