mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-06-17 22:23:03 +00:00
Fix issue with not cancelling events on linux (fix #29)
This commit is contained in:
+2
-5
@@ -74,15 +74,13 @@ std::any FutureWait(TLuaFile* lua, const std::string& R, std::shared_ptr<TLuaArg
|
|||||||
|
|
||||||
std::any TriggerLuaEvent(const std::string& Event, bool local, TLuaFile* Caller, std::shared_ptr<TLuaArg> arg, bool Wait) {
|
std::any TriggerLuaEvent(const std::string& Event, bool local, TLuaFile* Caller, std::shared_ptr<TLuaArg> arg, bool Wait) {
|
||||||
std::any R;
|
std::any R;
|
||||||
std::string Type;
|
|
||||||
int Ret = 0;
|
int Ret = 0;
|
||||||
for (auto& Script : Engine().LuaFiles()) {
|
for (auto& Script : Engine().LuaFiles()) {
|
||||||
if (Script->IsRegistered(Event)) {
|
if (Script->IsRegistered(Event)) {
|
||||||
if (local) {
|
if (local) {
|
||||||
if (Script->GetPluginName() == Caller->GetPluginName()) {
|
if (Script->GetPluginName() == Caller->GetPluginName()) {
|
||||||
R = FutureWait(Script.get(), Script->GetRegistered(Event), arg, Wait);
|
R = FutureWait(Script.get(), Script->GetRegistered(Event), arg, Wait);
|
||||||
Type = R.type().name();
|
if (R.type() == typeid(int)) {
|
||||||
if (Type.find("int") != std::string::npos) {
|
|
||||||
if (std::any_cast<int>(R))
|
if (std::any_cast<int>(R))
|
||||||
Ret++;
|
Ret++;
|
||||||
} else if (Event == "onPlayerAuth")
|
} else if (Event == "onPlayerAuth")
|
||||||
@@ -90,8 +88,7 @@ std::any TriggerLuaEvent(const std::string& Event, bool local, TLuaFile* Caller,
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
R = FutureWait(Script.get(), Script->GetRegistered(Event), arg, Wait);
|
R = FutureWait(Script.get(), Script->GetRegistered(Event), arg, Wait);
|
||||||
Type = R.type().name();
|
if (R.type() == typeid(int)) {
|
||||||
if (Type.find("int") != std::string::npos) {
|
|
||||||
if (std::any_cast<int>(R))
|
if (std::any_cast<int>(R))
|
||||||
Ret++;
|
Ret++;
|
||||||
} else if (Event == "onPlayerAuth")
|
} else if (Event == "onPlayerAuth")
|
||||||
|
|||||||
+2
-3
@@ -327,11 +327,10 @@ void TNetwork::Authentication(SOCKET TCPSock) {
|
|||||||
|
|
||||||
auto arg = std::make_unique<TLuaArg>(TLuaArg { { Client->GetName(), Client->GetRoles(), Client->IsGuest() } });
|
auto arg = std::make_unique<TLuaArg>(TLuaArg { { Client->GetName(), Client->GetRoles(), Client->IsGuest() } });
|
||||||
std::any Res = TriggerLuaEvent("onPlayerAuth", false, nullptr, std::move(arg), true);
|
std::any Res = TriggerLuaEvent("onPlayerAuth", false, nullptr, std::move(arg), true);
|
||||||
std::string Type = Res.type().name();
|
if (Res.type() == typeid(int) && std::any_cast<int>(Res)) {
|
||||||
if (Type.find("int") != std::string::npos && std::any_cast<int>(Res)) {
|
|
||||||
ClientKick(*Client, "you are not allowed on the server!");
|
ClientKick(*Client, "you are not allowed on the server!");
|
||||||
return;
|
return;
|
||||||
} else if (Type.find("string") != std::string::npos) {
|
} else if (Res.type() == typeid(std::string)) {
|
||||||
ClientKick(*Client, std::any_cast<std::string>(Res));
|
ClientKick(*Client, std::any_cast<std::string>(Res));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user