See how a function is triggered (arguments + return value). Use like: printhook(PLAYER, 'get_total_armor_value')
CODE: function printhook(owner, funcName, funcCondition) local old = owner[funcName] if type(old) ~= 'function' then print('Tried to hook non-function: {*2' .. funcName .. '}') return end
funcCondition = funcCondition or function(...) return true end owner[funcName] = function(...) local result = old(...) if funcCondition(...) then local args = {...} for k,v in ipairs(args) do args[k] = tostring(v) end print('{*1' .. funcName .. '}({*2' .. table.concat(args, ', ') .. '}) => {*3' .. tostring(result) .. '}') end return result end end
4 comments
Use like:
printhook(PLAYER, 'get_total_armor_value')
CODE:
function printhook(owner, funcName, funcCondition)
local old = owner[funcName]
if type(old) ~= 'function' then
print('Tried to hook non-function: {*2' .. funcName .. '}')
return
end
funcCondition = funcCondition or function(...) return true end
owner[funcName] = function(...)
local result = old(...)
if funcCondition(...) then
local args = {...}
for k,v in ipairs(args) do
args[k] = tostring(v)
end
print('{*1' .. funcName .. '}({*2' .. table.concat(args, ', ') .. '}) => {*3' .. tostring(result) .. '}')
end
return result
end
end
lua player_inventory_manager.set_inventory_limit(1000)