Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
179 changes: 139 additions & 40 deletions [admin]/admin/client/gui/admin_main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@ aResources = {}
local serverPassword = 'None'
local hasResourceSetting

local function aWeatherListClick ()
if ( source == aTab3.WeatherListSet or source == aTab3.WeatherListBlend ) then
local row = guiGridListGetSelectedItem ( aTab3.WeatherList )
local weather = row and row >= 0 and tonumber ( guiGridListGetItemData ( aTab3.WeatherList, row, 1 ) )
if ( weather ) then
local action = source == aTab3.WeatherListSet and "setweather" or "blendweather"
triggerServerEvent ( "aServer", localPlayer, action, weather )
guiSetVisible ( aTab3.WeatherWindow, false )
end
elseif ( source == aTab3.WeatherListClose ) then
guiSetVisible ( aTab3.WeatherWindow, false )
end
end

function guiComboBoxAdjustHeight ( combobox, itemcount )
if getElementType ( combobox ) ~= "gui-combobox" or type ( itemcount ) ~= "number" then error ( "Invalid arguments @ 'guiComboBoxAdjustHeight'", 2 ) end
local width = guiGetSize ( combobox, false )
Expand Down Expand Up @@ -81,6 +95,8 @@ function aAdminMenu ()
local y = 0.03 -- Start y coord
local A = 0.045 -- Large line gap
local B = 0.035 -- Small line gap
local infoLabelX, infoLabelWidth = 0.26, 0.32
local infoActionX, infoActionWidth, infoRowHeight = 0.45, 0.09, 0.035

