Skip to content
56 changes: 23 additions & 33 deletions [admin]/admin2/client/main/admin_players.lua
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function aPlayersTab.Create(tab)
addEventHandler("onClientGUIClick", aPlayersTab.Context, aPlayersTab.onContextClick)
addEventHandler("onClientGUIClick", aPlayersTab.InfoContext, aPlayersTab.onContextClick)
addEventHandler("onClientGUIClick", aPlayersTab.Tab, aPlayersTab.onClientClick)
addEventHandler("onClientGUIChanged", aPlayersTab.PlayerListSearch, aPlayersTab.onPlayerListSearch)
addEventHandler("onClientGUIChanged", aPlayersTab.PlayerListSearch, aPlayersTab.onGUIChange)
addEventHandler("onClientPlayerChangeNick", root, aPlayersTab.onClientPlayerChangeNick)
addEventHandler("aClientPlayerJoin", root, aPlayersTab.onClientPlayerJoin)
addEventHandler("onClientPlayerQuit", root, aPlayersTab.onClientPlayerQuit)
Expand Down Expand Up @@ -321,23 +321,9 @@ function aPlayersTab.onClientClick(button)
end
end

function aPlayersTab.onPlayerListSearch()
guiGridListClear(aPlayersTab.PlayerList)
local text = guiGetText(source)
if (text == "") then
for id, player in ipairs(getElementsByType("player")) do
local row = guiGridListAddRow(aPlayersTab.PlayerList)
guiGridListSetItemText(aPlayersTab.PlayerList, row, 1, getPlayerName(player), false, false)
guiGridListSetItemData(aPlayersTab.PlayerList, row, 1, player)
end
else
for id, player in ipairs(getElementsByType("player")) do
if (string.find(string.upper(getPlayerName(player)), string.upper(text))) then
local row = guiGridListAddRow(aPlayersTab.PlayerList)
guiGridListSetItemText(aPlayersTab.PlayerList, row, 1, getPlayerName(player), false, false)
guiGridListSetItemData(aPlayersTab.PlayerList, row, 1, player)
end
end
function aPlayersTab.onGUIChange()
if (source == aPlayersTab.PlayerListSearch) then
aPlayersTab.Refresh()
end
end

Expand Down Expand Up @@ -386,11 +372,11 @@ end
function aPlayersTab.onClientPlayerJoin(ip, username, serial, unused, country, countryname)
if ip == false and serial == false then
-- Update country only
if aPlayers[source] then
aPlayers[source].country = country
aPlayers[source].countryname = countryname
end
return
if aPlayers[source] then
aPlayers[source].country = country
aPlayers[source].countryname = countryname
end
return
end
aPlayers[source] = {}
aPlayers[source].name = getPlayerName(source)
Expand Down Expand Up @@ -551,21 +537,25 @@ end

function aPlayersTab.Refresh()
local selected = getSelectedPlayer()
local list = aPlayersTab.PlayerList
guiGridListClear(list)
local strip = guiCheckBoxGetSelected(aPlayersTab.ColorCodes)
local filter = guiGetText(aPlayersTab.PlayerListSearch):lower()
local sortDirection = guiGetProperty(aPlayersTab.PlayerList, "SortDirection")
guiGridListClear(aPlayersTab.PlayerList)
guiSetProperty(aPlayersTab.PlayerList, "SortDirection", "None")
for id, player in ipairs(getElementsByType("player")) do
local row = guiGridListAddRow(list)
local name = getPlayerName(player)
if (strip) then
name = stripColorCodes(name)
end
guiGridListSetItemText(list, row, 1, name, false, false)
guiGridListSetItemData(list, row, 1, player)
if (player == selected) then
guiGridListSetSelectedItem(list, row, 1)
if name:find(filter) or name:lower():find(filter) then
if (strip) then
name = stripColorCodes(name)
end
local row = guiGridListAddRow(aPlayersTab.PlayerList, name)
guiGridListSetItemData(aPlayersTab.PlayerList, row, 1, player)
if (player == selected) then
guiGridListSetSelectedItem(aPlayersTab.PlayerList, row, 1)
end
end
end
guiSetProperty(aPlayersTab.PlayerList, "SortDirection", sortDirection)
end

