-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.lua
More file actions
38 lines (35 loc) · 1.95 KB
/
Copy pathserver.lua
File metadata and controls
38 lines (35 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
local ESX = nil
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
RegisterServerEvent('adminButtonSystem:performAction')
AddEventHandler('adminButtonSystem:performAction', function(targetPlayerId, action)
local xPlayer = ESX.GetPlayerFromId(source)
local targetPlayer = ESX.GetPlayerFromId(targetPlayerId)
if xPlayer.getGroup() == 'admin' or xPlayer.getGroup() == 'superadmin' then
if action == 'revive' then
TriggerClientEvent('esx_ambulancejob:revive', targetPlayerId)
MySQL.Async.execute('INSERT INTO admin_buttons (player_id, button_name, action_time) VALUES (@player_id, @button_name, NOW())', {
['@player_id'] = targetPlayer.identifier,
['@button_name'] = 'revive'
})
elseif action == 'kick' then
DropPlayer(targetPlayerId, 'You have been kicked by an admin.')
MySQL.Async.execute('INSERT INTO admin_buttons (player_id, button_name, action_time) VALUES (@player_id, @button_name, NOW())', {
['@player_id'] = targetPlayer.identifier,
['@button_name'] = 'kick'
})
elseif action == 'ban' then
MySQL.Async.execute('INSERT INTO bans (identifier, reason, banned_by, banned_on) VALUES (@identifier, @reason, @banned_by, NOW())', {
['@identifier'] = targetPlayer.identifier,
['@reason'] = 'Banned by admin',
['@banned_by'] = xPlayer.identifier
})
DropPlayer(targetPlayerId, 'You have been banned by an admin.')
MySQL.Async.execute('INSERT INTO admin_buttons (player_id, button_name, action_time) VALUES (@player_id, @button_name, NOW())', {
['@player_id'] = targetPlayer.identifier,
['@button_name'] = 'ban'
})
end
else
print(('adminButtonSystem: %s attempted to perform admin action without permission'):format(xPlayer.identifier))
end
end)