nokizorque

Untitled

Dec 16th, 2015
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 25.92 KB | None | 0 0
  1. adminPanel = {
  2.     tab = {},
  3.     label = {},
  4.     tabpanel = {},
  5.     edit = {},
  6.     gridlist = {},
  7.     window = {},
  8.     checkbox = {},
  9.     button = {}
  10. }
  11. confirm = {
  12.     button = {},
  13.     window = {},
  14.     label = {},
  15.     edit = {}
  16. }
  17.  
  18. function getSelectedPlayer()
  19.     local row = guiGridListGetSelectedItem(adminPanel.gridlist[1])
  20.     if (row ~= false and row ~= nil and row ~= -1) then
  21.         local player = guiGridListGetItemData(adminPanel.gridlist[1], row, 1)
  22.         return player
  23.     end
  24. end
  25.  
  26. local punishments = {
  27.     "#0: Removing Punishment",
  28.     "#0: Deathmatching",
  29.     "Bugged",
  30. }
  31.  
  32. local punishmentTimes = {
  33.     -- From punishments table
  34.     -- ["#0: Deathmatching"] = {[1] = 300, [2] = 600, [3] = 1200, [4] = 1800, [5] = 2400, [6] = ban (21600 - 6 hrs), -- repeat 6}
  35. }
  36.  
  37. --addEventHandler("onClientResourceStart", resourceRoot,
  38. --  function()
  39.         adminPanel.window[1] = guiCreateWindow(697, 262, 665, 504, "UCD | Administrative & Management Panel", false)
  40.         guiWindowSetSizable(adminPanel.window[1], false)
  41.         guiSetVisible(adminPanel.window[1], false)
  42.  
  43.         adminPanel.tabpanel[1] = guiCreateTabPanel(10, 24, 645, 470, false, adminPanel.window[1])
  44.  
  45.         adminPanel.tab[1] = guiCreateTab("Players", adminPanel.tabpanel[1])
  46.  
  47.         adminPanel.gridlist[1] = guiCreateGridList(10, 40, 151, 395, false, adminPanel.tab[1])
  48.         guiGridListAddColumn(adminPanel.gridlist[1], "Player Name", 0.9)
  49.         guiGridListSetSortingEnabled(adminPanel.gridlist[1], false)
  50.        
  51.         adminPanel.edit[1] = guiCreateEdit(10, 10, 151, 26, "", false, adminPanel.tab[1])
  52.         adminPanel.label[1] = guiCreateLabel(170, 26, 290, 20, "Name: ", false, adminPanel.tab[1])
  53.         adminPanel.label[2] = guiCreateLabel(170, 86, 290, 20, "IP: ", false, adminPanel.tab[1])
  54.         guiLabelSetHorizontalAlign(adminPanel.label[2], "right", false)
  55.         adminPanel.label[3] = guiCreateLabel(170, 66, 290, 20, "Serial: ", false, adminPanel.tab[1])
  56.         adminPanel.label[4] = guiCreateLabel(171, 86, 289, 20, "Version: ", false, adminPanel.tab[1])
  57.         adminPanel.label[5] = guiCreateLabel(170, 46, 290, 20, "Account Name: ", false, adminPanel.tab[1])
  58.         adminPanel.label[6] = guiCreateLabel(171, 375, 289, 21, "Playtime: ", false, adminPanel.tab[1])
  59.         adminPanel.label[7] = guiCreateLabel(170, 126, 290, 22, "Country: ", false, adminPanel.tab[1])
  60.         adminPanel.label[8] = guiCreateLabel(171, 128, 289, 20, "Account ID: ", false, adminPanel.tab[1])
  61.         guiLabelSetHorizontalAlign(adminPanel.label[8], "right", false)
  62.         adminPanel.label[9] = guiCreateLabel(170, 210, 290, 20, "Location: ", false, adminPanel.tab[1])
  63.         adminPanel.label[10] = guiCreateLabel(170, 230, 290, 20, "Dimension: ", false, adminPanel.tab[1])
  64.         adminPanel.label[11] = guiCreateLabel(170, 230, 290, 20, "Interior: ", false, adminPanel.tab[1])
  65.         guiLabelSetHorizontalAlign(adminPanel.label[11], "right", false)
  66.         adminPanel.label[12] = guiCreateLabel(170, 106, 290, 20, "Email: ", false, adminPanel.tab[1])
  67.         adminPanel.label[13] = guiCreateLabel(170, 270, 290, 20, "Health: ", false, adminPanel.tab[1])
  68.         adminPanel.label[14] = guiCreateLabel(170, 270, 290, 20, "Armour: ", false, adminPanel.tab[1])
  69.         guiLabelSetHorizontalAlign(adminPanel.label[14], "right", false)
  70.         adminPanel.label[15] = guiCreateLabel(171, 355, 289, 20, "Money: ", false, adminPanel.tab[1])
  71.         adminPanel.label[16] = guiCreateLabel(170, 355, 290, 20, "Bank: ", false, adminPanel.tab[1])
  72.         guiLabelSetHorizontalAlign(adminPanel.label[16], "right", false)
  73.         adminPanel.label[17] = guiCreateLabel(170, 396, 291, 20, "Occupation: ", false, adminPanel.tab[1])
  74.         guiLabelSetHorizontalAlign(adminPanel.label[17], "right", false)
  75.         adminPanel.label[18] = guiCreateLabel(171, 396, 290, 20, "Class: ", false, adminPanel.tab[1])
  76.         adminPanel.label[19] = guiCreateLabel(171, 335, 289, 20, "Group: ", false, adminPanel.tab[1])
  77.         adminPanel.label[20] = guiCreateLabel(171, 375, 289, 21, "Team: ", false, adminPanel.tab[1])
  78.         guiLabelSetHorizontalAlign(adminPanel.label[20], "right", false)
  79.         adminPanel.label[21] = guiCreateLabel(170, 250, 267, 20, "Model: ", false, adminPanel.tab[1])
  80.         adminPanel.label[22] = guiCreateLabel(171, 250, 290, 20, "Weapon: ", false, adminPanel.tab[1])
  81.         guiLabelSetHorizontalAlign(adminPanel.label[22], "right", false)
  82.         adminPanel.label[23] = guiCreateLabel(170, 26, 290, 20, "Ping: ", false, adminPanel.tab[1])
  83.         guiLabelSetHorizontalAlign(adminPanel.label[23], "right", false)
  84.         adminPanel.label[24] = guiCreateLabel(170, 416, 290, 20, "Vehicle: ", false, adminPanel.tab[1])
  85.         adminPanel.label[25] = guiCreateLabel(170, 416, 290, 20, "Vehicle Health: ", false, adminPanel.tab[1])
  86.         guiLabelSetHorizontalAlign(adminPanel.label[25], "right", false)
  87.         adminPanel.label[26] = guiCreateLabel(170, 190, 290, 20, "X: N/A; Y: N/A; Z: N/A", false, adminPanel.tab[1])
  88.         adminPanel.label[27] = guiCreateLabel(170, 168, 49, 22, "Locality", false, adminPanel.tab[1])
  89.         guiSetFont(adminPanel.label[27], "default-bold-small")
  90.         guiLabelSetColor(adminPanel.label[27], 255, 0, 0)
  91.         adminPanel.label[28] = guiCreateLabel(170, 4, 49, 22, "Player", false, adminPanel.tab[1])
  92.         guiSetFont(adminPanel.label[28], "default-bold-small")
  93.         guiLabelSetColor(adminPanel.label[28], 255, 0, 0)
  94.         adminPanel.label[29] = guiCreateLabel(170, 313, 49, 22, "Misc", false, adminPanel.tab[1])
  95.         guiSetFont(adminPanel.label[29], "default-bold-small")
  96.         guiLabelSetColor(adminPanel.label[29], 255, 0, 0)
  97.         adminPanel.button[1] = guiCreateButton(488, 52, 147, 18, "Warp to player", false, adminPanel.tab[1])
  98.         adminPanel.button[2] = guiCreateButton(488, 10, 147, 36, "Punish", false, adminPanel.tab[1])
  99.         adminPanel.button[3] = guiCreateButton(488, 144, 72, 18, "Spectate", false, adminPanel.tab[1])
  100.         adminPanel.button[4] = guiCreateButton(488, 76, 147, 18, "Warp player to", false, adminPanel.tab[1])
  101.         adminPanel.button[5] = guiCreateButton(488, 100, 72, 18, "Reconnect", false, adminPanel.tab[1])
  102.         adminPanel.button[6] = guiCreateButton(563, 100, 72, 18, "Kick", false, adminPanel.tab[1])
  103.         adminPanel.button[7] = guiCreateButton(488, 122, 72, 18, "Freeze", false, adminPanel.tab[1])
  104.         adminPanel.button[8] = guiCreateButton(563, 122, 72, 18, "Shout", false, adminPanel.tab[1])
  105.         adminPanel.button[9] = guiCreateButton(563, 144, 72, 18, "Slap", false, adminPanel.tab[1])
  106.         adminPanel.button[10] = guiCreateButton(488, 167, 72, 18, "Rename", false, adminPanel.tab[1])
  107.         adminPanel.button[11] = guiCreateButton(488, 318, 147, 20, "View punishments", false, adminPanel.tab[1])
  108.         adminPanel.button[12] = guiCreateButton(563, 167, 72, 18, "Screenshot", false, adminPanel.tab[1])
  109.         adminPanel.button[13] = guiCreateButton(563, 195, 72, 18, "Set Model", false, adminPanel.tab[1])
  110.         adminPanel.button[14] = guiCreateButton(488, 195, 72, 18, "Money", false, adminPanel.tab[1])
  111.         adminPanel.button[15] = guiCreateButton(488, 220, 72, 18, "Set Health", false, adminPanel.tab[1])
  112.         adminPanel.button[16] = guiCreateButton(563, 220, 72, 18, "Set Armour", false, adminPanel.tab[1])
  113.         adminPanel.button[17] = guiCreateButton(488, 244, 72, 18, "Dimension", false, adminPanel.tab[1])
  114.         adminPanel.button[18] = guiCreateButton(563, 244, 72, 18, "Interior", false, adminPanel.tab[1])
  115.         adminPanel.button[19] = guiCreateButton(488, 369, 72, 18, "Fix", false, adminPanel.tab[1])
  116.         adminPanel.button[20] = guiCreateButton(563, 369, 72, 18, "Eject", false, adminPanel.tab[1])
  117.         adminPanel.button[21] = guiCreateButton(488, 392, 72, 18, "Destroy", false, adminPanel.tab[1])
  118.         adminPanel.button[22] = guiCreateButton(563, 392, 72, 18, "Disable", false, adminPanel.tab[1])
  119.         adminPanel.button[23] = guiCreateButton(563, 266, 72, 18, "Set Job", false, adminPanel.tab[1])
  120.         adminPanel.button[24] = guiCreateButton(488, 341, 72, 18, "Anticheat", false, adminPanel.tab[1])
  121.         adminPanel.button[25] = guiCreateButton(563, 341, 72, 18, "View Weps", false, adminPanel.tab[1])
  122.         adminPanel.button[26] = guiCreateButton(488, 290, 72, 18, "Weapons", false, adminPanel.tab[1])
  123.         adminPanel.button[27] = guiCreateButton(488, 266, 72, 18, "Give Vehicle", false, adminPanel.tab[1])
  124.         adminPanel.button[28] = guiCreateButton(488, 416, 72, 18, "Blow", false, adminPanel.tab[1])
  125.         adminPanel.button[29] = guiCreateButton(563, 416, 72, 18, "Freeze", false, adminPanel.tab[1])
  126.         adminPanel.button[27] = guiCreateButton(563, 290, 72, 18, "Last Logins", false, adminPanel.tab[1])
  127.  
  128.         adminPanel.tab[2] = guiCreateTab("Resources", adminPanel.tabpanel[1])
  129.  
  130.         adminPanel.gridlist[2] = guiCreateGridList(10, 48, 245, 349, false, adminPanel.tab[2])
  131.         guiGridListAddColumn(adminPanel.gridlist[2], "Resource", 0.5)
  132.         guiGridListAddColumn(adminPanel.gridlist[2], "State", 0.5)
  133.         guiGridListSetItemText(adminPanel.gridlist[2], 0, 1, "-", false, false)
  134.         guiGridListSetItemText(adminPanel.gridlist[2], 0, 2, "-", false, false)
  135.         adminPanel.edit[2] = guiCreateEdit(10, 10, 245, 28, "", false, adminPanel.tab[2])
  136.         adminPanel.button[30] = guiCreateButton(10, 407, 245, 29, "Refresh", false, adminPanel.tab[2])
  137.         guiSetProperty(adminPanel.button[30], "NormalTextColour", "FFAAAAAA")
  138.         adminPanel.edit[3] = guiCreateEdit(-548, 44, 15, 15, "", false, adminPanel.tab[2])
  139.         adminPanel.edit[4] = guiCreateEdit(265, 282, 350, 30, "", false, adminPanel.tab[2])
  140.         adminPanel.checkbox[1] = guiCreateCheckBox(380, 317, 15, 15, "", false, false, adminPanel.tab[2])
  141.         adminPanel.label[30] = guiCreateLabel(410, 317, 105, 20, "Silent (srun/scrun)", false, adminPanel.tab[2])
  142.         adminPanel.button[31] = guiCreateButton(290, 342, 140, 19, "Client", false, adminPanel.tab[2])
  143.         guiSetProperty(adminPanel.button[31], "NormalTextColour", "FFAAAAAA")
  144.         adminPanel.button[32] = guiCreateButton(454, 342, 140, 19, "Server", false, adminPanel.tab[2])
  145.         guiSetProperty(adminPanel.button[32], "NormalTextColour", "FFAAAAAA")
  146.         adminPanel.label[31] = guiCreateLabel(265, 366, 302, 18, "Last runs", false, adminPanel.tab[2])
  147.         adminPanel.label[32] = guiCreateLabel(271, 384, 374, 18, "[UCD]Noki [server]: killPed(getPlayerFromName(\"Epozide\"))", false, adminPanel.tab[2])
  148.         adminPanel.label[33] = guiCreateLabel(271, 402, 374, 18, "[UCD]Noki [server]: killPed(getPlayerFromName(\"Epozide\"))", false, adminPanel.tab[2])
  149.         adminPanel.label[34] = guiCreateLabel(271, 420, 374, 16, "[UCD]Noki [server]: killPed(getPlayerFromName(\"Epozide\"))", false, adminPanel.tab[2])
  150.         adminPanel.button[33] = guiCreateButton(282, 20, 148, 38, "Start", false, adminPanel.tab[2])
  151.         guiSetProperty(adminPanel.button[33], "NormalTextColour", "FFAAAAAA")
  152.         adminPanel.button[34] = guiCreateButton(457, 20, 148, 38, "Stop", false, adminPanel.tab[2])
  153.         guiSetProperty(adminPanel.button[34], "NormalTextColour", "FFAAAAAA")
  154.         adminPanel.button[35] = guiCreateButton(282, 70, 323, 38, "Restart", false, adminPanel.tab[2])
  155.         guiSetProperty(adminPanel.button[35], "NormalTextColour", "FFAAAAAA")
  156.         adminPanel.button[36] = guiCreateButton(457, 118, 148, 38, "Delete", false, adminPanel.tab[2])
  157.         guiSetProperty(adminPanel.button[36], "NormalTextColour", "FFAAAAAA")
  158.         adminPanel.button[37] = guiCreateButton(282, 118, 148, 38, "Move", false, adminPanel.tab[2])
  159.         guiSetProperty(adminPanel.button[37], "NormalTextColour", "FFAAAAAA")
  160.         adminPanel.label[35] = guiCreateLabel(265, 168, 178, 21, "Resource Information", false, adminPanel.tab[2])
  161.         guiSetFont(adminPanel.label[35], "default-bold-small")
  162.         guiLabelSetColor(adminPanel.label[35], 255, 0, 0)
  163.         adminPanel.label[36] = guiCreateLabel(280, 189, 345, 20, "Name:", false, adminPanel.tab[2])
  164.         adminPanel.label[37] = guiCreateLabel(280, 209, 345, 20, "Author:", false, adminPanel.tab[2])
  165.         adminPanel.label[38] = guiCreateLabel(280, 229, 345, 20, "Version:", false, adminPanel.tab[2])
  166.         adminPanel.label[39] = guiCreateLabel(280, 249, 345, 23, "Description:", false, adminPanel.tab[2])
  167.  
  168.         adminPanel.tab[3] = guiCreateTab("Server Management", adminPanel.tabpanel[1])
  169.         adminPanel.tab[4] = guiCreateTab("Utilities", adminPanel.tabpanel[1])    
  170.        
  171.        
  172.         confirm.window[1] = guiCreateWindow(792, 480, 324, 111, "UCD | Admin - <health>", false)
  173.         guiWindowSetSizable(confirm.window[1], false)
  174.         guiSetVisible(confirm.window[1], false)
  175.  
  176.         confirm.button[1] = guiCreateButton(58, 82, 101, 19, "Confirm", false, confirm.window[1])
  177.         guiSetProperty(confirm.button[1], "NormalTextColour", "FFAAAAAA")
  178.         confirm.button[2] = guiCreateButton(169, 82, 101, 19, "Cancel", false, confirm.window[1])
  179.         guiSetProperty(confirm.button[2], "NormalTextColour", "FFAAAAAA")
  180.         confirm.edit[1] = guiCreateEdit(35, 47, 260, 25, "", false, confirm.window[1])
  181.         confirm.label[1] = guiCreateLabel(36, 21, 259, 20, "Set the motherfucking label text nigga", false, confirm.window[1])
  182.         guiLabelSetHorizontalAlign(confirm.label[1], "center", false)
  183.         guiLabelSetVerticalAlign(confirm.label[1], "center")    
  184.  
  185.  
  186. --    end
  187. --)
  188.  
  189. for _, plr in pairs(Element.getAllByType("player")) do
  190.     local row = guiGridListAddRow(adminPanel.gridlist[1])
  191.     local r, g, b
  192.     if plr.team then
  193.         r, g, b = plr.team:getColor()
  194.     else
  195.         r, g, b = 255, 255, 255
  196.     end
  197.     guiGridListSetItemText(adminPanel.gridlist[1], row, 1, plr.name, false, false)
  198.     guiGridListSetItemData(adminPanel.gridlist[1], row, 1, plr)
  199.     guiGridListSetItemColor(adminPanel.gridlist[1], row, 1, r, g, b)
  200. end
  201.  
  202. function searchFromPlayerList()
  203.     if (source ~= adminPanel.edit[1]) then return end
  204.     guiGridListClear(adminPanel.gridlist[1])
  205.     local name = adminPanel.edit[1]:getText()
  206.     for _, plr in pairs(Element.getAllByType("player")) do
  207.         if string.find(plr.name:lower(), name:lower()) then
  208.             local r, g, b
  209.             if (plr.team) then
  210.                 r, g, b = plr.team:getColor()
  211.             else
  212.                 r, g, b = 255, 255, 255
  213.             end
  214.            
  215.             local row = guiGridListAddRow(adminPanel.gridlist[1])
  216.             guiGridListSetItemText(adminPanel.gridlist[1], row, 1, plr.name, false, false)
  217.             guiGridListSetItemData(adminPanel.gridlist[1], row, 1, plr)
  218.             guiGridListSetItemColor(adminPanel.gridlist[1], row, 1, r, g, b)
  219.         end
  220.     end
  221. end
  222. addEventHandler("onClientGUIChanged", guiRoot, searchFromPlayerList)
  223.  
  224. -- Add a player when they join
  225. addEventHandler("onClientPlayerJoin", root,
  226.     function ()
  227.         --if source.name:lower():find(adminPanel.edit[1]:getText():lower()) then
  228.             local row = guiGridListAddRow(adminPanel.gridlist[1])
  229.             guiGridListSetItemText(adminPanel.gridlist[1], row, 1, source.name, false, false)
  230.             guiGridListSetItemData(adminPanel.gridlist[1], row, 1, source)
  231.             local r, g, b
  232.             if source.team then
  233.                 r, g, b = source.team:getColor()
  234.             else
  235.                 r, g, b = 255, 255, 255
  236.             end
  237.             guiGridListSetItemColor(adminPanel.gridlist[1], row, 1, r, g, b)
  238.         --end
  239.     end
  240. )
  241.  
  242. -- Remove a player when they quit
  243. addEventHandler("onClientPlayerQuit", root,
  244.     function ()
  245.         for i = 0, guiGridListGetRowCount(adminPanel.gridlist[1]) - 1 do
  246.             if (guiGridListGetItemData(adminPanel.gridlist[1], i, 1) == source) then
  247.                 guiGridListRemoveRow(adminPanel.gridlist[1], i)
  248.                 break
  249.             end
  250.         end
  251.     end
  252. )
  253.  
  254. -- When a player changes his nick
  255. addEventHandler("onClientPlayerChangeNick", root,
  256.     function (oldNick, newNick)
  257.         for i = 0, guiGridListGetRowCount(adminPanel.gridlist[1]) - 1 do
  258.             if (guiGridListGetItemText(adminPanel.gridlist[1], i, 1) == oldNick) then
  259.                 guiGridListSetItemText(adminPanel.gridlist[1], i, 1, newNick, false, false)
  260.             end
  261.         end
  262.     end
  263. )
  264.  
  265. addEventHandler("onClientRender", root,
  266.     function ()
  267.         -- Update team colours
  268.         for i = 0, guiGridListGetRowCount(adminPanel.gridlist[1]) - 1 do
  269.             --local plr = Player(guiGridListGetItemText(adminPanel.gridlist[1], i, 1))
  270.             local plr = guiGridListGetItemData(adminPanel.gridlist[1], i, 1)
  271.             if (plr) then
  272.                 local r, g, b
  273.                 if plr.team then
  274.                     r, g, b = plr.team:getColor()
  275.                 else
  276.                     r, g, b = 255, 255, 255
  277.                 end
  278.                 guiGridListSetItemColor(adminPanel.gridlist[1], i, 1, r, g, b)
  279.                
  280.                 if (plr.name ~= guiGridListGetItemText(adminPanel.gridlist[1], i, 1)) then
  281.                     guiGridListSetItemText(adminPanel.gridlist[1], i, 1, plr.name, false, false)
  282.                 end
  283.             end
  284.         end
  285.         if (getSelectedPlayer()) then
  286.             updatePlayerInformation(getSelectedPlayer(), false) -- We don't want it triggering events every second, plus we don't want to repeat code
  287.         end
  288.     end
  289. )
  290.  
  291. function updatePlayerInformation(plr, getServerSidedData)
  292.     -- Fetch the rest server-side
  293.     local name = plr.name
  294.     local loc = plr.position
  295.     --loc.x = exports.UCDutil:mathround(loc.x, 3)
  296.     --loc.y = exports.UCDutil:mathround(loc.y, 3)
  297.     --loc.z = exports.UCDutil:mathround(loc.z, 3) -- Need to fix this
  298.     local accountID = plr:getData("accountID") or "N/A"
  299.     local accountName = plr:getData("accountName") or "N/A"
  300.     local model = plr.model or 0
  301.     local dim = plr.dimension or 0
  302.     local int = plr.interior or 0
  303.     local health = plr.health or 0
  304.     local armour = plr.armor or 0
  305.     local money = plr:getMoney() or "N/A"
  306.     local team = plr.team.name or "Not logged in"
  307.     local group = plr:getData("group") or "N/A"
  308.     local class = plr:getData("Class") or "N/A"
  309.     local occupation = plr:getData("Occupation") or "N/A"
  310.     local ping = plr.ping
  311.     local suburb, city = getZoneName(loc.x, loc.y, loc.z), getZoneName(loc.x, loc.y, loc.z, true)
  312.     local country = plr:getData("Country") or "N/A"
  313.     local ammo, weapon = getPedTotalAmmo(plr), getWeaponNameFromID(plr:getWeapon())
  314.     local playtime = plr:getData("dxscoreboard_playtime") or "N/A"
  315.    
  316.     local vehicle, vehicleHealth
  317.     if not plr.vehicle then
  318.         vehicle = "Not in a vehicle"
  319.         vehicleHealth = "N/A"
  320.     else
  321.         vehicle = plr.vehicle.name
  322.         vehicleHealth = tostring(exports.UCDutil:mathround(plr.vehicle.health / 10).."%")
  323.     end
  324.    
  325.     adminPanel.label[1]:setText("Name: "..name)
  326.     adminPanel.label[5]:setText("Account Name: "..accountName)
  327.     adminPanel.label[6]:setText("Playtime: "..playtime)
  328.     adminPanel.label[7]:setText("Country: "..country)
  329.     adminPanel.label[8]:setText("Account ID: "..accountID)
  330.     adminPanel.label[9]:setText("Location: "..suburb..", "..city)
  331.     adminPanel.label[10]:setText("Dimension: "..dim)
  332.     adminPanel.label[11]:setText("Interior: "..int)
  333.     adminPanel.label[13]:setText("Health: "..health)
  334.     adminPanel.label[14]:setText("Armour: "..armour)
  335.     adminPanel.label[15]:setText("Money: ".."$"..tostring(exports.UCDutil:tocomma(money)))
  336.     adminPanel.label[17]:setText("Occupation: "..occupation)
  337.     adminPanel.label[18]:setText("Class: "..class)
  338.     adminPanel.label[19]:setText("Group: "..group)
  339.     adminPanel.label[20]:setText("Team: "..team)
  340.     adminPanel.label[21]:setText("Model: "..model)
  341.     adminPanel.label[22]:setText("Weapon: "..weapon.." ["..ammo.."]")
  342.     adminPanel.label[23]:setText("Ping: "..ping)
  343.     adminPanel.label[24]:setText("Vehicle: "..vehicle)
  344.     adminPanel.label[25]:setText("Vehicle Health: "..vehicleHealth)
  345.     adminPanel.label[26]:setText("X: "..exports.UCDutil:mathround(loc.x, 3).."; Y: "..exports.UCDutil:mathround(loc.y, 3).."; Z: "..exports.UCDutil:mathround(loc.z, 3))
  346.    
  347.     if (getServerSidedData) then
  348.         -- This has a callback function where the data is updated
  349.         triggerServerEvent("UCDadmin.requestPlayerData", localPlayer, plr)
  350.     end
  351. end
  352.  
  353. function requestPlayerData_callback(sync)
  354.     --outputDebugString("Client callback")
  355.     local data = sync
  356.     adminPanel.label[2]:setText("IP: "..data["ip"])
  357.     adminPanel.label[3]:setText("Serial: "..data["serial"])
  358.     adminPanel.label[4]:setText("Version: "..data["version"])
  359.     adminPanel.label[12]:setText("Email: "..data["email"])
  360.     adminPanel.label[16]:setText("Bank: ".."$"..tostring(exports.UCDutil:mathround(data["bank"])))
  361. end
  362. addEvent("UCDadmin.requestPlayerData:callback", true)
  363. addEventHandler("UCDadmin.requestPlayerData:callback", root, requestPlayerData_callback)
  364.  
  365. function playerSelection()
  366.     if (source == adminPanel.gridlist[1]) then
  367.         local row = guiGridListGetSelectedItem(adminPanel.gridlist[1])
  368.         if (row and row ~= nil and row ~= -1 and row ~= false) then
  369.             local plr = guiGridListGetItemData(adminPanel.gridlist[1], row, 1)
  370.             --outputChatBox("Viewing data for: "..tostring(plr))
  371.             updatePlayerInformation(plr, true)
  372.         else
  373.             -- Set everything blank
  374.             adminPanel.label[1]:setText("Name: ")
  375.             adminPanel.label[2]:setText("IP: ")
  376.             adminPanel.label[3]:setText("Serial: ")
  377.             adminPanel.label[4]:setText("Version: ")
  378.             adminPanel.label[5]:setText("Account Name: ")
  379.             adminPanel.label[6]:setText("Playtime: ")
  380.             adminPanel.label[7]:setText("Country: ")
  381.             adminPanel.label[8]:setText("Account ID: ")
  382.             adminPanel.label[9]:setText("Location: ")
  383.             adminPanel.label[10]:setText("Dimension: ")
  384.             adminPanel.label[12]:setText("Email: ")
  385.             adminPanel.label[11]:setText("Interior: ")
  386.             adminPanel.label[13]:setText("Health: ")
  387.             adminPanel.label[14]:setText("Armour: ")
  388.             adminPanel.label[15]:setText("Money: ")
  389.             adminPanel.label[16]:setText("Bank: ")
  390.             adminPanel.label[17]:setText("Occupation: ")
  391.             adminPanel.label[18]:setText("Class: ")
  392.             adminPanel.label[19]:setText("Group: ")
  393.             adminPanel.label[20]:setText("Team: ")
  394.             adminPanel.label[21]:setText("Model: ")
  395.             adminPanel.label[22]:setText("Weapon: ")
  396.             adminPanel.label[23]:setText("Ping: ")
  397.             adminPanel.label[24]:setText("Vehicle: ")
  398.             adminPanel.label[25]:setText("Vehicle Health: ")
  399.             adminPanel.label[26]:setText("X: N/A; Y: N/A; Z: N/A")
  400.         end
  401.     end
  402. end
  403. addEventHandler("onClientGUIClick", guiRoot, playerSelection)
  404.  
  405. function adminAction()
  406.     if (source ~= adminPanel.gridlist[1] and source.parent == adminPanel.window[1]) then
  407.         local plr = getSelectedPlayer()
  408.         if (not plr) then
  409.             exports.UCDdx:new("You must select a player first!", 255, 0, 0)
  410.             return
  411.         end
  412.        
  413.         local action = source.text:lower()
  414.         if not action then return end
  415.         if (action == "punish") then
  416.             -- open punish gui
  417.         elseif (action == "warp to player") then
  418.             --
  419.         elseif (action == "warp player to") then
  420.            
  421.         elseif (action == "reconnect") then
  422.             triggerServerEvent("UCDadmin.reconnect", localPlayer, plr)
  423.         elseif (action == "kick") then
  424.             --triggerServerEvent("UCDadmin.kick", localPlayer, plr, "Annoying admins and creating a negative atmosphere")
  425.             createInputBox("UCD | Admin - Kick", "Enter a reason [Note: this will be logged]", "", "UCDadmin.kick", localPlayer, plr)
  426.         elseif (action == "freeze") then
  427.             if (source == adminPanel.button[29]) then -- If it's the vehicle one
  428.                 triggerServerEvent("UCDadmin.freeze", localPlayer, plr.vehicle, plr)
  429.             else -- We're dealing with the player one
  430.                 triggerServerEvent("UCDadmin.freeze", localPlayer, plr)
  431.             end
  432.         elseif (action == "shout") then
  433.            
  434.         elseif (action == "spectate") then
  435.            
  436.         elseif (action == "slap") then
  437.            
  438.         elseif (action == "rename") then
  439.             createInputBox("UCD | Admin - Rename", "Enter the desired name", exports.UCDutil:randomstring(8), "UCDadmin.rename", localPlayer, plr)
  440.         elseif (action == "screenshot") then
  441.            
  442.         elseif (action == "money") then
  443.            
  444.         elseif (action == "set model") then
  445.             createInputBox("UCD | Admin - Model", "Enter the desired model", 0, "UCDadmin.setModel", localPlayer, plr)
  446.         elseif (action == "set health") then
  447.             createInputBox("UCD | Admin - Health", "Enter the armour value", 200, "UCDadmin.setHealth", localPlayer, plr)
  448.         elseif (action == "set armour") then
  449.             -- Open another GUI with an input box
  450.             --triggerServerEvent("UCDadmin.setArmour", localPlayer, plr, 100)
  451.             createInputBox("UCD | Admin - Armour", "Enter the armour value", 100, "UCDadmin.setArmour", localPlayer, plr)
  452.         elseif (action == "dimension") then
  453.             createInputBox("UCD | Admin - Dimension", "Enter the desired dimension", 0, "UCDadmin.setDimension", localPlayer, plr)
  454.         elseif (action == "interior") then
  455.             createInputBox("UCD | Admin - Interior", "Enter the desired interior", 0, "UCDadmin.setInterior", localPlayer, plr)
  456.         elseif (action == "last logins") then
  457.            
  458.         elseif (action == "set job") then
  459.            
  460.         elseif (action == "weapons") then
  461.            
  462.         elseif (action == "view punishments") then
  463.            
  464.         elseif (action == "anticheat") then
  465.            
  466.         elseif (action == "view weps") then
  467.            
  468.         elseif (action == "fix") then
  469.            
  470.         elseif (action == "eject") then
  471.            
  472.         elseif (action == "destroy") then
  473.             if (plr.vehicle) then
  474.                 if (plr.vehicle:getData("vehicleID")) then
  475.                     exports.UCDdx:new(plr.name.."'s vehicle is a player vehicle. Hiding it instead...", 0, 255, 0)
  476.                     triggerServerEvent("UCDvehicleSystem.hideVehicle", plr, plr.vehicle:getData("vehicleID"))
  477.                     triggerServerEvent("UCDadmin.destroyVehicle", localPlayer, plr)
  478.                     return
  479.                 end
  480.                 triggerServerEvent("UCDadmin.destroyVehicle", localPlayer, plr, plr.vehicle)
  481.             else
  482.                 exports.UCDdx:new("This player is not in a vehicle", 255, 0, 0)
  483.             end
  484.         elseif (action == "disable") then
  485.            
  486.         elseif (action == "blow") then
  487.        
  488.         elseif (action == "give vehicle") then
  489.             if (isPedInVehicle(plr) or plr.vehicle) then
  490.                 exports.UCDdx:new("You can't give this player a vehicle as they are already in one", 255, 0, 0)
  491.                 return
  492.             end
  493.             createInputBox("UCD | Admin - Give Vehicle", "Enter a vehicle ID or name", "", "UCDadmin.giveVehicle", localPlayer, plr)
  494.         end
  495.     end
  496. end
  497. addEventHandler("onClientGUIClick", guiRoot, adminAction)
  498.  
  499. function toggleGUI()
  500.     --[[
  501.     if (guiGetVisible(adminPanel.window[1])) then
  502.         adminPanel.window[1]:setVisible(false)
  503.     else
  504.         adminPanel.window[1]:setVisible(true)
  505.     end
  506.     --]]
  507.     adminPanel.window[1]:setVisible(not adminPanel.window[1]:getVisible())
  508.     showCursor(adminPanel.window[1]:getVisible())
  509.    
  510.     if (confirm.window[1]) then
  511.         closeInputBox()
  512.     end
  513. end
  514. addCommandHandler("adminpanel", toggleGUI)
  515. bindKey("p", "down", toggleGUI)
Advertisement
Add Comment
Please, Sign In to add comment