function getSelectedPlayer()
Expand Down
4 changes: 1 addition & 3 deletions [admin]/admin2/client/main/admin_resources.lua
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,7 @@ function aResourcesTab.listResources(type)
end
for id, resource in ipairs(temp) do
if (filter and resource.name:lower():find(filter:lower())) or (not filter) then
local row = guiGridListAddRow(resources)
guiGridListSetItemText(resources, row, 1, resource.name, false, false)
guiGridListSetItemText(resources, row, 2, resource.state, false, false)
guiGridListAddRow(resources, resource.name, resource.state)
end
end
end
Expand Down
3 changes: 3 additions & 0 deletions [admin]/admin2/client/widgets/admin_interior.lua
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,15 @@ end

function aInterior.Refresh()
local filter = guiGetText(aInterior.Edit):lower()
local sortDirection = guiGetProperty(aInterior.List, "SortDirection")
guiGridListClear(aInterior.List)
guiSetProperty(aInterior.List, "SortDirection", "None")
for k, v in ipairs(aInterior.interiors) do
if v.world:find(filter) or v.id:lower():find(filter) then
local row = guiGridListAddRow(aInterior.List)
guiGridListSetItemText(aInterior.List, row, 1, v.world, false, true)
guiGridListSetItemText(aInterior.List, row, 2, v.id, false, false)
end
end
guiSetProperty(aInterior.List, "SortDirection", sortDirection)
end
14 changes: 8 additions & 6 deletions [admin]/admin2/client/widgets/admin_skin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,13 @@ function aSkin.Load()
end

function aSkin.Refresh()
aSetSetting("skinsGroup", guiCheckBoxGetSelected(aSkin.Groups))
guiGridListClear(aSkin.List)
local groups = guiCheckBoxGetSelected(aSkin.Groups)
local filter = guiGetText(aSkin.Edit):lower()
if (guiCheckBoxGetSelected(aSkin.Groups)) then
local sortDirection = guiGetProperty(aSkin.List, "SortDirection")
aSetSetting("skinsGroup", groups)
guiGridListClear(aSkin.List)
guiSetProperty(aSkin.List, "SortDirection", "None")
if (groups) then
local skins = {}
for name, group in pairs(aSkin.skins) do
for _, skin in ipairs(group) do
Expand All @@ -164,9 +167,7 @@ function aSkin.Refresh()
local row = guiGridListAddRow(aSkin.List)
guiGridListSetItemText(aSkin.List, row, 2, name, true, false)
for id, skin in ipairs(group) do
row = guiGridListAddRow(aSkin.List)
guiGridListSetItemText(aSkin.List, row, 1, skin.model, false, true)
guiGridListSetItemText(aSkin.List, row, 2, skin.name, false, false)
guiGridListAddRow(aSkin.List, skin.model, skin.name)
end
end
guiGridListSetSortingEnabled(aSkin.List, false)
Expand All @@ -185,5 +186,6 @@ function aSkin.Refresh()
end
end
guiGridListSetSortingEnabled(aSkin.List, true)
guiSetProperty(aSkin.List, "SortDirection", sortDirection)
end
end
8 changes: 5 additions & 3 deletions [admin]/admin2/client/widgets/admin_team.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function aTeam.onDoubleClick(button)
if (guiGridListGetSelectedItem(aTeam.List) ~= -1) then
local team = guiGridListGetItemText(aTeam.List, guiGridListGetSelectedItem(aTeam.List), 1)
triggerServerEvent("aPlayer", localPlayer, getSelectedPlayer(), "setteam", getTeamFromName(team))
aPlayerTeamClose(false)
aTeam.Close(false)
end
end
end
Expand Down Expand Up @@ -147,13 +147,15 @@ end

