if( GetConVar( "sv_allowcslua" ):GetFlags() != 8452 || GetConVar( "sv_allowcslua" ):GetFlags() == 0 ) then
//The original function, it prints whatever argument is given to it
function PrintSomething(what)
MsgN(what)
end
//Detouring the function
local PS = PrintSomething //Save a copy of the original (not always necessary)
function PrintSomething(what) //Because it has the same name this overwrites the other function (its also smart the use the same arguments)
PS("I was suppose to print "..what.." but im detoured!") //Calling the original function but with an altered message
end
//The original function Player:Deaths() returns how many deaths a player has
local Player = FindMetaTable("Player") //Getting a copy of the player meta table
local deaths = Player.Deaths //Saving a copy of the original function (Same as Player["Deaths"])
function Player:Deaths() //Re-creating the function, this is the detour
local num = deaths(self) //Calling the original function to find what it would normally return
MsgN("Players deaths: "..num) //Printing it
return num //Returning what the original function would've returned,
end