Skip to content

Commit ef59929

Browse files
authored
admin: check the client for permission instead of the event source (#300)
* Check the client for permission instead of the event source * Added fallback to source in case the event is triggered from the server side Co-authored-by: NanoBob <[email protected]>
1 parent 519cd11 commit ef59929

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

[admin]/admin/server/admin_server.lua

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ end
568568
addEvent ( "aTeam", true )
569569
addEventHandler ( "aTeam", _root, function ( action, name, r, g, b )
570570
if checkClient( "command."..action, source, 'aTeam', action ) then return end
571-
if ( hasObjectPermissionTo ( source, "command."..action ) ) then
571+
if ( hasObjectPermissionTo ( client or source, "command."..action ) ) then
572572
mdata = tostring ( data )
573573
mdata = ""
574574
if ( action == "createteam" ) then
@@ -878,7 +878,7 @@ addEventHandler ( "aPlayer", _root, function ( player, action, data, additional,
878878
if not isElement( player ) then
879879
return -- Ignore if player is no longer valid
880880
end
881-
if ( hasObjectPermissionTo ( source, "command."..action ) ) then
881+
if ( hasObjectPermissionTo ( client or source, "command."..action ) ) then
882882
local admin = source
883883
local mdata = ""
884884
local more = ""
@@ -1187,7 +1187,7 @@ end
11871187
addEvent ( "aVehicle", true )
11881188
addEventHandler ( "aVehicle", _root, function ( player, action, data )
11891189
if checkClient( "command."..action, source, 'aVehicle', action ) then return end
1190-
if ( hasObjectPermissionTo ( source, "command."..action ) ) then
1190+
if ( hasObjectPermissionTo ( client or source, "command."..action ) ) then
11911191
if ( not player ) then return end
11921192
local vehicle = getPedOccupiedVehicle ( player )
11931193
if ( vehicle ) then
@@ -1271,7 +1271,7 @@ addEvent ( "aResource", true )
12711271
addEventHandler ( "aResource", _root, function ( name, action )
12721272
if checkClient( "command."..action, source, 'aResource', action ) then return end
12731273
local pname = getPlayerName ( source )
1274-
if ( hasObjectPermissionTo ( source, "command."..action ) ) then
1274+
if ( hasObjectPermissionTo ( client or source, "command."..action ) ) then
12751275
local text = ""
12761276
if ( action == "start" ) then if ( startResource ( getResourceFromName ( name ), true ) ) then text = "started" end
12771277
elseif ( action == "restart" ) then
@@ -1298,7 +1298,7 @@ end )
12981298
addEvent ( "aServer", true )
12991299
addEventHandler ( "aServer", _root, function ( action, data, data2 )
13001300
if checkClient( "command."..action, source, 'aServer', action ) then return end
1301-
if ( hasObjectPermissionTo ( source, "command."..action ) ) then
1301+
if ( hasObjectPermissionTo ( client or source, "command."..action ) ) then
13021302
local mdata = tostring ( data )
13031303
local mdata2 = ""
13041304
if ( action == "setgame" ) then
@@ -1452,7 +1452,7 @@ addEventHandler ( "aMessage", _root, function ( action, data )
14521452
table.remove( aReports, 1 )
14531453
end
14541454
end
1455-
if ( hasObjectPermissionTo ( source, "general.adminpanel" ) ) then
1455+
if ( hasObjectPermissionTo ( client or source, "general.adminpanel" ) ) then
14561456
if ( action == "get" ) then
14571457
triggerClientEvent ( source, "aMessage", source, "get", aReports )
14581458
elseif ( action == "read" ) then
@@ -1487,7 +1487,7 @@ end )
14871487
addEvent ( "aBans", true )
14881488
addEventHandler ( "aBans", _root, function ( action, data, arg1, arg2, arg3 )
14891489
if checkClient( "command."..action, source, 'aBans', action ) then return end
1490-
if ( hasObjectPermissionTo ( source, "command."..action ) ) then
1490+
if ( hasObjectPermissionTo ( client or source, "command."..action ) ) then
14911491
local mdata = ""
14921492
local more = ""
14931493
if ( action == "banip" ) then
@@ -1548,7 +1548,7 @@ end )
15481548
addEvent ( "aExecute", true )
15491549
addEventHandler ( "aExecute", _root, function ( action, echo )
15501550
if checkClient( "command.execute", source, 'aExecute', action ) then return end
1551-
if ( hasObjectPermissionTo ( source, "command.execute" ) ) then
1551+
if ( hasObjectPermissionTo ( client or source, "command.execute" ) ) then
15521552
local result = loadstring("return " .. action)()
15531553
if ( echo == true ) then
15541554
local restring = ""

0 commit comments

Comments
 (0)