Skip to content

Commit d13daac

Browse files
committed
fix(events): Items Mixup
1 parent 200ab9c commit d13daac

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/plugins/Plugin.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,8 @@ EValue SerializeData(std::any data, EContext* state)
454454
return EValue(state, std::any_cast<QAngle>(value));
455455
else if (value.type() == typeid(std::nullptr_t))
456456
return EValue(state, nullptr);
457+
else if (value.type() == typeid(PluginEvent))
458+
return EValue(state, std::any_cast<PluginEvent>(value));
457459
else if (value.type() == typeid(std::vector<std::string>))
458460
{
459461
if (state->GetKind() == ContextKinds::Lua) {

src/plugins/loader/scripting/engine/events.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,20 @@ void RemoveEventHandlerPlugin(std::string eventName, EContext* L)
3030
plugin->UnregisterEventHandling(eventName);
3131
}
3232

33-
std::vector<EValue> TriggerEventInternal(std::string eventName, EValue eventPayload, EContext* L)
33+
std::vector<std::any> TriggerEventInternal(std::string eventName, EValue eventPayload, EContext* L)
3434
{
35-
std::vector<EValue> returnValues;
35+
std::vector<std::any> returnValues;
3636

3737
PluginEvent event(FetchPluginName(L), nullptr, nullptr);
3838

3939
std::string payload = "";
4040
size_t len;
4141

42-
if(L->GetKind() == ContextKinds::JavaScript) payload = (const char*)JS_GetUint8Array((JSContext*)L->GetState(), &len, eventPayload.pushJS());
42+
if (L->GetKind() == ContextKinds::JavaScript) payload = (const char*)JS_GetUint8Array((JSContext*)L->GetState(), &len, eventPayload.pushJS());
4343
else payload = eventPayload.cast<std::string>();
4444

45-
returnValues.push_back(EValue(L, (int)g_pluginManager->ExecuteEvent(FetchPluginName(L), eventName, eventPayload, &event)));
46-
returnValues.push_back(EValue(L, event));
45+
returnValues.push_back((int)g_pluginManager->ExecuteEvent(FetchPluginName(L), eventName, eventPayload, &event));
46+
returnValues.push_back(event);
4747

4848
return returnValues;
4949
}
@@ -101,7 +101,7 @@ void LoadEvent(Plugin* plugin, EContext* state)
101101
.addFunction("SetNoBroadcast", &PluginEvent::SetNoBroadcast)
102102
.addFunction("GetNoBroadcast", &PluginEvent::GetNoBroadcast)
103103

104-
.endClass();
104+
.endClass();
105105
}
106106

107107
LoadScriptingComponent(

0 commit comments

Comments
 (0)