Created
November 21, 2022 09:25
-
-
Save samisalreadytaken/22d8c16bdb0dc2a6674d1c90733511b3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// flashlight | |
// sethealth <amount> [time] | |
// setarmor <amount> | |
// setfov <fov> [rate] | |
// givehealth <amount> | |
// givearmor <amount> | |
// givesuit | |
// giveall | |
// | |
if ( SERVER_DLL ) | |
{ | |
Convars.RegisterCommand( "flashlight", function(...) | |
{ | |
local player = Convars.GetCommandClient(); | |
if ( player.IsEffectActive( EF_DIMLIGHT ) ) | |
{ | |
player.RemoveEffects( EF_DIMLIGHT ); | |
player.EmitSound( "HL2Player.FlashLightOff" ); | |
} | |
else | |
{ | |
player.AddEffects( EF_DIMLIGHT ); | |
player.EmitSound( "HL2Player.FlashLightOn" ); | |
} | |
}, "", FCVAR_GAMEDLL ); | |
Convars.RegisterCommand( "sethealth", function(...) | |
{ | |
local player = Convars.GetCommandClient(); | |
local value = vargv[1].tointeger(); | |
if ( player.GetHealth() == value ) | |
return; | |
if ( 2 in vargv ) | |
{ | |
// total time | |
if ( vargv[2].tofloat() > 0.01 ) | |
{ | |
local time = 1.0 / vargv[2].tofloat(); | |
local startTime = Time(); | |
local prevHealth = player.GetHealth(); | |
player.SetContextThink( "cc_sethealth", function( player ) | |
{ | |
local t = (Time() - startTime) * time; | |
local v = RemapValClamped( t, 0.0, 1.0, prevHealth, value ); | |
player.SetHealth( v ); | |
if ( v == value ) | |
return -1 | |
return 0.0; | |
}, 0.1 ); | |
} | |
} | |
else if ( 1 in vargv ) | |
{ | |
player.SetHealth( vargv[1].tointeger() ); | |
} | |
}, "", FCVAR_GAMEDLL | FCVAR_CHEAT ); | |
Convars.RegisterCommand( "setarmor", function(...) | |
{ | |
local player = Convars.GetCommandClient(); | |
if ( 1 in vargv ) | |
{ | |
player.SetArmor( vargv[1].tointeger() ); | |
} | |
}, "", FCVAR_GAMEDLL | FCVAR_CHEAT ); | |
Convars.RegisterCommand( "setfov", function(...) | |
{ | |
local player = Convars.GetCommandClient(); | |
if ( player.GetFOVOwner() ) | |
return; | |
if ( 2 in vargv ) | |
{ | |
player.SetFOV( vargv[1].tointeger(), vargv[2].tofloat() ); | |
} | |
else if ( 1 in vargv ) | |
{ | |
player.SetFOV( vargv[1].tointeger(), 0.0 ); | |
} | |
else | |
{ | |
player.SetFOV( 0, 0.0 ); | |
} | |
}, "", FCVAR_GAMEDLL | FCVAR_CHEAT ); | |
Convars.RegisterCommand( "givearmor", function(...) | |
{ | |
local player = Convars.GetCommandClient(); | |
local amt = 1; | |
if ( 1 in vargv ) | |
amt = vargv[1].tointeger(); | |
player.SetArmor( player.GetArmor() + amt ); | |
}, "", FCVAR_GAMEDLL | FCVAR_CHEAT ); | |
Convars.RegisterCommand( "givehealth", function(...) | |
{ | |
local player = Convars.GetCommandClient(); | |
local amt = 1; | |
if ( 1 in vargv ) | |
amt = vargv[1].tointeger(); | |
player.SetHealth( player.GetHealth() + amt ); | |
}, "", FCVAR_GAMEDLL | FCVAR_CHEAT ); | |
Convars.RegisterCommand( "givesuit", function(...) | |
{ | |
local player = Convars.GetCommandClient(); | |
SendToConsole("give item_suit"); | |
}, "", FCVAR_GAMEDLL | FCVAR_CHEAT ); | |
Convars.RegisterCommand( "giveall", function(...) | |
{ | |
local player = Convars.GetCommandClient(); | |
SendToConsole("impulse 101"); | |
SpawnEntityFromTable("weapon_slam", { origin = player.GetOrigin() }); | |
}, "", FCVAR_GAMEDLL | FCVAR_CHEAT ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment