
Untitled
By: a guest on
May 7th, 2012 | syntax:
Lua | size: 1.72 KB | hits: 16 | expires: Never
messages = {}
addEventHandler ("onClientResourceStart", resourceRoot,
function ()
local resX, resY = guiGetScreenSize ()
msgWindow = (resX/2, resY/2, 300, 400, "UGC Random Messages", false)
guiSetVisible (msgWindow, false)
msgText = guiCreatLabel ( 15, 75,241, 300, "Add a message here so it will be showed every 15 minutes. /n Note: If there's more than one, the message will be random", false, msgWindow)
guiSetFont (msgText, "default-bold-small")
msgGrid = guiCreateGridList (15, 125, 350, 350, false, msgWindow)
msgColumn = guiGridListAddColumn ( msgGrid, "Messages", 0.75)
msgEdit = guiCreateEdit (15, 500, 25, 350, "Add your message here", false, msgWindow)
guiEditSetMaxLength (msgEdit, 120)
msgAddBtn = guiCreateButton (375, 425, 50, 50, "Add", false, msgWindow)
msgRemBtn = guiCreateButton (375, 370, 50, 50, "Remove", false, msgWindow)
addEventHandler ("onClientGUIClick", msgAddBtn,
function add ()
msgEditText = guiGetText (msgEdit)
table.insert ( messages, { msg = msgEditText, number = (0 + 1) * (add) } )
end
for k, v in ipairs (messages) do
msgRow = guiGridListAddRow (msgGrid)
guiGridListSetItemText ( msgGrid, msgRow, msgColumn, (v.number) .. ". " .. (v.msg), false, false)
end
end)
addEventHandler ("onClientGUIClick", msgRemBtn,
function
msgSel = guiGridListGetSelectedItem ( msgGrid )
guiGridListRemoveRow (msgGrid, msgSel )
table.remove (messages, msg, number)
end)
)
function showGUI2 ()
if ( guiGetVisible( msgWindow ) )then
guiSetVisible( msgWindow, false )
showCursor( false )
else then
guiSetVisible ( msgWindow, true )
showCursor ( true )
end
end
addCommandHandler ("msg", showGUI2)