Jump to content

help guiSetVisible


Dimos7

Recommended Posts

local GUIEditor = {
    window = {},
	button = {},
	tabpanel = {},
	edit = {},
	tab = {},
	gridlist = {},
	column = {},
	label = {},
	memo = {}
}

function createGangWindow()
    local screenWidth, screenHeight = guiGetScreenSize()
	local windowWidth, windowHeight = 867, 477
	local left, top = screenWidth/2 - windowWidth/2, screenHeight/2 - windowHeight/2
	if not getElementData(localPlayer, "gang") then
	    GUIEditor.window[1] = guiCreateWindow(left, top, windowWidth, windowHeight, "Gang Panel", false)
		GUIEditor.tabpanel[1] = guiCreateTabPanel(10, 36, 847, 444, false, GUIEditor.window[1])
		GUIEditor.tab[1] = guiCreateTab("Create gang", GUIEditor.tabpanel[1])
		GUIEditor.tab[2] = guiCreateTab("Choose Color", GUIEditor.tabpanel[1])
		GUIEditor.tab[3] = guiCreateTab("Options", GUIEditor.tabpanel[1])
		GUIEditor.label[1] = guiCreateLabel(48, 43, 56, 18, "Name:", false, GUIEditor.tab[1])
		GUIEditor.edit[1] = guiCreateEdit(144, 43, 144, 24, "", false, GUIEditor.tab[1])
		GUIEditor.button[1] = guiCreateButton(371, 43, 73, 25, "Create", false, GUIEditor.tab[1])
		GUIEditor.label[2] = guiCreateLabel(48, 43, 56, 18, "Color:", false, GUIEditor.tab[2])
		GUIEditor.edit[2] = guiCreateEdit(144, 43, 144, 24, "", false, GUIEditor.tab[2])
		GUIEditor.button[2] = guiCreateButton(371, 43, 73, 25, "Select", false, GUIEditor.tab[2])
		GUIEditor.label[3] = guiCreateLabel(48, 43, 56, 18, "Name:", false, GUIEditor.tab[3])
		GUIEditor.label[4] = guiCreateLabel(48, 90, 56, 18, "Color:", false, GUIEditor.tab[3])
		GUIEditor.edit[3] = guiCreateEdit(144, 43, 144, 24, "", false, GUIEditor.tab[3])
		GUIEditor.edit[4] = guiCreateEdit(144, 90, 144, 24, "", false, GUIEditor.tab[3])
		GUIEditor.button[3] = guiCreateButton(371, 43, 73, 25, "Change", false, GUIEditor.tab[3])
		GUIEditor.button[4] = guiCreateButton(371, 90, 73, 25, "Change", false, GUIEditor.tab[3])
	    guiSetVisible(GUIEditor.window[1], not guiGetVisible(GUIEditor.window[1]))
		showCursor(not isCursorShowing())
		guiSetInputEnabled(not guiGetInputEnabled())
   elseif getElementData(localPlayer, "gang") then
        GUIEditor.window[2] = guiCreateWindow(left, top, windowWidth, windowHeight, "Gang Panel", false)
		GUIEditor.tabpanel[2] = guiCreateTabPanel(10, 36, 847, 444, false, GUIEditor.window[2])
		GUIEditor.tab[4] = guiCreateTab("Rules", GUIEditor.tabpanel[2])
		GUIEditor.tab[5] = guiCreateTab("Manage", GUIEditor.tabpanel[2])
		GUIEditor.tab[6] = guiCreateTab("Members", GUIEditor.tabpanel[2])
		GUIEditor.tab[7] = guiCreateTab("Invite", GUIEditor.tabpanel[2])
		GUIEditor.tab[8] = guiCreateTab("Stats", GUIEditor.tabpanel[2])
		GUIEditor.tab[9] = guiCreateTab("Bank", GUIEditor.tabpanel[2])
		GUIEditor.memo[1] = guiCreateMemo(74, 36, 680, 351, "", false, GUIEditor.tab[4])
		GUIEditor.label[5] = guiCreateLabel(48, 43, 56, 18, "Name:", false, GUIEditor.tab[5])
		GUIEditor.label[6] = guiCreateLabel(48, 90, 56, 18, "Color:", false, GUIEditor.tab[5])
		GUIEditor.edit[5] = guiCreateEdit(144, 43, 144, 24, "", false, GUIEditor.tab[5])
		GUIEditor.edit[6] = guiCreateEdit(144, 90, 144, 24, "", false, GUIEditor.tab[5])
		GUIEditor.button[5] = guiCreateButton(371, 43, 73, 25, "Change", false, GUIEditor.tab[5])
		GUIEditor.button[6] = guiCreateButton(371, 43, 73, 25, "Change", false, GUIEditor.tab[5])
		GUIEditor.gridlist[1] = guiCreateGridList(10, 10, 631, 386, false, GUIEditor.tab[6])
		GUIEditor.column[1] = guiGridListAddColumn(GUIEditor.gridlist[1], "Name", 0.5)
		GUIEditor.column[2] = guiGridListAddColumn(GUIEditor.gridlist[1], "Status", 0.5)
		GUIEditor.column[3] = guiGridListAddColumn(GUIEditor.gridlist[1], "Level", 0.5)
		GUIEditor.column[4] = guiGridListAddColumn(GUIEditor.gridlist[1], "Location", 0.5)
		GUIEditor.button[7] = guiCreateButton(671, 120, 158, 41, "Toggle Leader", false, GUIEditor.tab[6])
		GUIEditor.button[8] = guiCreateButton(671, 188, 158, 41, "Kick, Player", false, GUIEditor.tab[6])
		GUIEditor.button[9] = guiCreateButton(671, 258, 158, 41, "Leave Gang", false, GUIEditor.tab[6])
		for _, v in ipairs(getElementsByType("player")) do
		    if getElementData(v, "gang") then
			   local row = guiGridListAddRow(GUIEditor.gridlist[1])
			   guiGridListSetItemText(GUIEditor.gridlist[1], row, GUIEditor.column[1], getPlayerName(v), false, false)
			   guiGridListSetItemData(GUIEditor.gridlist[1], row, GUIEditor.column[1], getPlayerName(v))
			   guiGridListSetItemText(GUIEditor.gridlist[1], row, GUIEditor.column[2], getElementData(v, "Status"), false, false)
			   guiGridListSetItemData(GUIEditor.gridlist[1], row, GUIEditor.column[2], getElementData(v, "Status"))
			   guiGridListSetItemText(GUIEditor.gridlist[1], row, GUIEditor.column[3], getElementData(v, "gang:level"), false, false)
			   guiGridListSetItemData(GUIEditor.gridlist[1], row, GUIEditor.column[3], getElementData(v, "gang:level"))
			   guiGridListSetItemText(GUIEditor.gridlist[1], row, GUIEditor.column[4], getElementData(v, "Location"), false, false)
			   guiGridListSetItemData(GUIEditor.gridlist[1], row, GUIEditor.column[4], getElementData(v, "Location"))
			end
		end
		GUIEditor.gridlist[2] = guiCreateGridList(10, 10, 631, 386, false, GUIEditor.tab[7])
		GUIEditor.column[5] = guiGridListAddColumn(GUIEditor.gridlist[2], "Players", 0.5)
		GUIEditor.button[10] = guiCreateButton(671, 120, 158, 41, "Inivte", false, GUIEditor.tab[7])
		for _, v in ipairs(getElementsByType("player")) do
		     if not getElementData(v, "gang") then
			    local row = guiGridListAddRow(GUIEditor.gridlist[2])
				guiGridListSetItemText(GUIEditor.gridlist[2], row, GUIEditor.column[5], getPlayerName(v), false, false)
				guiGridListSetItemData(GUIEditor.gridlist[2], row, GUIEditor.column[5], getPlayerName(v))
			end
	    end
		GUIEditor.gridlist[3] = guiCreateGridList(10, 10, 827, 411, false, GUIEditor.tab[8])
		GUIEditor.column[6] = guiGridListAddColumn(GUIEditor.gridlist[3], "Leaders", 0.5)
		GUIEditor.column[7] = guiGridListAddColumn(GUIEditor.gridlist[3], "Deaths", 0.5)
		GUIEditor.column[8] = guiGridListAddColumn(GUIEditor.gridlist[3], "Money", 0.5)
		for k, p in ipairs(getElementsByType("player")) do
		    if getElementData(p, "gang") then
			    row = guiGridListAddRow(GUIEditor.gridlist[3])
			   if getElementData(p, "gang:level") == "Leader" then
			      guiGridListSetItemText(GUIEditor.gridlist[3], row, GUIEditor.column[6], getPlayerName(p), false, false)
				  guiGridListSetItemData(GUIEditor.gridlist[3], row, GUIEditor.column[6], getPlayerName(p))
			  end
			  guiGridListSetItemText(GUIEditor.gridlist[3], row, GUIEditor.column[7], getElementData(p, "Deaths"), false, false)
			  guiGridListSetItemData(GUIEditor.gridlist[3], row, GUIEditor.column[7], getElementData(p, "Deaths"))
			  guiGridListSetItemData(GUIEditor.gridlist[3], row, GUIEditor.column[8], getElementData(p, "gang:money"), false, false)
			  guiGridListSetItemData(GUIEditor.gridlist[3], row, GUIEditor.column[8], getElementData(p, "gang:money"))
			end
		end
		GUIEditor.gridlist[4] = guiCreateGridList(10,10 , 827, 411, false, GUIEditor.tab[9])
		GUIEditor.column[9] = guiGridListAddColumn(GUIEditor.gridlist[4], "Amount", 0.5)
		GUIEditor.column[10] = guiGridListAddColumn(GUIEditor.gridlist[4], "Action", 0.5)
		GUIEditor.column[11] = guiGridListAddColumn(GUIEditor.gridlist[4], "From", 0.5)
		for v, k in ipairs(getElementsByType("player")) do
		    if getElementData(k, "gang") then
			    row = guiGridListAddRow(GUIEditor.gridlist[4])
			   if getElementData(k, "gang:level") == "Leader" then
			      if getElementData(k, "gang:bank") then
			         guiGridListSetItemText(GUIEditor.gridlist[4], row, GUIEditor.column[9], getElementData(k, "gang:amount"), false, false)
				     guiGridListSetItemData(GUIEditor.gridlist[4], row, GUIEditor.column[9], getElementData(k, "gang:amount"))
					 guiGridListSetItemText(GUIEditor.gridlist[4], row, GUIEditor.column[10], getElementData(k, "gang:bankaction"), false, false)
					 guiGridListSetItemData(GUIEditor.gridlist[4], row, GUIEditor.column[10], getElementData(k, "gang:bankaction"))
					 guiGridListSetItemText(GUIEditor.gridlist[4], row, GUIEditor.column[11], getPlayerName(k), false, false)
					 guiGridListSetItemData(GUIEditor.gridlist[4], row, GUIEditor.column[1], getPlayerName(k))
				  end
			   end
			end
		end
		guiSetVisible(GUIEditor.window[2], not guiGetVisible(GUIEditor.window[2]))
		showCursor(not isCursorShowing())
		guiSetInputEnabled(not guiGetInputEnabled())
		if getElementData(localPlayer, "gang:level") ~= "Leader" then
		   guiMemoSetReadOnly(GUIEditor.memo[1], true)
		   guiSetVisible(GUIEditor.tab[7], false)
		   guiSetVisible(GUIEditor.tab[5], false)
		   guiSetVisible(GUIEditor.button[7], false)
		   guiSetVisible(GUIEditor.button[8], false)
	   end
    end
