Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

admin: some tweaks #347

Merged
merged 17 commits into from
Sep 25, 2021
Merged
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
8 changes: 0 additions & 8 deletions [admin]/admin/client/admin_client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,6 @@ function realTimeToSeconds( time )
return seconds
end

function realTimeToSecondsTest()
for i=1,100 do
local time1 = getRealTime( math.random(0, 60*60*24*365*50) ) -- Get a random date between 1970 and 2020
local time2 = getRealTime( realTimeToSeconds( time1 ) )
assert( getRealDateTimeString( time1 ) == getRealDateTimeString( time2 ) )
end
end

-- seconds to description i.e. "10 mins"
function secondsToTimeDesc( seconds )
if seconds then
Expand Down
2 changes: 1 addition & 1 deletion [admin]/admin/client/gui/admin_acl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function aManageACL ()
end

function aACLClose ( destroy )
if ( ( destroy ) or ( aPerformanceACL and guiCheckBoxGetSelected ( aPerformanceACL ) ) ) then
if ( destroy ) then
if ( aAclForm ) then
removeEventHandler ( "onClientGUIClick", aAclForm, aClientACLClick )
removeEventHandler ( "onClientGUIDoubleClick", aAclForm, aClientACLDoubleClick )
Expand Down
2 changes: 1 addition & 1 deletion [admin]/admin/client/gui/admin_interior.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function aPlayerInterior ( player )
end

function aPlayerInteriorClose ( destroy )
if ( ( destroy ) or ( aPerformanceInterior and guiCheckBoxGetSelected ( aPerformanceInterior ) ) ) then
if ( destroy ) then
if ( aInteriorForm ) then
removeEventHandler ( "onClientGUIDoubleClick", aInteriorForm, aClientInteriorDoubleClick )
removeEventHandler ( "onClientGUIClick", aInteriorForm, aClientInteriorClick )
Expand Down
8 changes: 2 additions & 6 deletions [admin]/admin/client/gui/admin_main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,6 @@ function aAdminRefresh ()
guiSetText ( aTab1.Name, "Name: ".. playerName)
guiSetText ( aTab1.Mute, iif ( aPlayers[player]["mute"], "Unmute", "Mute" ) )
guiSetText ( aTab1.Freeze, iif ( aPlayers[player]["freeze"], "Unfreeze", "Freeze" ) )
--guiSetText ( aTab1.Username, "Community Username: "..( aPlayers[player]["username"] or "" ) )
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" ) )
Expand All @@ -515,7 +514,7 @@ function aAdminRefresh ()
guiSetText ( aTab1.Money, "Money: "..( aPlayers[player]["money"] or 0 ) )
if ( getElementDimension ( player ) ) then guiSetText ( aTab1.Dimension, "Dimension: "..getElementDimension ( player ) ) end
if ( getElementInterior ( player ) ) then guiSetText ( aTab1.Interior, "Interior: "..getElementInterior ( player ) ) end
guiSetText ( aTab1.JetPack, iif ( doesPedHaveJetPack ( player ), "Remove JetPack", "Give JetPack" ) )
guiSetText ( aTab1.JetPack, iif ( isPedWearingJetpack ( player ), "Remove JetPack", "Give JetPack" ) )
if ( getPedWeapon ( player ) ) then guiSetText ( aTab1.Weapon, "Weapon: "..getWeaponNameFromID ( getPedWeapon ( player ) ).." (ID: "..getPedWeapon ( player )..")" ) end

local x, y, z = getElementPosition ( player )
Expand Down Expand Up @@ -776,7 +775,7 @@ function aClientResourceStop ( resource )
end
end

function aClientPlayerJoin ( ip, username, accountname, serial, admin, country )
function aClientPlayerJoin ( ip, accountname, serial, admin, country )
if ip == false and serial == false then
-- Update country only
if aPlayers[source] then
Expand All @@ -787,7 +786,6 @@ function aClientPlayerJoin ( ip, username, accountname, serial, admin, country )
aPlayers[source] = {}
aPlayers[source]["name"] = getPlayerName ( source )
aPlayers[source]["IP"] = ip
aPlayers[source]["username"] = username or "N/A"
aPlayers[source]["accountname"] = accountname or "N/A"
aPlayers[source]["serial"] = serial
aPlayers[source]["admin"] = admin
Expand Down Expand Up @@ -1250,14 +1248,12 @@ function aAdminReloadInfos()
outputConsole(('Name: %s'):format(playerName))
outputConsole(('IP: %s'):format(aPlayers[player]["IP"]))
outputConsole(('Serial: %s'):format(aPlayers[player]["serial"]))
-- outputConsole(('Community Username: %s'):format(aPlayers[player]["username"]))
outputConsole(('Account Name: %s'):format(aPlayers[player]["accountname"]))
outputConsole(('D3D9.DLL: %s'):format(aPlayers[player]["d3d9dll"]))
outputConsole(' ')
end
guiSetText ( aTab1.IP, "IP: "..getSensitiveText( aPlayers[player]["IP"] ) )
guiSetText ( aTab1.Serial, "Serial: "..getSensitiveText( aPlayers[player]["serial"] ) )
--guiSetText ( aTab1.Username, "Community Username: "..aPlayers[player]["username"] )
guiSetText ( aTab1.Accountname, "Account Name: "..getSensitiveText( aPlayers[player]["accountname"] ) )
guiSetText ( aTab1.ACDetected, "AC Detected: "..aPlayers[player]["acdetected"] )
guiSetText ( aTab1.ACD3D, "D3D9.DLL: "..aPlayers[player]["d3d9dll"] )
Expand Down
2 changes: 1 addition & 1 deletion [admin]/admin/client/gui/admin_messagebox.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
**************************************]]

