Make a client script.
In it:
local godmode = false;
function onClientRender() {
local plr = FindLocalPlayer();
if (godmode)
{
plr.Health = 100;
plr.Armour = 100;
}
}
function onClientCommand ( szCommand, szParams )
{
if (szCommand == "godmode")
{
if (godmode) {
godmode = false;
Message("Godmode turned off");
}
else {
godmode = true;
Message("Godmode turned on");
}
}
return 1;
}
Note: this will glitch it when your car explodes while you're inside it. It will register the death twice, instead of not dying. This is only good for water accidents, pvp matches, etc
If you want to make it admin only, then here's the script for that:
local godmode = false;
local isadmin = false;
function onClientRender() {
local plr = FindLocalPlayer();
if (godmode)
{
plr.Health = 100;
plr.Armour = 100;
}
}
function onClientSpawn( pClass )
{
local player = FindLocalPlayer();
if (player.Name == "yournamehere")
{
IsAdmin = true;
}
}
function onClientCommand ( szCommand, szParams )
{
if (szCommand == "godmode")
{
if (IsAdmin)
{
if (godmode) {
godmode = false;
Message("Godmode turned off");
}
else {
godmode = true;
Message("Godmode turned on");
}
}
}
return 1;
}