Enabling Buddha mode through lua scripts

Quick question, is there a way I can enable buddha mode through the lua itself? I know you can do “ply:ConCommand(“buddha”)” but that makes the player enter the command into the console, I want to just enable it directly like “ply:GodEnable()” for instance.

Please elaborate what “Buddha mode” means.

Oh, right. Well, it’s a console command that prevents you from dying and keeps your health at 1. It works for most source games.

IIRC it does not exist on Garry’s Mod, but please correct me someone if I am wrong.

[lua]
local Player = FindMetaTable( “Player” )
if ( not Player ) then return end

AccessorFunc( Player, “bIsBuddha”, “Buddha”, FORCE_BOOL )

hook.Add( “EntityTakeDamage” , “Buddha Mode”, function( target, dmg )

if ( target:IsPlayer() and target:GetBuddha() ) then
	if ( dmg:GetDamage() >= target:Health() ) then
	
		dmg:SetDamage( 0 )
		target:SetHealth( 1 )
	
	end
end

end)
[/lua]

Not tested, but you get the jist. If a player is hurt with budha mode enabled, the player only takes damage until 1 HP.