Override default functions then call them.

How can I override AddFrags and then call the original function without a stack overflow?

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

function meta:AddFrags( count )
self:AddExperience( count * 40 )
self:oldFrags( count )
end
[/lua]

At the moment it just crashes the game, as I am assuming that its in an infinite loop of calling itself. How can I avoid this?

[editline]27th September 2013[/editline]

Fixed it.

[lua]
local meta = FindMetaTable(“Player”)
if not meta then return end
meta.oldFrags = meta.oldFrags or meta.AddFrags

function meta:AddFrags( count )
self:AddExperience( count * 40 )
self:oldFrags( count )
end
[/lua]