Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ----------------------------------------->
- -- Project: Community, Integrity, Transparency
- -- Author: JaVa
- -- Date: 21 December 2017
- -- Resource: CITbarriers/gui.lua
- -- Version: 1.0
- ----------------------------------------->
- function setupGUI()
- local screenW, screenH = guiGetScreenSize()
- mainWindow = guiCreateWindow((screenW - 347) / 2, (screenH - 557) / 2, 347, 557, "Barriers", false)
- guiWindowSetSizable(mainWindow, false)
- guiSetAlpha(mainWindow, 1.00)
- guiSetVisible(mainWindow, false)
- removeAllBtn = guiCreateButton(10, 115, 197, 35, "Remove all barriers", false, mainWindow)
- barriersGridList = guiCreateGridList(9, 156, 325, 391, false, mainWindow)
- guiGridListAddColumn(barriersGridList, "Barrier Id", 0.3)
- guiGridListAddColumn(barriersGridList, "Description", 0.6)
- barriersDescriptions = {
- "Metal fence / Metal grid",
- "Wood barrier",
- "Tent",
- "Wood barrier with lights",
- "Sand bags 3 piles",
- "Sand bags 2 piles",
- "Boxes",
- "Pallets",
- "Concrete wall",
- "Barbed wire",
- "Red smoke",
- "House",
- "Bunker"
- }
- for i, v in ipairs(barriersDescriptions) do
- guiGridListAddRow(barriersGridList, i, v)
- end
- closeBtn = guiCreateButton(232, 115, 92, 35, "Close", false, mainWindow)
- placeBtn = guiCreateButton(9, 66, 88, 39, "Place", false, mainWindow)
- removeBtn = guiCreateButton(107, 66, 100, 39, "Remove" false, mainWindow)
- barrierLabel = guiCreateLabel(13, 28, 313, 28, "No barrier selected", false, mainWindow)
- guiSetFont(barrierLabel, "default-bold-small")
- guiLabelSetColor(barrierLabel, 35, 195, 254)
- guiLabelSetVerticalAlign(barrierLabel, "center")
- --Event Handlers
- addEventHandler("onClientGUIClick", closeBtn, showGUI, false)
- addEventHandler("onClientGUIClick", placeBtn, onClickPlaceButton, false)
- addEventHandler("onClientGUIClick", removeBtn, onClickRemoveButton, false)
- addEventHandler("onClientGUIClick", removeAllBtn, onClickRemoveAllButton, false)
- addEventHandler("onClientGUIClick", barriersGridList, onClickBarrierToSelect, false)
- end
- function showGUI()
- if (not mainWindow) then
- setupGUI()
- end
- local state = not guiGetVisible(mainWindow)
- guiSetVisible(mainWindow, state)
- showCursor(state)
- end
- addCommandHandler("barriers", showGUI)
- function onClickPlaceButton()
- local row = guiGridListGetSelectedItem(barriersGridList)
- local barrierId = guiGridListGetItemText(barriersGridList, row, 1)
- if (#barrierId <= 0) then
- outputChatBox("You should select a barrier to place.", 190, 0, 0)
- return false
- end
- executeCommandHandler("barrier", barrierId)
- end
- function onClickRemoveButton()
- local row = guiGridListGetSelectedItem(barriersGridList)
- local barrierId = guiGridListGetItemText(barriersGridList, row, 1)
- if (#barrierId <= 0) then
- outputChatBox("You should select a barrier to remove.", 190, 0, 0)
- return false
- end
- executeCommandHandler("removebarrier", barrierId)
- end
- function onClickRemoveAllButton()
- executeCommandHandler("removebarrier", "all")
- end
- function onClickBarrierToSelect()
- local row = guiGridListGetSelectedItem(barriersGridList)
- local barrierId = guiGridListGetItemText(barriersGridList, row, 1)
- local barrierName = guiGridListGetItemText(barriersGridList, row, 2)
- if (#barrierId <= 0) then
- guiSetText(barrierLabel, "No barrier selected")
- return false
- end
- guiSetText(barrierLabel, "Barrier Id: "..barrierId.."\n".."Barrier name: "..barrierName)
- end
Advertisement
Add Comment
Please, Sign In to add comment