Liberty Unleashed
Scripting => Script Help => Topic started by: Maximom on May 18, 2013, 08:02:45 am
-
hi, how i can get a godmode script for the server on a lan ???
-
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;
}
-
Nice bump...
This is a good example for god mode...
// The following events protect the player from getting hurt while they are in free view mode.
function onClientShot( attacker, weapon, bodypart )
{
if ( pCamera.IsEnabled() ) return 0;
return 1;
}
function onClientHurt( entity )
{
if ( pCamera.IsEnabled() ) return 0;
return 1;
}
-
pls
god_mode <- false;
function onClientHurt(entity) { if (god_mode) { return 0; } }
function onClientShot(attacker, weapon, part) { if (god_mode) { return 0; } }
function onClientCommand(command, text) { if (command == "god") { if (god_mode) { god_mode = false; }else{ god_mode = true; } } }
-
xdddd
edit: best example is from benedani,cuz uses admin
-
This is an alternative to Ankris's snippet.
vulnerable <- true;
function onClientHurt(entity) { return vulnerable; }
function onClientShot(attacker, weapon, part) { return vulnerable; }
function onClientCommand(command, text) { if(command == "god") { vulnerable = !vulnerable; } }
-
The "var = !var" switch is very handy