Skip to content

Commit

Permalink
v.1.0.2: Add the ability to configure admins and disable the check fo…
Browse files Browse the repository at this point in the history
…r them
  • Loading branch information
lze3 committed Mar 17, 2019
1 parent 4a4722d commit 23a5958
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
10 changes: 8 additions & 2 deletions no-god-mode/client.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local isInvincible = false
local isAdmin = false

Citizen.CreateThread(function()
while true do
Expand All @@ -13,7 +14,7 @@ Citizen.CreateThread(function()

local ped = PlayerPedId()
local player = PlayerId()
if isInvincible then
if isInvincible and not isAdmin then
DrawLabel("~r~You are currently in godmode which is ~h~prohibited~h~ on this server, disable it now.")
FreezeEntityPosition(ped, true)
DisablePlayerFiring(player, true) -- true/false - doesn't seem to do anything different, still disables every frame
Expand All @@ -35,4 +36,9 @@ function DrawLabel(text)
BeginTextCommandDisplayHelp("STRING")
AddTextComponentSubstringPlayerName(text)
EndTextCommandDisplayHelp(0, 0, 1, -1)
end
end

RegisterNetEvent("sendAcePermissionToClient")
AddEventHandler("sendAcePermissionToClient", function(state)
isAdmin = state
end)
29 changes: 29 additions & 0 deletions no-god-mode/server.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
local ace_perm = "admin"
local debug = false

function ProcessAces()
if GetNumPlayerIndices() > 0 then -- don't do it when there aren't any players
for i=0, GetNumPlayerIndices()-1 do -- loop through all players
player = tonumber(GetPlayerFromIndex(i))
Citizen.Wait(0)
if IsPlayerAceAllowed(player, ace_perm) then
TriggerClientEvent("sendAcePermissionToClient", player, true)
if debug then print("[DEBUG][" .. GetCurrentResourceName() .. "] ^5Syncronising player aces, sending to client...^0") end
end
end
end
end

Citizen.CreateThread(function()
while true do
ProcessAces()
Citizen.Wait(60000) -- lets check every minute
end
end)

AddEventHandler("onResourceStart", function(name)
if name == GetCurrentResourceName() then
ProcessAces()
if debug then print("[DEBUG][" .. GetCurrentResourceName() .. "] ^6Resource [ " .. GetCurrentResourceName() .. " ] was (re)started, syncing aces to all players.^0") end
end
end)

0 comments on commit 23a5958

Please sign in to comment.