Skip to content

Commit

Permalink
Check every 500 ticks for god mode -- more optimised. Clean up code. …
Browse files Browse the repository at this point in the history
…Rename vars.
  • Loading branch information
lze3 committed Mar 16, 2019
1 parent 4b88e57 commit 21020cb
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions no-god-mode/client.lua
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
local isInvincible = false

Citizen.CreateThread(function()
while true do
isInvincible = GetPlayerInvincible(PlayerId())
Citizen.Wait(500)
end
end)

Citizen.CreateThread(function()
while true do

local player_l = PlayerPedId()
local ped_l = PlayerId()
if GetPlayerInvincible(ped_l) then
local ped = PlayerPedId()
local player = PlayerId()
if isInvincible then
DrawLabel("~r~You are currently in godmode which is ~h~prohibited~h~ on this server, disable it now.")
FreezeEntityPosition(player_l, true)
DisablePlayerFiring(ped_l, true)
if IsPedInAnyVehicle(player_l, false) then
FreezeEntityPosition(GetVehiclePedIsIn(player_l, false), true)
FreezeEntityPosition(ped, true)
DisablePlayerFiring(player, true)
if IsPedInAnyVehicle(ped, false) then
FreezeEntityPosition(GetVehiclePedIsIn(ped, false), true)
end
else
FreezeEntityPosition(player_l, false)
DisablePlayerFiring(ped_l, false)
if IsPedInAnyVehicle(player_l, false) then
FreezeEntityPosition(GetVehiclePedIsIn(player_l, false), true)
FreezeEntityPosition(ped, false)
if IsPedInAnyVehicle(ped, false) then
FreezeEntityPosition(GetVehiclePedIsIn(ped, false), false)
end
end

Citizen.Wait(0)
end


end)

function DrawLabel(text)
Expand Down

0 comments on commit 21020cb

Please sign in to comment.