aMessageForm = nil
local varOne, varTwo, varThree = vOne, vTwo, vThree
local varOne, varTwo, varThree

function aMessageBox ( type, message, action, vOne, vTwo, vThree )
local x, y = guiGetScreenSize()
Expand Down
2 changes: 1 addition & 1 deletion [admin]/admin/client/gui/admin_permissions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ function aPermissions.ConfirmChange(add)

if (not isElement(player)) then
aPermissions.Close(false)
messageBox("Player not found!", MB_WARNING)
aMessageBox ( "error", "Player not found!")
return
end

Expand Down
2 changes: 1 addition & 1 deletion [admin]/admin/client/gui/admin_settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function aManageSettings ( resName )
end

function aSettingsClose ( destroy )
if ( ( destroy ) or ( aPerformanceSettings and guiCheckBoxGetSelected ( aPerformanceSettings ) ) ) then
if ( destroy ) then
if ( aSettingsForm ) then
removeEventHandler ( "onClientGUIClick", aSettingsForm, aClientSettingsClick )
removeEventHandler ( "onClientGUIDoubleClick", aSettingsForm, aClientSettingsDoubleClick )
Expand Down
2 changes: 1 addition & 1 deletion [admin]/admin/client/gui/admin_spectator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function aSpectator.Close ( destroy )
toggleControl ( "aim_weapon", true )
removeEventHandler ( "onClientPlayerWasted", _root, aSpectator.PlayerCheck )
removeEventHandler ( "onClientPlayerQuit", _root, aSpectator.PlayerCheck )
removeEventHandler ( "onClientMouseMove", _root, aSpectator.CursorMove )
removeEventHandler ( "onClientCursorMove", _root, aSpectator.CursorMove )
removeEventHandler ( "onClientPreRender", _root, aSpectator.Render )

if ( ( destroy ) or ( guiCheckBoxGetSelected ( aPerformanceSpectator ) ) ) then
Expand Down
6 changes: 3 additions & 3 deletions [admin]/admin/client/gui/admin_vehicle.lua
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,9 @@ function aClientVehicleClick ( button )
triggerServerEvent ( "aVehicle", getLocalPlayer(), aVehicleCustomizePlayer, "setlights", { guiGetText ( aLightsColor ) } )
elseif ( source == aLicensePlateSet ) then
triggerServerEvent ( "aVehicle", getLocalPlayer(), aVehicleCustomizePlayer, "setplates", { guiGetText ( aLicensePlate ) } )
elseif ( source == aVehicleColorScheme ) then
guiSetVisible ( aVehicleColorForm, true )
guiBringToFront ( aVehicleColorForm )
stoneage-mta marked this conversation as resolved.
Show resolved Hide resolved
-- elseif ( source == aVehicleColorScheme ) then
-- guiSetVisible ( aVehicleColorForm, true )
-- guiBringToFront ( aVehicleColorForm )
elseif ( source == aVehicleUpgradeAll ) then
triggerServerEvent ( "aVehicle", getLocalPlayer(), aVehicleCustomizePlayer, "customize", { "all" } )
setTimer ( aVehicleCheckCurrentUpgrades, 2000, 1, aVehicleCustomizeVehicle )
Expand Down
4 changes: 2 additions & 2 deletions [admin]/admin/client/gui/admin_warp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function aPlayerWarp ( player )
end

function aPlayerWarpClose ( destroy )
if ( ( destroy ) or ( aPerformanceWarp and guiCheckBoxGetSelected ( aPerformanceWarp ) ) ) then
if ( destroy ) then
if ( aWarpForm ) then
removeEventHandler ( "onClientGUIDoubleClick", aWarpForm, aClientWarpDoubleClick )
removeEventHandler ( "onClientGUIClick", aWarpForm, aClientWarpClick )
Expand Down Expand Up @@ -73,7 +73,7 @@ function aPlayerWarpToPosition ( )
end

