how to use hook.Remove to remove a random name hook?
6 replies, posted
hook.Add ("Think",math.random(1,999999),somefunction)
the hook name is random so how to remove it?
why make the name random. that is exacly what you use to remove the hook. if your name is random, you fucked up
You could store it in a variable and use that as the idenfitifer, thn use the same variable inside hook.Remove
To remove a hook you dont want. Just make sure you get the identifier of the hook.
For example the Advert Spam Hooks from some workshop Users.
If you have console rights you could do:
PrintTable( hook.GetTable() )
do get all the hooks and their identifiers. If you found a suspiscout not want hook just do
hook.Remove( string eventName, any identifier )
for exampke
hook.Remove("PlayerSpawn","Killplyatspawn")
You need to keep track of your identifier.
local hookID = math.random(1, 999999)
hook.Add("Think", hookID, function() end)
... -- Some code
hook.Remove("Think", hookID)
Assuming you actually intend to use something like the code in this thread, know that you can't use numbers as hook ids. If the id isn't a string IsValid will be used on it, which will error when called.
Nothing you stopping from just using tostring on it first.
Sorry, you need to Log In to post a reply to this thread.