Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --just a testing table you can remove this and add the one you have in skin shop script.
- local skinSelectionTable = {
- ["cj"] = 0,
- ["truth"] = 1,
- ["maccer"] = 2,
- ["andre"] = 3,
- ["Barry"] = 4,
- ["Barry Big"] = 5,
- ["emmet"] = 6,
- ["Taxi Driver"] = 7,
- ["janitor"] = 8,
- ["Normal Ped"] = 9
- }
- --creating the GUI
- function runGUI()
- guiMainWindow = guiCreateWindow(725, 275, 336, 478, "Guard", false)
- guiWindowSetSizable(guiMainWindow, false)
- guiGridList = guiCreateGridList(10, 25, 316, 379, false, guiMainWindow)
- guiGridListAddColumn(guiGridList, "Skin name", 0.5)
- guiGridListAddColumn(guiGridList, "Skin id", 0.5)
- guiCloseButton = guiCreateButton(16, 412, 127, 49, "Close", false, guiMainWindow)
- guiCreateButton = guiCreateButton(189, 412, 127, 49, "Choose Guard", false, guiMainWindow)
- guiSetVisible(guiMainWindow, false)
- -- to hide the GUI after they click "Close" button
- addEventHandler("onClientGUIClick", guiCloseButton, function()
- guiSetVisible(guiMainWindow, false)
- showCursor(false, true)
- end)
- addEventHandler("onClientGUIClick", guiCreateButton, createGuardHandler)
- populateGridlist()
- end
- --opening the GUI with the commandHandler.
- function openGUI()
- if not (guiGetVisible(guiMainWindow)) then
- guiSetVisible(guiMainWindow, true)
- showCursor(true, true)
- end
- end
- -- to add the table to the gridList
- function populateGridlist()
- for name, skin in pairs(skinSelectionTable) do
- local row = guiGridListAddRow(guiGridList)
- guiGridListSetItemText(guiGridList, row, 1, name, false, false)
- guiGridListSetItemText(guiGridList, row, 2, skin, false, false)
- guiGridListSetItemData(guiGridList, row, 1, tostring(skin))
- end
- end
- --creating event to trigger in server-sided in order to create the ped.
- function createGuardHandler(button, state)
- if (button == "left" and state == "up") then
- local row, col = guiGridListGetSelectedItem(guiGridList)
- if (row and col and row ~= -1 and col ~= -1) then
- selected = guiGridListGetItemData(guiGridList,row,col)
- selected = tonumber(selected)
- if (selected) then
- --you probably need to change this, couldnt find the CIT message export.
- outputChatBox("Guard has been chosen")
- guiSetVisible(guiMainWindow, false)
- showCursor(false, false)
- else
- --you probably need to change this, couldnt find the CIT error message export.
- outputChatBox("Error")
- end
- end
- end
- end
- --triggering the event here with a different commandHandler.
- function createGuard()
- if (selected) then
- local player = getLocalPlayer()
- triggerServerEvent("createGuardFromGUI", getRootElement(), selected, player)
- end
- end
- addCommandHandler("guard", createGuard)
- addCommandHandler("chooseguard", function()
- if not(guiMainWindow) then
- runGUI()
- end
- openGUI()
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement