How to use 'hookfunction'

Опубликовано: 12 Март 2026
на канале: TechHog
21,884
403

This is a video that explains how to use hookfunction.

One thing I forgot about in the video is how to use the old function to implement a toggle. Here is what I mean:
Let's say that I want to have a toggle for the infinite ammo. Whenever this toggle is off, I want the function to return the original value. Whenever this toggle is on, I want the function to return my custom value. Here is how we can do this:
local oldgetammo; oldgetammo = hookfunction(getammo, function(...)
if infammo then
return 100;
else
return oldgetammo(...);
end;
end);