Skip to content

Commit

Permalink
feat: security: checking for illegal range changes
Browse files Browse the repository at this point in the history
  • Loading branch information
lze3 committed Jun 26, 2020
1 parent 3e1c0b7 commit e7c46a6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions hlabels/client/c_hlabel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ fontId = RegisterFontId("Comic Sans MS")
RegisterNetEvent('setHeadLabelDistance')
AddEventHandler('setHeadLabelDistance', function(distance)
disPlayerNames = distance
TriggerServerEvent("onClientHeadLabelRangeChange", distance)
end)

local LocalPlayer = {
Expand Down
18 changes: 17 additions & 1 deletion hlabels/server/s_hlabel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,20 @@ RegisterCommand('hlrange', function(source, args)
args = { "Head Labels", "You have set your head label display range to: [ " .. foundRange.name:upper() .. " ]." },
color = colours.SUCCESS
})
end, false)
end, false)

RegisterNetEvent("onClientHeadLabelRangeChange")
AddEventHandler("onClientHeadLabelRangeChange", function(change)
local source = source
-- ok, this is bad!
if not IsPlayerAceAllowed(source, "hlabels.hlrange") then
local thisResourceName = {
DROP = GetCurrentResourceName() .. " (hlabels)",
CONSOLE = "^7[^4" .. GetCurrentResourceName() .. "^7]"
}
local message = "Detected an unauthorized altercation of"
print("^1(ALERT) " .. thisResourceName.CONSOLE .. ": ^3" .. message .. " player [ " .. GetPlayerName(source) .. " | " .. source .. " ] head label range. ^1Dropping the " ..
"player from the server now.^7")
DropPlayer(source, "Dropped as a protection of the " .. thisResourceName.DROP .. " resource. " .. message .. " your head label range.")
end
end)

0 comments on commit e7c46a6

Please sign in to comment.