Creating a hook or something similar

Is there a way to create a hook so that when a custom event in lua happens? For example, when a button is pressed, could you create a hook as soon as it’s pressed? Not sure if that’s a good way to word it, but here’s where I want to create it or do something similar:

[lua]
concommand.Add( “scoin_buy”, function( ply, cmd, args )
local item = args[1]
if !item then return end
for k, v in ipairs( SCoins.Items ) do
if v[4] == item then
if ply:GetPoints() < v[5] then
ply:ChatMessage( “You don’t have enough coins for the “” … v[1] … “” item!” )
return
end
if ply:HasItem( v[4] ) then
ply:ChatMessage( “You already have the “” … v[1] … “” item!” )
return
end
ply:TakePoints( v[5] )
ply:GiveItem( v[4] )
ply:ChatMessage( “You have bought the “” … v[1] … “” item for " … v[5] … " coins!” )
–Right here
return
end
end
end )
[/lua]

Yes, it’s based on PointMod

You mean calling a function when something is done?

Like this…

[lua]
function CallMe()
– Put your function contents in here
end

function SomeOtherFunction()
print(“When the function SomeOtherFunction is called, I will call CallMe”);

CallMe()
end
[/lua]

You be raping mah mod :gonk:

[editline]04:29AM[/editline]

Have a look at this:
http://seth.im/files/pointmod_v1.01b.zip
(In the exact place you described)

Thanks Guru, no I’m not raping it, I’m making it beautiful and renaming it.

Wow, I thought of hook.Call, I wasn’t sure what to put in the table though, that’s sweet.