add identifiers (beammp id, ip) as an argument to onPlayerAuth

This commit is contained in:
Lion Kortlepel
2022-10-03 15:31:32 +02:00
parent cb0cb30797
commit 5d3dff3c88
4 changed files with 14 additions and 2 deletions

View File

@@ -4,6 +4,7 @@
#include "Http.h"
#include "LuaAPI.h"
#include "TLuaPlugin.h"
#include "sol/object.hpp"
#include <chrono>
#include <condition_variable>
@@ -992,6 +993,15 @@ void TLuaEngine::StateThreadData::operator()() {
case TLuaArgTypes_Bool:
LuaArgs.push_back(sol::make_object(StateView, std::get<bool>(Arg)));
break;
case TLuaArgTypes_StringStringMap: {
auto Map = std::get<std::unordered_map<std::string, std::string>>(Arg);
auto Table = StateView.create_table();
for (const auto& [k, v] : Map) {
Table[k] = v;
}
LuaArgs.push_back(sol::make_object(StateView, Table));
break;
}
default:
beammp_error("Unknown argument type, passed as nil");
break;

View File

@@ -355,7 +355,7 @@ void TNetwork::Authentication(const TConnection& ClientConnection) {
return true;
});
auto Futures = LuaAPI::MP::Engine->TriggerEvent("onPlayerAuth", "", Client->GetName(), Client->GetRoles(), Client->IsGuest());
auto Futures = LuaAPI::MP::Engine->TriggerEvent("onPlayerAuth", "", Client->GetName(), Client->GetRoles(), Client->IsGuest(), Client->GetIdentifiers());
TLuaEngine::WaitForAll(Futures);
bool NotAllowed = std::any_of(Futures.begin(), Futures.end(),
[](const std::shared_ptr<TLuaResult>& Result) {