guiCreateHeader ( 0.25, y, 0.20, 0.04, "Player:", true, aTab1.Tab )
y=y+A aTab1.Name = guiCreateLabel ( 0.26, y, 0.435, 0.035, "Name: N/A", true, aTab1.Tab )
Expand All @@ -91,11 +107,19 @@ y=y+A aTab1.Serial = guiCreateLabel ( 0.26, y, 0.435, 0.035, "Serial: N/A", t
--aTab1.Username = guiCreateLabel ( 0.26, 0.245, 0.435, 0.035, "Username: N/A", true, aTab1.Tab )
y=y+B aTab1.Version = guiCreateLabel ( 0.26, y, 0.435, 0.035, "Version: N/A", true, aTab1.Tab )
y=y+B aTab1.Accountname = guiCreateLabel ( 0.26, y, 0.435, 0.035, "Account Name: N/A", true, aTab1.Tab )
y=y+B aTab1.Groups = guiCreateLabel ( 0.26, y, 0.435, 0.035, "Groups: N/A", true, aTab1.Tab )
y=y+B aTab1.Groups = guiCreateLabel ( infoLabelX, y, infoLabelWidth, infoRowHeight, "Groups: N/A", true, aTab1.Tab )
aTab1.GroupsView = guiCreateButton ( infoActionX, y, infoActionWidth, infoRowHeight, "View", true, aTab1.Tab )
aTab1.GroupsWindow = guiCreateWindow ( sx / 2 - 150, sy / 2 - 130, 300, 260, "ACL Groups", false )
guiWindowSetSizable ( aTab1.GroupsWindow, false )
aTab1.GroupsList = guiCreateGridList ( 0.05, 0.14, 0.90, 0.70, true, aTab1.GroupsWindow )
guiGridListAddColumn ( aTab1.GroupsList, "Group", 0.85 )
guiGridListSetSortingEnabled ( aTab1.GroupsList, false )
aTab1.GroupsClose = guiCreateButton ( 0.35, 0.87, 0.30, 0.08, "Close", true, aTab1.GroupsWindow )
guiSetVisible ( aTab1.GroupsWindow, false )
y=y+A aTab1.ACDetected = guiCreateLabel ( 0.26, y, 0.30, 0.035, "AC Detected: N/A", true, aTab1.Tab )
y=y+B aTab1.ACD3D = guiCreateLabel ( 0.26, y, 0.30, 0.035, "D3D9.DLL: N/A", true, aTab1.Tab )
y=y+B aTab1.ACModInfo = guiCreateLabel ( 0.26, y, 0.20, 0.035, "Img Mods: N/A", true, aTab1.Tab )
aTab1.ACModDetails = guiCreateButton ( 0.46, y, 0.13, 0.04, "Details", true, aTab1.Tab )
y=y+B aTab1.ACModInfo = guiCreateLabel ( infoLabelX, y, infoLabelWidth, infoRowHeight, "Img Mods: N/A", true, aTab1.Tab )
aTab1.ACModDetails = guiCreateButton ( infoActionX, y, infoActionWidth, infoRowHeight, "Details", true, aTab1.Tab )


B = 0.040
Expand Down Expand Up @@ -253,6 +277,29 @@ y=y+B aTab1.VehicleHealth = guiCreateLabel ( 0.26, y, 0.25, 0.04, "Vehicle Heal
guiEditSetReadOnly ( aTab3.Weather, true )
aTab3.WeatherSet = guiCreateButton ( 0.50, 0.40, 0.10, 0.04, "Set", true, aTab3.Tab, "setweather" )
aTab3.WeatherBlend = guiCreateButton ( 0.61, 0.40, 0.15, 0.04, "Set Blended", true, aTab3.Tab, "blendweather" )
aTab3.WeatherListOpen = guiCreateButton ( 0.77, 0.40, 0.12, 0.04, "Browse", true, aTab3.Tab )

aTab3.WeatherWindow = guiCreateWindow ( sx / 2 - 170, sy / 2 - 195, 340, 420, "Select Weather", false )
guiWindowSetSizable ( aTab3.WeatherWindow, false )
aTab3.WeatherList = guiCreateGridList ( 0.04, 0.08, 0.92, 0.75, true, aTab3.WeatherWindow )
guiGridListAddColumn ( aTab3.WeatherList, "Weather", 0.9 )
guiGridListSetSortingEnabled ( aTab3.WeatherList, false )
local weatherIds = {}
for id in pairs ( aWeathers ) do table.insert ( weatherIds, id ) end
table.sort ( weatherIds )
for _, id in ipairs ( weatherIds ) do
local row = guiGridListAddRow ( aTab3.WeatherList )
guiGridListSetItemText ( aTab3.WeatherList, row, 1, id.." - "..aWeathers[id], false, false )
guiGridListSetItemData ( aTab3.WeatherList, row, 1, id )
if ( id == getWeather() ) then guiGridListSetSelectedItem ( aTab3.WeatherList, row, 1 ) end
end
aTab3.WeatherListSet = guiCreateButton ( 0.04, 0.86, 0.28, 0.10, "Set", true, aTab3.WeatherWindow )
aTab3.WeatherListBlend = guiCreateButton ( 0.36, 0.86, 0.38, 0.10, "Set Blended", true, aTab3.WeatherWindow )
aTab3.WeatherListClose = guiCreateButton ( 0.78, 0.86, 0.18, 0.10, "Close", true, aTab3.WeatherWindow )
guiSetVisible ( aTab3.WeatherWindow, false )
addEventHandler ( "onClientGUIClick", aTab3.WeatherListSet, aWeatherListClick )
addEventHandler ( "onClientGUIClick", aTab3.WeatherListBlend, aWeatherListClick )
addEventHandler ( "onClientGUIClick", aTab3.WeatherListClose, aWeatherListClick )

local th, tm = getTime()
aTab3.TimeCurrent = guiCreateLabel ( 0.05, 0.45, 0.25, 0.04, "Time: "..th..":"..tm, true, aTab3.Tab )
Expand Down Expand Up @@ -398,6 +445,7 @@ y=y+B aTab1.VehicleHealth = guiCreateLabel ( 0.26, y, 0.25, 0.04, "Vehicle Heal
addEventHandler ( "aClientPlayerJoin", root, aClientPlayerJoin )
addEventHandler ( "onClientPlayerQuit", root, aClientPlayerQuit )
addEventHandler ( "onClientGUIClick", aAdminForm, aClientClick )
addEventHandler ( "onClientGUIClick", aTab1.GroupsClose, aClientClick )
addEventHandler ( "onClientGUIScroll", aAdminForm, aClientScroll )
addEventHandler ( "onClientGUIDoubleClick", aAdminForm, aClientDoubleClick )
addEventHandler ( "onClientGUIAccepted", aAdminForm, aClientGUIAccepted )
Expand Down Expand Up @@ -444,6 +492,7 @@ y=y+B aTab1.VehicleHealth = guiCreateLabel ( 0.26, y, 0.25, 0.04, "Vehicle Heal
end

function aAdminMenuClose ( destroy )
if ( aTab1 and aTab1.GroupsWindow ) then guiSetVisible ( aTab1.GroupsWindow, false ) end
if ( destroy ) then
aMainSaveSettings ()
aPlayers = {}
Expand All @@ -457,6 +506,7 @@ function aAdminMenuClose ( destroy )
removeEventHandler ( "aClientPlayerJoin", root, aClientPlayerJoin )
removeEventHandler ( "onClientPlayerQuit", root, aClientPlayerQuit )
removeEventHandler ( "onClientGUIClick", aAdminForm, aClientClick )
removeEventHandler ( "onClientGUIClick", aTab1.GroupsClose, aClientClick )
removeEventHandler ( "onClientGUIScroll", aAdminForm, aClientScroll )
removeEventHandler ( "onClientGUIDoubleClick", aAdminForm, aClientDoubleClick )
removeEventHandler ( "onClientGUIAccepted", aAdminForm, aClientGUIAccepted )
Expand All @@ -466,6 +516,7 @@ function aAdminMenuClose ( destroy )
removeEventHandler ( "onClientResourceStop", root, aMainSaveSettings )
unbindKey ( "arrow_d", "down", aPlayerListScroll )
unbindKey ( "arrow_u", "down", aPlayerListScroll )
destroyElement ( aTab1.GroupsWindow )
destroyElement ( aAdminForm )
aAdminForm = nil
else
Expand All @@ -490,9 +541,56 @@ function aMainSaveSettings ()
else aSetSetting ( "performance", "Auto" ) end
end

local function aRefreshPlayerGroups ( player )
local playerData = player and aPlayers[player]
local groups = playerData and playerData["groupList"]
if ( aTab1.GroupsPlayer ~= player ) then
aTab1.GroupsPlayer = player
aTab1.GroupsData = nil
guiSetVisible ( aTab1.GroupsWindow, false )
guiGridListClear ( aTab1.GroupsList )
end
local groupsChanged = groups ~= aTab1.GroupsData
if ( groupsChanged and type ( groups ) == "table" and type ( aTab1.GroupsData ) == "table" ) then
groupsChanged = #groups ~= #aTab1.GroupsData
if ( not groupsChanged ) then
for index, group in ipairs ( groups ) do
if ( group ~= aTab1.GroupsData[index] ) then
groupsChanged = true
break
end
end
end
end
if ( groupsChanged ) then
guiGridListClear ( aTab1.GroupsList )
if ( type ( groups ) == "table" ) then
for _, group in ipairs ( groups ) do
local row = guiGridListAddRow ( aTab1.GroupsList )
guiGridListSetItemText ( aTab1.GroupsList, row, 1, group, false, false )
end
end
end
aTab1.GroupsData = groups
if ( not playerData ) then
guiSetText ( aTab1.Groups, "Groups: N/A" )
elseif ( playerData["groupStatus"] == "Not logged in" ) then
guiSetText ( aTab1.Groups, "Groups: Not logged in" )
elseif ( playerData["groupStatus"] == "None" ) then
guiSetText ( aTab1.Groups, "Groups: None" )
elseif ( type ( groups ) == "table" ) then
guiSetText ( aTab1.Groups, #groups > 0 and "Groups: "..#groups or "Groups: None" )
else
guiSetText ( aTab1.Groups, "Groups: N/A" )
end
local hasGroups = type ( groups ) == "table" and #groups > 0
if ( not hasGroups ) then guiSetVisible ( aTab1.GroupsWindow, false ) end
end

function aAdminRefresh ()
if ( guiGridListGetSelectedItem ( aTab1.PlayerList ) ~= -1 ) then
local player = getPlayerFromName ( guiGridListGetItemPlayerName ( aTab1.PlayerList, guiGridListGetSelectedItem( aTab1.PlayerList ), 1 ) )
aRefreshPlayerGroups ( player and aPlayers[player] and player or nil )
if ( player and aPlayers[player] ) then
local playerName = aPlayers[player]["name"]

Expand All @@ -509,7 +607,6 @@ function aAdminRefresh ()
guiSetText ( aTab1.Freeze, iif ( aPlayers[player]["freeze"], "Unfreeze", "Freeze" ) )
guiSetText ( aTab1.Version, "Version: "..( aPlayers[player]["version"] or "" ) )
guiSetText ( aTab1.Accountname, "Account Name: "..getSensitiveText( aPlayers[player]["accountname"] or "" ) )
guiSetText ( aTab1.Groups, "Groups: "..( aPlayers[player]["groups"] or "None" ) )
guiSetText ( aTab1.ACDetected, "AC Detected: "..( aPlayers[player]["acdetected"] or "" ) )
guiSetText ( aTab1.ACD3D, "D3D9.DLL: "..( aPlayers[player]["d3d9dll"] or "" ) )
guiSetText ( aTab1.ACModInfo, "Img Mods: "..( aPlayers[player]["imgmodsnum"] or "" ) )
Expand Down Expand Up @@ -549,6 +646,7 @@ function aAdminRefresh ()
return player
end
end
aRefreshPlayerGroups ( nil )
end

function aClientSync ( type, table, data )
Expand All @@ -559,17 +657,12 @@ function aClientSync ( type, table, data )
elseif ( type == "players" ) then
aPlayers = table
elseif ( type == "resources" ) then
guiGridListClear ( aTab2.ResourceList )
local bInclMaps = guiCheckBoxGetSelected ( aTab2.ResourceInclMaps )
aResources = table
for id, resource in ipairs(table) do
if bInclMaps or resource["type"] ~= "map" then
local row = guiGridListAddRow ( aTab2.ResourceList )
guiGridListSetItemText ( aTab2.ResourceList, row, 1, resource["name"], false, false )
guiGridListSetItemText ( aTab2.ResourceList, row, 2, resource["numsettings"] > 0 and tostring(resource["numsettings"]) or "", false, false )
guiGridListSetItemText ( aTab2.ResourceList, row, 3, resource["state"], false, false )
guiGridListSetItemText ( aTab2.ResourceList, row, 4, resource["fullName"], false, false )
guiGridListSetItemText ( aTab2.ResourceList, row, 5, resource["author"], false, false )
guiGridListSetItemText ( aTab2.ResourceList, row, 6, resource["version"], false, false )
guiGridListAddRow ( aTab2.ResourceList, resource["name"], resource["numsettings"] > 0 and tostring(resource["numsettings"]) or "", resource["state"], resource["fullName"], resource["author"], resource["version"] )
end
end
elseif ( type == "loggedout" ) then
Expand All @@ -581,7 +674,8 @@ function aClientSync ( type, table, data )
aAdminDestroy()
break
elseif aPlayers[player] then
aPlayers[player]["groups"] = table[player]["groups"]
aPlayers[player]["groupStatus"] = table[player]["groupStatus"]
aPlayers[player]["groupList"] = table[player]["groupList"]
if ( table[player]["chat"] ) then
local id = 0
local exists = false
Expand Down Expand Up @@ -741,6 +835,7 @@ end

function aClientGUITabSwitched( selectedTab )
if getElementParent( selectedTab ) == aTabPanel then
if selectedTab ~= aTab1.Tab then guiSetVisible ( aTab1.GroupsWindow, false ) end
if selectedTab == aTab2.Tab then
-- Handle initial update of resources list
if guiGridListGetRowCount( aTab2.ResourceList ) == 0 then
Expand All @@ -764,26 +859,32 @@ function aClientGUITabSwitched( selectedTab )
end
end

function aClientResourceStart ( resource )
local id = 0
while ( id <= guiGridListGetRowCount( aTab2.ResourceList ) ) do
if ( guiGridListGetItemText ( aTab2.ResourceList, id, 1 ) == resource ) then
guiGridListSetItemText ( aTab2.ResourceList, id, 3, "running", false, false )
local function aUpdateResourceState ( resourceName, state )
for _, resource in ipairs ( aResources ) do
if ( resource["name"] == resourceName ) then
resource["state"] = state
break
end
id = id + 1
end
end

function aClientResourceStop ( resource )
local id = 0
while ( id <= guiGridListGetRowCount( aTab2.ResourceList ) ) do
if ( guiGridListGetItemText ( aTab2.ResourceList, id, 1 ) == resource ) then
guiGridListSetItemText ( aTab2.ResourceList, id, 3, "loaded", false, false )
for row = 0, guiGridListGetRowCount ( aTab2.ResourceList ) - 1 do
if ( guiGridListGetItemText ( aTab2.ResourceList, row, 1 ) == resourceName ) then
guiGridListSetItemText ( aTab2.ResourceList, row, 3, state, false, false )
break
end
id = id + 1
end
end

function aClientResourceStart ( resource )
aUpdateResourceState ( resource, "running" )
triggerServerEvent ( "aSync", localPlayer, "resources" )
end

function aClientResourceStop ( resource )
aUpdateResourceState ( resource, "loaded" )
triggerServerEvent ( "aSync", localPlayer, "resources" )
end

function aClientPlayerJoin ( ip, accountname, serial, admin, country )
if ip == false and serial == false then
-- Update country only
Expand Down Expand Up @@ -947,26 +1048,14 @@ function aClientGUIChanged ()
if ( text == "" ) then
for id, resource in ipairs(aResources) do
if bInclMaps or resource["type"] ~= "map" then
local row = guiGridListAddRow ( aTab2.ResourceList )
guiGridListSetItemText ( aTab2.ResourceList, row, 1, resource["name"], false, false )
guiGridListSetItemText ( aTab2.ResourceList, row, 2, resource["numsettings"] > 0 and tostring(resource["numsettings"]) or "", false, false )
guiGridListSetItemText ( aTab2.ResourceList, row, 3, resource["state"], false, false )
guiGridListSetItemText ( aTab2.ResourceList, row, 4, resource["fullName"], false, false )
guiGridListSetItemText ( aTab2.ResourceList, row, 5, resource["author"], false, false )
guiGridListSetItemText ( aTab2.ResourceList, row, 6, resource["version"], false, false )
guiGridListAddRow ( aTab2.ResourceList, resource["name"], resource["numsettings"] > 0 and tostring(resource["numsettings"]) or "", resource["state"], resource["fullName"], resource["author"], resource["version"] )
end
end
else
for id, resource in ipairs(aResources) do
if bInclMaps or resource["type"] ~= "map" then
if string.find(string.lower(resource.name), text, 1, true) then
local row = guiGridListAddRow ( aTab2.ResourceList )
guiGridListSetItemText ( aTab2.ResourceList, row, 1, resource["name"], false, false )
guiGridListSetItemText ( aTab2.ResourceList, row, 2, resource["numsettings"] > 0 and tostring(resource["numsettings"]) or "", false, false )
guiGridListSetItemText ( aTab2.ResourceList, row, 3, resource["state"], false, false )
guiGridListSetItemText ( aTab2.ResourceList, row, 4, resource["fullName"], false, false )
guiGridListSetItemText ( aTab2.ResourceList, row, 5, resource["author"], false, false )
guiGridListSetItemText ( aTab2.ResourceList, row, 6, resource["version"], false, false )
guiGridListAddRow ( aTab2.ResourceList, resource["name"], resource["numsettings"] > 0 and tostring(resource["numsettings"]) or "", resource["state"], resource["fullName"], resource["author"], resource["version"] )
end
end
end
Expand Down Expand Up @@ -1000,6 +1089,10 @@ end

function aClientClick ( button )
if ( button == "left" ) then
if ( source == aTab1.GroupsClose ) then
guiSetVisible ( aTab1.GroupsWindow, false )
return
end
-- TAB 1, PLAYERS
if ( getElementParent ( source ) == aTab1.Tab ) then
if ( source == aTab1.Messages ) then
Expand All @@ -1020,7 +1113,10 @@ function aClientClick ( button )
else
local name = guiGridListGetItemPlayerName ( aTab1.PlayerList, guiGridListGetSelectedItem( aTab1.PlayerList ), 1 )
local player = getPlayerFromName ( name )
if ( source == aTab1.Kick ) then aInputBox ( "Kick player "..removeColorCoding(name), "Enter the kick reason", "", "kickPlayer", player )
if ( source == aTab1.GroupsView ) then
guiSetVisible ( aTab1.GroupsWindow, true )
guiBringToFront ( aTab1.GroupsWindow )
elseif ( source == aTab1.Kick ) then aInputBox ( "Kick player "..removeColorCoding(name), "Enter the kick reason", "", "kickPlayer", player )
elseif ( source == aTab1.Ban ) then aBanInputBox ( player )
elseif ( source == aTab1.Slap ) then triggerServerEvent ( "aPlayer", localPlayer, player, "slap", aCurrentSlap )
elseif ( source == aTab1.Mute ) then if not aPlayers[player]["mute"] then aMuteInputBox ( player ) else aMessageBox ( "question", "Are you sure to unmute "..removeColorCoding(name).."?", "unmute", player ) end
Expand Down Expand Up @@ -1096,6 +1192,9 @@ function aClientClick ( button )
-- TAB 3, WORLD
elseif ( getElementParent ( source ) == aTab3.Tab ) then
if ( source == aTab3.SetGameType ) then aInputBox ( "Game Type", "Enter game type:", "", "setGameType" )
elseif ( source == aTab3.WeatherListOpen ) then
guiSetVisible ( aTab3.WeatherWindow, true )
guiBringToFront ( aTab3.WeatherWindow )
elseif ( source == aTab3.SetMapName ) then aInputBox ( "Map Name", "Enter map name:", "", "setMapName" )
elseif ( source == aTab3.SetWelcome ) then aInputBox ( "Welcome Message", "Enter the server welcome message:", "", "setWelcome" )
elseif ( source == aTab3.SetPassword ) then aInputBox ( "Server password", "Enter server password: (32 characters max)", "", "setServerPassword" )
Expand Down
Loading
Loading