Schokokex / addon_template_butt

A template for Dota But Mods. Initiated by Baumis Twitch/Youtube channel and the community.
https://www.twitch.tv/l34um1
22 stars 13 forks source link

script_reload friendly ListenToGameEvent() #39

Open Schokokex opened 4 years ago

Schokokex commented 4 years ago
function _G.DynamicListenToGameEvent("event_name",functionname, context)
or
function _G.DynamicListenToGameEvent("event_name", function() end)
Schokokex commented 4 years ago

should remove old listeners

Schokokex commented 4 years ago

if Listeners then
 StopAllListeners(Listeners)
else Listeners = {} end

function _G.DynamicListenToGameEvent(event_name, func)
 table.add Listener ListenToGameEvent(eventname, func, Listeners
end