Jump to content

[Help] A Gui Script


ForLaXPy

Recommended Posts

Well My probleme is About a GUI that I was creating , Well to be Clear with you guys This is about some chatboxes interface I made my chat list on a table called "sometabs" then I Added a Grid list to show each Tab chat logs and some others features but later I decided to Add a Grid List on the Left that will allow players to switch between Chatboxes Tabs But I dont Really Now what is the function that i should use I found the even onClientGUIClick but how I will call the tabs once the player click on a row of the grid List , anyway Here is a quick Screnshot of the GUI : http://imgur.com/uP1SHc3

 

and here  is the Code :

 



local rx, ry = guiGetScreenSize()
local eventDim = 336
local local_chat_range = 90
local chatspam = {["main"]=getTickCount(), ["main2"]=""}
local sometabs = {"Support", "Contact Admin", "Main", "Team", "Local", "Group", "Alliance", "Chat", "All", "Kills", "Trading"}
local tabs = {}
local cboxt = {}

function onClientStart()
    -- Load XML file
    rootXMLNode = xmlLoadFile("@chat.xml")
    if (not rootXMLNode) then
        rootXMLNode = xmlCreateFile("@chat.xml", "settings")
    end
    nodeValue = xmlNodeGetValue(rootXMLNode)

    chatwin = guiCreateWindow((rx/2)-400, (ry/2)-300, 800, 600, "Chat Interface", false)
    addEventHandler("onClientResourceStop", resourceRoot, function()
        if (guiGetVisible(chatwin)) then
            showCursor(false)
        end
    end)
    guiSetVisible(chatwin, false)
    guiSetAlpha(chatwin, 0.95)
    guiWindowSetSizable(chatwin, false)
    tabpanel = guiCreateTabPanel(9, 23, 622 + 159, 430 + 136, false, chatwin)


    for index, tab in pairs(sometabs) do
        local main = guiCreateTab(tab, tabpanel)
        local edit = guiCreateEdit(5, 350 + 136, 540 + 159, 30, "", false, main)
        local send = guiCreateButton(548 + 159, 350 + 136, 68, 30, "Close", false, main)
        local cbox = guiCreateCheckBox(6, 384 + 136, 120, 20, "Show in Chatbox", false, false, main)
        local beep = guiCreateCheckBox(146, 384 + 136, 120, 20, "Beep on Message", false, false, main)

		local grid = guiCreateGridList(190, 7, 581, 469, false, main) 

		local spawnScreenGridList = guiCreateGridList(6, 9, 174, 467, false, main)
		 guiGridListAddColumn ( spawnScreenGridList, "Chatboxs       ", 0.8 )
		for key,tab2 in pairs(sometabs) do
               local row = guiGridListAddRow ( spawnScreenGridList ) --get our new row
               guiGridListSetItemText ( spawnScreenGridList, row, 1, tab2, false, false )
        end

 guiGridListSetSortingEnabled(grid, false)
        addEventHandler("onClientGUIAccepted", edit, chatSend)
        local tab = string.lower(tab)
        if (string.find(nodeValue, tab)) then
            guiCheckBoxSetSelected(cbox, true)
        end
        addEventHandler("onClientGUIClick", cbox, function()
            if (guiCheckBoxGetSelected(source)) then
                nodeValue = nodeValue..";"..cboxt[source]..";"
            else
                nodeValue = string.gsub(nodeValue, ";"..cboxt[source]..";", "")
            end
            xmlNodeSetValue(rootXMLNode, nodeValue)
            xmlSaveFile(rootXMLNode)
        end, false)
        cboxt[cbox] = tab
        local label = guiCreateLabel(280, 386 + 136, 250, 20, "Use /"..tab.." message for use in chat box", false, main)
        tabs[tab] = {main, edit, send, grid, cbox, beep, label}
        addEventHandler("onClientGUIClick", send, function()
            guiSetVisible(chatwin, false)
            showCursor(false)
        end, false)
        guiGridListAddColumn(grid, "Time", 0.13)
        guiGridListAddColumn(grid, "Name and Message", 0.85)
        guiGridListAddRow(grid)
        guiGridListSetItemText(grid, 1, 1, "", false, false)
        addCommandHandler(tab, function(cmd, ...)
            if (getElementData(localPlayer, "o") ~= "Banned") then
                local edit, grid, cbox, beep = getEditBoxAndGridFromName(cmd)
                guiSetText(edit, table.concat({...}, " "))
                chatSend(edit)
            end
        end, false)
    end
end
addEventHandler("onClientResourceStart", resourceRoot, onClientStart)

 

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