Skip to content
This repository has been archived by the owner on Nov 19, 2022. It is now read-only.

Commit

Permalink
Add new toggle event mechanism.
Browse files Browse the repository at this point in the history
  • Loading branch information
drakeee committed Jun 11, 2022
1 parent 5ac9e0b commit 4665a49
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/EventManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ bool ResourceEventManager::SubscribeLocalEvent(std::string& eventName, int funct
eventType = alt::CEvent::Type::CLIENT_SCRIPT_EVENT;
#endif

if (!Core->IsEventEnabled(eventType))
Core->ToggleEvent(eventType, true);

DEBUG_INFO("SubscribeLocalEvent: " + std::to_string((int)eventType) + " - " + eventName);

this->resourceEvents[eventType][eventName].push_back(functionReference);
Expand Down Expand Up @@ -222,6 +225,10 @@ bool ResourceEventManager::UnsubscribeEvent(const std::string& eventName, int fu
return false;

references.erase(it);

if (Core->IsEventEnabled(eventType) && (references.size() == 0))
Core->ToggleEvent(eventType, false);

return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/LuaScriptRuntime.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class LuaScriptRuntime : public alt::IScriptRuntime
~LuaScriptRuntime() { };

char* _ALT_SDK_VERSION = (char*)ALT_SDK_VERSION; //disable annoying warnings in Linux build
const semver::version version{ 1, 2, 8, _ALT_SDK_VERSION, semver::branch::dev };
const semver::version version{ 1, 2, 9, _ALT_SDK_VERSION, semver::branch::dev };

#ifdef ALT_SERVER_API
alt::config::Node::Dict serverConfigDict;
Expand Down

0 comments on commit 4665a49

Please sign in to comment.