I don’t know what is wrong with my script, i want to activate and deactivate god mode by typing /god
function notify(msg)
SetNotificationTextEntry("STRING")
AddTextComponentString(msg)
DrawNotification(true,false)
end
GodAtivado = false
RegisterCommand('god', function(source, args)
Jogador = GetPlayerPed(-1)
GodAtivado = not GodAtivado
if GodAtivado then
SetPlayerInvincible(Jogador, true)
notify("GodMode ~g~Ativado")
elseif not GodAtivado then
SetPlayerInvincible(Jogador, false)
notify("GodMode ~r~Desativado")
end
end)
To do this in one command you need a server-side script, at the moment i dont know how to do it, but i can help with two commands.
RegisterCommand("godmodeon", function(sender, item, index)
SetEntityInvincible(PlayerPedId(), true)
end)
RegisterCommand("godmodeoff", function(sender, item, index)
SetEntityInvincible(PlayerPedId(), false)
end)
I want to activate and deactivate in one command
function notify(msg)
SetNotificationTextEntry("STRING")
AddTextComponentString(msg)
DrawNotification(true,false)
end
RegisterCommand('god', function(source, args)
Jogador = GetPlayerPed(-1)
GodAtivado = GetPlayerInvincible(Jogador)
if GodAtivado then
SetPlayerInvincible(Jogador, false)
notify("GodMode ~r~Desativado")
elseif not GodAtivado then
SetPlayerInvincible(Jogador, true)
notify("GodMode ~g~Ativado")
end
I think this could be what you want to do
you could also try IsPlayerInvincible(Player player)
2 Likes
First, i say you need a server-side script, which at the moment i dont know how to do.
Second, Read what i write
Third, say thanks and explain what is wrong with my reply but dont write"I WANT" i understand what you want.
Be more kind with the people who help you
English is not my first language, i just want help, sorry for that
This one doesn’t work, it always say God Mode Activated when i type /god, and the god mode is not working
English is not my first language, I’m italian LOL, dont worry, i have the solution for you, just wait a moment
Have you tried IsPlayerInvincible instead of GetPlayerInvincible as i mentioned?
I’m sending you the working code, just a few seconds
Never seen this native before, how does it works ?
RegisterCommand('god', function(source, args)
god = not god
if god then
SetEntityInvincible(GetPlayerPed(-1), true)
notify("~g~God Mode On")
else
SetEntityInvincible(GetPlayerPed(-1), false)
notify("~r~God Mode Off")
end
end)
That is a working script on my end.
2 Likes
The message works, but it doesn’t give me the god mode
2 Likes
That’s weird, I tested it on my end and all was good. I even got hit by a car on the highway and had no damage taken.
My bad, what i was doing is that i was changing the script and using Lambda’s noclip to go up and take fall damage, but when i deactivate the noclip it removes the godmode.
Thanks to all that spent time to help me 
1 Like
Awesome! Glad it was of help 
Is this for server.lua or client.lua?
Where would you paste this code to?