function aPlayerWarpToPositionClose ( destroy )
if ( ( destroy ) or ( aPerformanceWarp and guiCheckBoxGetSelected ( aPerformanceWarp ) ) ) then
if ( destroy ) then
if ( aWarpToPositionForm ) then
removeEventHandler ( "onClientGUIDoubleClick", aWarpToPositionForm, aClientWarpDoubleClick )
removeEventHandler ( "onClientGUIClick", aWarpToPositionForm, aClientWarpClick )
Expand Down
2 changes: 1 addition & 1 deletion [admin]/admin/meta.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<meta>
<info author="lil_Toady" type="misc" version="1.5.9" />
<min_mta_version server="1.3.3" client="1.5.6-9.16361"/>
<min_mta_version server="1.5.5-9.13846" client="1.5.6-9.16361"/>
<!--
Admin System Meta File.

Expand Down
27 changes: 14 additions & 13 deletions [admin]/admin/server/admin_server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ addEventHandler ( "onPlayerJoin", _root, function ()
aPlayerInitialize ( source )
for id, player in ipairs(getElementsByType("player")) do
if ( hasObjectPermissionTo ( player, "general.adminpanel" ) ) then
triggerClientEvent ( player, "aClientPlayerJoin", source, getPlayerIP ( source ), getPlayerUserName ( source ), getPlayerAccountName ( source ), getPlayerSerial ( source ), hasObjectPermissionTo ( source, "general.adminpanel" ), aPlayers[source]["country"] )
triggerClientEvent ( player, "aClientPlayerJoin", source, getPlayerIP ( source ), getPlayerAccountName ( source ), getPlayerSerial ( source ), hasObjectPermissionTo ( source, "general.adminpanel" ), aPlayers[source]["country"] )
end
end
setPedGravity ( source, getGravity() )
Expand All @@ -394,7 +394,7 @@ function aPlayerInitialize ( player )
kickPlayer ( player, "Invalid Serial" )
else
bindKey ( player, "p", "down", "admin" )
--callRemote ( "http://community.mtasa.com/mta/verify.php", aPlayerSerialCheck, player, getPlayerUserName ( player ), getPlayerSerial ( player ) )
--callRemote ( "http://community.mtasa.com/mta/verify.php", aPlayerSerialCheck, player, getPlayerSerial ( player ) )
aPlayers[player] = {}
aPlayers[player]["country"] = getPlayerCountry ( player )
aPlayers[player]["money"] = getPlayerMoney ( player )
Expand Down Expand Up @@ -440,7 +440,7 @@ addEventHandler ( "aPlayerVersion", _root, function ( version )
end

-- Format it all prettyful
local _,_,ver,type,build = string.find ( playerVersion, "(.*)-([0-9])\.(.*)" )
local _,_,ver,type,build = string.find ( playerVersion, "(.*)-([0-9])%.(.*)" )
if aPlayers[source] then
aPlayers[source]["version"] = ver .. ( type < '9' and " pre " or " " ) .. "(" .. type .. "." .. build .. ")"
end
Expand Down Expand Up @@ -569,7 +569,6 @@ addEvent ( "aTeam", true )
addEventHandler ( "aTeam", _root, function ( action, name, r, g, b )
if checkClient( "command."..action, source, 'aTeam', action ) then return end
if ( hasObjectPermissionTo ( client or source, "command."..action ) ) then
mdata = tostring ( data )
mdata = ""
if ( action == "createteam" ) then
local success = false
Expand All @@ -592,7 +591,7 @@ addEventHandler ( "aTeam", _root, function ( action, name, r, g, b )
else
action = nil
end
if ( action ~= nil ) then aAction ( "server", action, source, false, mdata, mdata2 ) end
if ( action ~= nil ) then aAction ( "server", action, source, false, mdata ) end
return true
end
outputChatBox ( "Access denied for '"..tostring ( action ).."'", source, 255, 168, 0 )
Expand Down Expand Up @@ -880,7 +879,7 @@ function warp ( p, to )
r, dim, int = 0, 0, 0
else
x, y, z = getElementPosition ( to )
r = getPedRotation ( to )
_, _, r = getElementRotation ( to )
dim = getElementDimension ( to )
int = getElementInterior ( to )
end
Expand Down Expand Up @@ -1070,7 +1069,7 @@ addEventHandler ( "aPlayer", _root, function ( player, action, data, additional,
setElementPosition ( vehicle, x, y, z + 0.2 )
else
setElementPosition ( player, x, y, z + 0.2 )
setPedRotation ( player, rot )
setElementRotation ( player, 0, 0, rot, 'default', true )
end
action = "interior"
mdata = data
Expand All @@ -1088,13 +1087,13 @@ addEventHandler ( "aPlayer", _root, function ( player, action, data, additional,
action = nil
end
elseif ( action == "jetpack" ) then
if ( doesPedHaveJetPack ( player ) ) then
removePedJetPack ( player )
if ( isPedWearingJetpack ( player ) ) then
setPedWearingJetpack ( player, false )
action = "jetpackr"
else
if ( getPedOccupiedVehicle ( player ) ) then outputChatBox ( "Unable to give a jetpack - "..getPlayerName ( player ).." is in a vehicle", source, 255, 0, 0 )
else
if ( givePedJetPack ( player ) ) then
if ( setPedWearingJetpack ( player, true ) ) then
action = "jetpacka"
end
end
Expand Down Expand Up @@ -1130,7 +1129,7 @@ addEventHandler ( "aPlayer", _root, function ( player, action, data, additional,
fixVehicle(vehicle)
else
local x, y, z = getElementPosition ( player )
local r = getPedRotation ( player )
local _, _, r = getElementRotation ( player )
local vx, vy, vz = getElementVelocity ( player )
vehicle = createVehicle ( data, x, y, z, 0, 0, r )
setElementDimension ( vehicle, getElementDimension ( player ) )
Expand Down Expand Up @@ -1217,10 +1216,10 @@ addEventHandler ( "aVehicle", _root, function ( player, action, data )
local mdata = ""
if ( action == "repair" ) then
fixVehicle ( vehicle )
local rx, ry, rz = getVehicleRotation ( vehicle )
local rx, ry, rz = getElementRotation ( vehicle )
if ( rx > 110 ) and ( rx < 250 ) then
local x, y, z = getElementPosition ( vehicle )
setVehicleRotation ( vehicle, rx + 180, ry, rz )
setElementRotation ( vehicle, rx + 180, ry, rz )
setElementPosition ( vehicle, x, y, z + 2 )
end
elseif ( action == "customize" ) then
Expand Down Expand Up @@ -1637,6 +1636,8 @@ function checkClient(checkAccess,player,...)
return false -- Access ok
end
if hasObjectPermissionTo ( player, "general.adminpanel" ) then
local desc = table.concat({...}," ")
local ipAddress = getPlayerIP(player)
outputDebugString( "Admin security - Client does not have required rights ("..checkAccess.."). " .. tostring(ipAddress) .. " (" .. tostring(desc) .. ")" )
return true -- Low risk fail - Can't do specific command, but has access to admin panel
end
Expand Down
16 changes: 0 additions & 16 deletions [admin]/admin/server/admin_sync.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ function aSynchCoroutineFunc( type, data, typeOfTag, banSearchTag )
tableOut["mute"] = isPlayerMuted ( data )
tableOut["freeze"] = isPlayerFrozen ( data )
tableOut["money"] = getPlayerMoney ( data )
tableOut["username"] = getPlayerUserName ( data ) or "N/A"
tableOut["version"] = aPlayers[data]["version"]
tableOut["accountname"] = getPlayerAccountName ( data ) or "N/A"
tableOut["groups"] = "None"
Expand All @@ -48,7 +47,6 @@ function aSynchCoroutineFunc( type, data, typeOfTag, banSearchTag )
tableOut[player] = {}
tableOut[player]["name"] = getPlayerName ( player )
tableOut[player]["IP"] = getPlayerIP ( player )
tableOut[player]["username"] = getPlayerUserName ( player ) or "N/A"
tableOut[player]["version"] = aPlayers[player]["version"]
tableOut[player]["accountname"] = getPlayerAccountName ( player ) or "N/A"
tableOut[player]["serial"] = getPlayerSerial ( player )
Expand Down Expand Up @@ -124,20 +122,6 @@ function aSynchCoroutineFunc( type, data, typeOfTag, banSearchTag )
tableOut["map"] = getMapName()
tableOut["password"] = getServerPassword()
tableOut["fps"] = getFPSLimit()
elseif ( type == "rights" ) then
stoneage-mta marked this conversation as resolved.
Show resolved Hide resolved
for gi, group in ipairs ( aclListGroups() ) do
stoneage-mta marked this conversation as resolved.
Show resolved Hide resolved
for oi, object in ipairs ( aclGroupListObjects ( group ) ) do
if ( ( object == data ) or ( object == "user.*" ) ) then
for ai, acl in ipairs ( aclGroupListACL ( group ) ) do
for ri, right in ipairs ( aclListRights ( acl ) ) do
local access = aclGetRight ( acl, string )
stoneage-mta marked this conversation as resolved.
Show resolved Hide resolved
if ( access ) then table.insert ( tableOut, right ) end
stoneage-mta marked this conversation as resolved.
Show resolved Hide resolved
end
end
break
end
end
end
elseif ( type == "bansdirty" ) then
tableOut = nil
g_Bans = nil
Expand Down