Skip to content

Commit

Permalink
Merge branch 'admin2-bans' of https://github.com/jlillis/mtasa-resources
Browse files Browse the repository at this point in the history
 into admin2-bans
  • Loading branch information
jlillis committed Jan 18, 2024
2 parents 9643a3d + ebe8782 commit 3c53b4e
Show file tree
Hide file tree
Showing 42 changed files with 1,027 additions and 500 deletions.
4 changes: 2 additions & 2 deletions [admin]/admin/client/gui/admin_main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ y=y+B aTab1.VehicleHealth = guiCreateLabel ( 0.26, y, 0.25, 0.04, "Vehicle Heal
aTab3.FPSCurrent = guiCreateLabel ( 0.05, 0.65, 0.25, 0.04, "FPS Limit: 38", true, aTab3.Tab )
aTab3.FPS = guiCreateEdit ( 0.35, 0.65, 0.135, 0.04, "38", true, aTab3.Tab )
aTab3.FPSSet = guiCreateButton ( 0.50, 0.65, 0.10, 0.04, "Set", true, aTab3.Tab, "setfpslimit" )
guiCreateLabel ( 0.63, 0.65, 0.1, 0.04, "( 25-100 )", true, aTab3.Tab )
guiCreateLabel ( 0.63, 0.65, 0.1, 0.04, "( 25-32767 )", true, aTab3.Tab )


aTab4 = {}
Expand Down Expand Up @@ -1435,4 +1435,4 @@ function loadFlagImage( guiStaticImage, countryCode )
end
end
guiStaticImageLoadImage ( guiStaticImage, "client\\images\\empty.png" )
end
end
4 changes: 3 additions & 1 deletion [admin]/admin2/admin_definitions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ enum(
"EVENT_RESOURCE",
"EVENT_SERVER",
"EVENT_MESSAGE",
"EVENT_BANS",
"EVENT_BAN",
"EVENT_NETWORK",
"EVENT_EXECUTE",
"EVENT_PROXY",
Expand All @@ -55,10 +55,12 @@ enum(
{
"SYNC_PLAYER",
"SYNC_PLAYERS",
"SYNC_PLAYERACL",
"SYNC_RESOURCES",
"SYNC_RESOURCE",
"SYNC_ADMINS",
"SYNC_SERVER",
"SYNC_BAN",
"SYNC_BANS",
"SYNC_MESSAGES"
},
Expand Down
2 changes: 1 addition & 1 deletion [admin]/admin2/client/main/admin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ addEventHandler(
function aAdminMain.Open()
if (aAdminMain.Form == nil) then
local x, y = guiGetScreenSize()
aAdminMain.Form = guiCreateWindow(x / 2 - 372, y / 2 - 312, 744, 624, "Admin Menu - v" .. _version, false)
aAdminMain.Form = guiCreateWindow(x / 2 - 375, y / 2 - 300, 750, 600, "Admin Menu - v" .. _version, false)
guiSetText(aAdminMain.Form, "Admin Menu - v" .. _version)
guiCreateLabel(0.75, 0.05, 0.45, 0.04, "Admin Panel by lil_Toady", true, aAdminMain.Form)
aAdminMain.Panel = guiCreateTabPanel(0.01, 0.05, 0.98, 0.95, true, aAdminMain.Form)
Expand Down
54 changes: 19 additions & 35 deletions [admin]/admin2/client/main/admin_bans.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ function aBansTab.Create(tab)
guiGridListAddColumn(aBansTab.BansList, "Name", 0.22)
guiGridListAddColumn(aBansTab.BansList, "IP", 0.25)
guiGridListAddColumn(aBansTab.BansList, "Serial", 0.25)
guiGridListAddColumn(aBansTab.BansList, "Username", 0.25)
guiGridListAddColumn(aBansTab.BansList, "Date", 0.17)
guiGridListAddColumn(aBansTab.BansList, "Expires", 0.17)
guiGridListAddColumn(aBansTab.BansList, "Banned by", 0.22)
guiGridListAddColumn(aBansTab.BansList, "Temporary", 0.22)
aBansTab.Details = guiCreateButton(0.82, 0.07, 0.17, 0.04, "Details", true, aBansTab.Tab)
aBansTab.Unban = guiCreateButton(0.82, 0.12, 0.17, 0.04, "Unban", true, aBansTab.Tab, "unban")
aBansTab.Ban = guiCreateButton(0.82, 0.12, 0.17, 0.04, "Add ban", true, aBansTab.Tab, "ban")
aBansTab.Unban = guiCreateButton(0.82, 0.17, 0.17, 0.04, "Unban", true, aBansTab.Tab, "unban")
aBansTab.BansRefresh = guiCreateButton(0.82, 0.94, 0.17, 0.04, "Refresh", true, aBansTab.Tab, "listbans")

addEventHandler("onClientGUIChanged", aBansTab.BansListSearch, aBansTab.onBansListSearch)
Expand All @@ -41,26 +40,21 @@ function aBansTab.onClientClick(button)
if (button == "left") then
if (source == aBansTab.Details) then
if (guiGridListGetSelectedItem(aBansTab.BansList) == -1) then
messageBox("No ban row selected!", MB_ERROR, MB_OK)
messageBox("No ban selected!", MB_ERROR, MB_OK)
else
local ip = guiGridListGetItemText(aBansTab.BansList, guiGridListGetSelectedItem(aBansTab.BansList), 2)
aBanDetails(ip)
local banID =
guiGridListGetItemData(aBansTab.BansList, guiGridListGetSelectedItem(aBansTab.BansList), 1)
aBanDetails.Show(banID, false)
end
elseif source == aBansTab.Ban then
aBan.Show()
elseif (source == aBansTab.Unban) then
if (guiGridListGetSelectedItem(aBansTab.BansList) == -1) then
messageBox("No ban row selected!", MB_ERROR, MB_OK)
messageBox("No ban selected!", MB_ERROR, MB_OK)
else
local selected =
guiGridListGetItemText(aBansTab.BansList, guiGridListGetSelectedItem(aBansTab.BansList), 2)
if (aBans["Serial"][selected]) then
if (messageBox("Unban Serial " .. selected .. "?", MB_QUESTION, MB_YESNO ) == true) then
triggerServerEvent ( "aBans", localPlayer, "unbanserial", selected )
end
else
if (messageBox("Unban IP " .. selected .. "?", MB_QUESTION, MB_YESNO) == true) then
triggerServerEvent ( "aBans", localPlayer, "unbanip", selected )
end
end
local banID =
guiGridListGetItemData(aBansTab.BansList, guiGridListGetSelectedItem(aBansTab.BansList), 1)
aBanDetails.Show(banID, true)
end
elseif (source == aBansTab.BansRefresh) then
guiGridListClear(aBansTab.BansList)
Expand All @@ -80,7 +74,6 @@ function aBansTab.onBansListSearch()
((ban.nick and string.find(string.upper(ban.nick), text)) or
(ban.ip and string.find(string.upper(ban.ip), text)) or
(ban.serial and string.find(string.upper(ban.serial), text)) or
(ban.username and string.find(string.upper(ban.username), text)) or
(ban.banner and string.find(string.upper(ban.banner), text)))
then
aBansTab.AddRow(id, ban)
Expand Down Expand Up @@ -117,29 +110,20 @@ function aBansTab.AddRow(id, data)
guiGridListSetItemText(list, row, 1, data.nick or "Unknown", false, false)
guiGridListSetItemText(list, row, 2, data.ip or "", false, false)
guiGridListSetItemText(list, row, 3, data.serial or "", false, false)
guiGridListSetItemText(list, row, 4, data.username or "", false, false)
if (data.time) then
local time = getRealTime(data.time)
guiGridListSetItemText(
list,
row,
5,
time.monthday .. " " .. getMonthName(time.month) .. " " .. (1900 + time.year),
false,
false
)
if (data.unban) then
guiGridListSetItemText(list, row, 4, formatDate("m/d/y h:m", nil, data.unban), false, false)
else
guiGridListSetItemText(list, row, 5, "", false, false)
guiGridListSetItemText(list, row, 4, "Never", false, false)
end
guiGridListSetItemText(list, row, 6, data.banner or "", false, false)
guiGridListSetItemText(list, row, 7, iif(data.unban, "Yes", "No"), false, false)
guiGridListSetItemText(list, row, 5, data.banner or "", false, false)

guiGridListSetItemData(list, row, 1, id)
end

function aBansTab.DeleteRow(id)
local list = aBansTab.BansList
for i = 1, guiGridListGetRowCount(list) do
-- GridList row ids start at zero, not one
for i = 0, guiGridListGetRowCount(list) do
local data = guiGridListGetItemData(list, i, 1)
if (data == id) then
guiGridListRemoveRow(list, i)
Expand Down
79 changes: 31 additions & 48 deletions [admin]/admin2/client/main/admin_players.lua
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function aPlayersTab.Create(tab)
aPlayersTab.Shout = guiCreateButton(0.74, 0.19, 0.12, 0.04, "Shout", true, tab, "shout")
aPlayersTab.Spectate = guiCreateButton(0.87, 0.19, 0.12, 0.04, "Spectate", true, tab, "spectate")
aPlayersTab.SetNick = guiCreateButton(0.74, 0.235, 0.12, 0.04, "Set nick", true, tab, "setnick")
aPlayersTab.Admin = guiCreateButton(0.87, 0.235, 0.12, 0.04, "Give admin", true, tab, "setgroup")
aPlayersTab.Permissions = guiCreateButton(0.87, 0.235, 0.12, 0.04, "Permissions", true, tab, "setgroup")
aPlayersTab.SlapOptions = guiCreateComboBox(0.76, 0.28, 0.1, 0.04, "0", true, tab)
local width, height = guiGetSize(aPlayersTab.SlapOptions, false)
for i = 0, 200, 20 do
Expand Down 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 @@ -168,10 +168,7 @@ function aPlayersTab.onClientClick(button)
triggerServerEvent("aPlayer", localPlayer, player, "kick", reason)
end
elseif (source == aPlayersTab.Ban) then
local reason = inputBox("Ban player " .. name, "Enter the ban reason")
if (reason) then
triggerServerEvent("aPlayer", localPlayer, player, "ban", reason)
end
aBan.Show(player)
elseif (source == aPlayersTab.Slap) then
triggerServerEvent("aPlayer", localPlayer, player, "slap",
guiComboBoxGetItemText(aPlayersTab.SlapOptions, guiComboBoxGetSelected(aPlayersTab.SlapOptions))
Expand All @@ -193,7 +190,7 @@ function aPlayersTab.onClientClick(button)
elseif (source == aPlayersTab.Spectate) then
aSpectate(player)
elseif (source == aPlayersTab.SetNick) then
local nick = inputBox("Set nick", "Enter new nickname for " .. name)
local nick = inputBox("Set nick", "Enter new nickname for " .. name, name)
if (nick) then
triggerServerEvent("aPlayer", localPlayer, player, "setnick", nick)
end
Expand Down Expand Up @@ -257,14 +254,11 @@ function aPlayersTab.onClientClick(button)
end
elseif (source == aPlayersTab.WarpPlayer) then
aPlayerWarp(player)
elseif (source == aPlayersTab.Admin) then
if
(aPlayers[player]["admin"] and
messageBox("Revoke admin rights from " .. name .. "?", MB_WARNING))
then
triggerServerEvent("aPlayer", localPlayer, player, "setgroup", false)
elseif (messageBox("Give admin rights to " .. name .. "?", MB_WARNING)) then
triggerServerEvent("aPlayer", localPlayer, player, "setgroup", true)
elseif (source == aPlayersTab.Permissions) then
if (aPlayers[player]['account'] ~= 'guest') then
aPermissions.Show(player)
else
messageBox("This player is not logged in!", MB_ERROR, MB_ERROR)
end
end
end
Expand Down Expand Up @@ -298,7 +292,6 @@ function aPlayersTab.onClientClick(button)
guiSetText(aPlayersTab.Groups, "Groups: N/A")
guiSetText(aPlayersTab.Mute, "Mute")
guiSetText(aPlayersTab.Freeze, "Freeze")
guiSetText(aPlayersTab.Admin, "Give admin")
guiSetText(aPlayersTab.Health, "Health: 0%")
guiSetText(aPlayersTab.Armour, "Armour: 0%")
guiSetText(aPlayersTab.Skin, "Skin: N/A")
Expand All @@ -321,23 +314,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 +365,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 +530,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
23 changes: 17 additions & 6 deletions [admin]/admin2/client/main/admin_server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ function aServerTab.Create(tab)
aServerTab.Waves = guiCreateEdit(0.35, 0.665, 0.135, 0.04, "0", true, tab)
aServerTab.WavesSet = guiCreateButton(0.50, 0.665, 0.10, 0.04, "Set", true, tab, "setwaveheight")

aServerTab.FPSCurrent = guiCreateLabel(0.03, 0.710, 0.25, 0.035, "FPS Limit: 36", true, tab)
aServerTab.FPS = guiCreateEdit(0.35, 0.710, 0.135, 0.04, "36", true, tab)
local fpsLimit = getFPSLimit()
aServerTab.FPSCurrent = guiCreateLabel(0.03, 0.710, 0.25, 0.035, "FPS Limit: "..fpsLimit, true, tab)
aServerTab.FPS = guiCreateEdit(0.35, 0.710, 0.135, 0.04, fpsLimit, true, tab)
aServerTab.FPSSet = guiCreateButton(0.50, 0.710, 0.10, 0.04, "Set", true, tab, "setfpslimit")

guiCreateHeader(0.02, 0.755, 0.30, 0.035, "Automatic scripts:", true, tab)
Expand Down Expand Up @@ -258,11 +259,21 @@ function aServerTab.onClientClick(button)
end
elseif (source == aServerTab.FPSSet) then
local fps = guiGetText(aServerTab.FPS)
if tonumber(fps) then
fps = fps and tonumber(fps) or 0
if fps >= 25 and fps <= 32767 then
-- Warn user of fps-related physics bugs when fps > 74, per notes at https://wiki.multitheftauto.com/wiki/SetFPSLimit
if fps > 74 then
if not messageBox("74 FPS is the breaking point that opens the door to various severe GTA bugs related to physics, and setting a higher limit than this is not recommended. Are you sure you want to proceed?", MB_WARNING, MB_YESNO) then
guiSetText(aServerTab.FPS, getFPSLimit())
return
end
end
triggerServerEvent("aServer", localPlayer, "setfpslimit", fps)
elseif #fps == 0 then
triggerServerEvent("aServer", localPlayer, "setfpslimit", 36) -- 36 is default
guiSetText(aServerTab.FPS, 36)
elseif fps == 0 then
triggerServerEvent("aServer", localPlayer, "setfpslimit", 74) -- 74 is default
guiSetText(aServerTab.FPS, 74)
else
messageBox("Invalid FPS limit: range is 25 - 32767, or 0 for default.", MB_ERROR, MB_OK)
end
elseif (source == aServerTab.QuickReload) then
triggerServerEvent(
Expand Down
Loading

0 comments on commit 3c53b4e

Please sign in to comment.