function aTeam.Refresh()
if (aTeam.List) then
local sortDirection = guiGetProperty(aTeam.List, "SortDirection")
guiGridListClear(aTeam.List)
guiSetProperty(aTeam.List, "SortDirection", "None")
for id, team in ipairs(getElementsByType("team")) do
local row = guiGridListAddRow(aTeam.List)
local row = guiGridListAddRow(aTeam.List, getTeamName(team))
local r, g, b = getTeamColor(team)
guiGridListSetItemText(aTeam.List, row, 1, getTeamName(team), false, false)
guiGridListSetItemColor(aTeam.List, row, 1, r, g, b)
guiGridListSetItemData(aTeam.List, row, 1, team)
end
guiSetProperty(aTeam.List, "SortDirection", sortDirection)
end
end
16 changes: 9 additions & 7 deletions [admin]/admin2/client/widgets/admin_vehicle.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function aVehicle.Show(player)
guiCreateInnerImage("client\\images\\search.png", aVehicle.Edit)

aVehicle.Groups = guiCreateCheckBox(0.03, 0.90, 0.70, 0.09, "Sort by groups", false, true, aVehicle.Form)
if (aGetSetting("weaponsGroup")) then
if (aGetSetting("vehiclesGroup")) then
guiCheckBoxSetSelected(aVehicle.Groups, true)
end

Expand Down Expand Up @@ -141,10 +141,13 @@ function aVehicle.Load()
end

function aVehicle.Refresh()
aSetSetting("weaponsGroup", guiCheckBoxGetSelected(aVehicle.Groups))
guiGridListClear(aVehicle.List)
local groups = guiCheckBoxGetSelected(aVehicle.Groups)
local filter = guiGetText(aVehicle.Edit):lower()
if (guiCheckBoxGetSelected(aVehicle.Groups)) then
local sortDirection = guiGetProperty(aVehicle.List, "SortDirection")
aSetSetting("vehiclesGroup", groups)
guiGridListClear(aVehicle.List)
guiSetProperty(aVehicle.List, "SortDirection", "None")
if (groups) then
local vehicles = {}
for name, group in pairs(aVehicle.vehicles) do
for _, vehicle in ipairs(group) do
Expand All @@ -160,9 +163,7 @@ function aVehicle.Refresh()
local row = guiGridListAddRow(aVehicle.List)
guiGridListSetItemText(aVehicle.List, row, 2, name, true, false)
for id, vehicle in ipairs(group) do
row = guiGridListAddRow(aVehicle.List)
guiGridListSetItemText(aVehicle.List, row, 1, vehicle.id, false, true)
guiGridListSetItemText(aVehicle.List, row, 2, vehicle.name, false, false)
guiGridListAddRow(aVehicle.List, vehicle.id, vehicle.name)
end
end
guiGridListSetSortingEnabled(aVehicle.List, false)
Expand All @@ -181,5 +182,6 @@ function aVehicle.Refresh()
end
end
guiGridListSetSortingEnabled(aVehicle.List, true)
guiSetProperty(aVehicle.List, "SortDirection", sortDirection)
end
end
7 changes: 4 additions & 3 deletions [admin]/admin2/client/widgets/admin_weapon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,10 @@ end
function aWeapon.Refresh()
local groups = guiCheckBoxGetSelected(aWeapon.Groups)
local filter = guiGetText(aWeapon.Edit):lower()
local sortDirection = guiGetProperty(aWeapon.List, "SortDirection")
aSetSetting("weaponsGroup", groups)
guiGridListClear(aWeapon.List)
guiSetProperty(aWeapon.List, "SortDirection", "None")
if (groups) then
local weapons = {}
for name, group in pairs(aWeapon.weapons) do
Expand All @@ -172,9 +174,7 @@ function aWeapon.Refresh()
local row = guiGridListAddRow(aWeapon.List)
guiGridListSetItemText(aWeapon.List, row, 2, name, true, false)
for id, weapon in ipairs(group) do
row = guiGridListAddRow(aWeapon.List)
guiGridListSetItemText(aWeapon.List, row, 1, weapon.id, false, true)
guiGridListSetItemText(aWeapon.List, row, 2, weapon.name, false, false)
guiGridListAddRow(aWeapon.List, weapon.id, weapon.name)
end
end
guiGridListSetSortingEnabled(aWeapon.List, false)
Expand All @@ -193,5 +193,6 @@ function aWeapon.Refresh()
end
end
guiGridListSetSortingEnabled(aWeapon.List, true)
guiSetProperty(aWeapon.List, "SortDirection", sortDirection)
end
end