[Release] no-god-mode

What is this?

This is a resource that prevents users from being able to run around, shoot, drive, whatever whilst they are in god mode.

An example of where this might be useful

You’re on a deathmatch server and, for some reason, scripthook is enabled and a user comes on the server, enables god mode, and starts ruining the deathmatch and they’re at an unfair advantage. This script will freeze the player and the vehicle (if they are in one), and prevent them from shooting.


Is this the most amazing script to ever be released to this forum? No, not by far. This is a simple script that didn't take me long at all to create, I thought I would upload it to the forum and let people use it as a contribution to the community. I thought something like this had already been created, that's why I didn't initially upload it when I started working on it. Anyway, I hope you enjoy this script and I hope it can prove to be effective in your servers.

Thanks,
Zeemah.

If you encounter any bugs (which there shouldn’t be) please report them by either making an ‘Issue’ on the GitHub repository or on this topic. Thanks :mascot:!

Download


or:

v1.0.2 (Latest)

no-god-mode.rar (1.4 KB)

v1.0.1

no-god-mode.rar (724 Bytes)

v1.0.0 (Initial Commit to GitHub)

no-god-mode.rar (702 Bytes)


Credits

HavocDocumentation on labels which have been used in this script.

4 Likes

Useful.

2 Likes

Simple and nice. :slight_smile: Gj.

So, this detects people that uses godmode and does freeze them?
well done.

Maybe a kick function after a certain time, like 2 minutes or something would be also a good feature :slight_smile: (For people that does not want to read because of whatever)

AAND maybe a bann feature too, but I think this would be too much.

This helps a lot :slight_smile:

If invincibility is detected on a player, it will freeze them, freeze the vehicle they are driving if they are in one and it will disable player firing – so they won’t be able to shoot.

Kinda want to keep this simplistic, but, if people want this feature then I will add it.

Would rely on some other script unless the ban would be temporary and it would include storing the identifiers somewhere. I don’t really want this to have dependencies.

the storing could get saved into a log.txt file, no dependency needed thatfor.

And I like it as simple as it is, so keep up the work :slight_smile:

If you’re interested into writing a log.txt file look at this:

function textWrite(text)
    log = io.open("resources/"..GetCurrentResourceName().."/log.txt", "a")
    if log then
        log:write(text)
    else
        print("Log file doesnt exist")
    end
    log:close()
end

not sure how to read it but I think it should be able to read with the default
read
function from Lua…

Good work again :hamburger:

@Real-hamburger you could probably do:

Citizen.CreateThread(function()
    while true do
        
        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(ped, true)
            DisablePlayerFiring(player, true)
            if IsPedInAnyVehicle(ped, false) then
                FreezeEntityPosition(GetVehiclePedIsIn(ped, false), true)
				Citizen.Wait(60000) -- wait 1 minute
				DropPlayer(source, "Godmode isn't allowed on this server!") -- Drop the player after 1 minute
            end
        else
            FreezeEntityPosition(ped, false)
            if IsPedInAnyVehicle(ped, false) then
                FreezeEntityPosition(GetVehiclePedIsIn(ped, false), false)
            end 
        end
        
        Citizen.Wait(0)
    end
end)

but not sure if that would work or not.

This is a server native, this doesn’t exist on the client.

shit, totally forgot about that one! let me whip up a client one give me a minute.

Also, waiting a minute there would prevent the script from continuing if the player is in a vehicle, it would make the script useless at that point.

ah so then i could just make another thing since your using local isInvincible = false at the top

and checking the invincibility on another line

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

so i could probably use a server and client.

to check with that native.

actually let me just edit it so you can set it if you want to kick the player. and then maybe an option for the wait timer. that is possible isn’t it?

… or just trigger a server event on a client that has been invincible for too long – this event will drop the player.

oh yeah good point :wink:

Does this include any support for ace perms to bypass for admins etc? If not, I’d suggest adding it! Looks nice, good work. :slight_smile:

Nice release! Great job :+1:

this solution is cuter for any case where you like to have menus :stuck_out_tongue:

1 Like

Not right now, could be implemented however.

Thank you :mascot:

Nice!

I’m also aware that some menus don’t actually use SET_PLAYER_INVINCIBLE or so, but just constantly set the player’s health to 200 or whatever. I’ll work on an update that will check it menus are doing this.

Update!

v1.0.2

Changes

+ Added the ability to check for staff - this is done via ace permissions. Just set `ace_perm` to whatever ace you want. Add the ace via `add_ace <identifier> <ace here> allow`. 
+ There is a check that occurs every minute, it checks whether players have the ace specified, if they do, it will trigger a client event and toggle a bool which will allow them to be invincible.

Download

Bugs/Issues

Report them on this topic or make an ‘Issue’ on the GitHub repository.

1 Like

if you want everyone no godmode just use this

Citizen.CreateThread(function()
    while true do
		Citizen.Wait(0)
		SetEntityInvincible(GetPlayerPed(-1), false)
	end
end)

:drooling_face:

1 Like