end	
bindKey("F3", "down", createGangWindow)

function createInviteWindow()
    local screenWidth, screenHeight = guiGetScreenSize()
	local windowWidth, windowHeight = 434, 139
	local left, top = screenWidth/2 - windowWidth/2, screenHeight/2 - windowHeight/2
     GUIEditor.window[3] = guiCreateWindow(left, top, windowWidth, windowHeight, "Gang Invite", false)
	 GUIEditor.label[7] = guiCreateLabel(10, 52, 414, 15, "You have been invite from gang "..getElementData(source, "gang").." do you want join?", false, GUIEditor.window[3])
	 GUIEditor.button[11] = guiCreateButton(58, 91, 47, 22, " Yes", false, GUIEditor.window[3])
	 GUIEditor.button[12] = guiCreateButton(162, 91, 47, 22, "No", false, GUIEditor.want[3])
end

addEventHandler("onClientGUIClick", root, 
function(button, state)
    if not GUIEditor.window[1] or not guiGetVisible(GUIEditor.window[1]) then return end
	if not GUIEditor.window[2] or not guiGetVisible(GUIEditor.window[2]) then return end
	if source == GUIEditor.button[1] then
	   gang = guiGetText(GUIEditor.edit[1])
	   triggerServerEvent("creategang", localPlayer, gang)
	elseif source == GUIEditor.button[2] or source == GUIEditor.button[4] or  source == GUIEditor.button[6] then
	    color = guiGetText(GUIEditor.edit[2]) or guiGetText(GUIEditor.edit[4]) or guiGetText(GUIEditor.edit[6])
		triggerServerEvent("setgangcolor", localPlayer, color)
		setElementData(localPlayer, "gang:color", color)
    elseif source == GUIEditor.button[3] or source == GUIEditor.button[5] then
	      gang = guiGetText(GUIEditor.edit[3]) or guiGetText(GUIEditor.edit[5])
		  triggerServerEvent("setgangname", localPlayer, gang)
   elseif source == GUIEditor.button[7] then
          if guiGridListGetSelectItem(GUIEditor.gridlist[1]) == -1 then outputChatBox("Select a player!", 255, 0, 0) return end
		  target = guiGridListGetItemData(GUIEditor.gridlist[1], guiGridListGetSelectItem(GUIEditor.gridlist[1]), 1)
		  if getElementData (target, "gang:level") == "member" then
		     setElementData(target, "gang:level", "Leader")
			 outputChatBox(getPlayerName(target).." promoted to leader of this gang!".." by "..getPlayerName(localPlayer))
		 else 
		    setElementData(target, "gang:level", "Member")
			outputChatBox(getPlayerName(target).." demoted to member of this gang!".." by "..getPlayerName(localPlayer))
	     end
    elseif source == GUIEditor.button[8] then 
	      if guiGridListGetSelectItem(GUIEditor.gridlist[1]) == -1 then outputChatBox("Select a player!", 255, 0, 0) return end
		  target = guiGridListGetItemData(GUIEditor.gridlist[1], guiGridListGetSelectItem(GUIEditor.gridlist[1]), 1)
		  setElementData(target, "gang", "N/A")
		  outputChatBox(getPlayerName(target).." has been kicked from gang!".." by "..getPlayerName(localPlayer))
    elseif source  == GUIEditor.button[9] then
	       setElementData(localPlayer, "gang", "N/A")
		   outputChatBox(getPlayerName(localPlayer).. "has left from gang!")
		   showCursor(false)
		   guiSetVisible(GUIEditor.window[2], false)
	elseif source == GUIEditor.button[10] then
	      if guiGridListGetSelectItem(GUIEditor.gridlist[2]) == -1 then outputChatBox("Select a player!", 255, 0, 0) return end
		  target = guiGridListGetItemData(GUIEditor.gridlist[2], guiGridListGetSelectItem(GUIEditor.gridlist[2]), 1)
		  outputChatBox(getPlayerName(target).." has been invite to the gang!")
		  if target then
		    createInviteWindow()
			guiSetVisible(GUIEditor.window[3], true)
			showCursor(true)
			if source == GUIEditor.button[11] then
			   setElementData(target, "gang", getElementData(localPlayer, "gang"))
			   setElementData(target, "gang:level", "Member")
			   outputChatBox("You join the gang".. getElementData(localPlayer, "gang"))
			   guiSetVisible(GUIEditor.window[3], false)
			   showCursor(false)
			elseif source == GUIEditor.button [12] then
			    guiSetVisible(GUIEditor.window[3], false)
			    showCursor(false)
		   end
		 end
	end
end)

the window not show up but the cursor does any help not error or warning

Edited by Dimos7
Link to comment

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...