mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2025-07-02 07:45:26 +00:00
Fix postPlayerAuth and add reason value
This commit is contained in:
parent
6c9d58582b
commit
1c07cf83b2
@ -430,32 +430,24 @@ std::shared_ptr<TClient> TNetwork::Authentication(TConnection&& RawConnection) {
|
|||||||
Reason = "No guests are allowed on this server! To join, sign up at: forum.beammp.com.";
|
Reason = "No guests are allowed on this server! To join, sign up at: forum.beammp.com.";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Allowed = true;
|
if (!NotAllowed && !NotAllowedWithReason) {
|
||||||
if (NotAllowed) {
|
if (mServer.ClientCount() < size_t(Application::Settings.getAsInt(Settings::Key::General_MaxPlayers)) || BypassLimit) {
|
||||||
Allowed = false;
|
beammp_info("Identification success");
|
||||||
|
mServer.InsertClient(Client);
|
||||||
|
TCPClient(Client);
|
||||||
|
} else {
|
||||||
|
NotAllowedWithReason = true;
|
||||||
|
Reason = "Server full!";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NotAllowedWithReason) {
|
if (NotAllowedWithReason) {
|
||||||
Allowed = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NotAllowed) {
|
|
||||||
ClientKick(*Client, "you are not allowed on the server!");
|
|
||||||
} else if (NotAllowedWithReason) {
|
|
||||||
ClientKick(*Client, Reason);
|
ClientKick(*Client, Reason);
|
||||||
|
} else if (NotAllowed) {
|
||||||
|
ClientKick(*Client, "you are not allowed on the server!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto PostFutures = LuaAPI::MP::Engine->TriggerEvent("postPlayerAuth", "", NotAllowed || NotAllowedWithReason, Reason, Client->GetName(), Client->GetRoles(), Client->IsGuest(), Client->GetIdentifiers());
|
||||||
if (!Allowed) {
|
|
||||||
return {};
|
|
||||||
} else if (mServer.ClientCount() < size_t(Application::Settings.getAsInt(Settings::Key::General_MaxPlayers)) || BypassLimit) {
|
|
||||||
beammp_info("Identification success");
|
|
||||||
mServer.InsertClient(Client);
|
|
||||||
TCPClient(Client);
|
|
||||||
} else {
|
|
||||||
ClientKick(*Client, "Server full!");
|
|
||||||
}
|
|
||||||
|
|
||||||
auto PostFutures = LuaAPI::MP::Engine->TriggerEvent("postPlayerAuth", "", Allowed, Client->GetName(), Client->GetRoles(), Client->IsGuest(), Client->GetIdentifiers());
|
|
||||||
// the post event is not cancellable so we dont wait for it
|
// the post event is not cancellable so we dont wait for it
|
||||||
LuaAPI::MP::Engine->ReportErrors(PostFutures);
|
LuaAPI::MP::Engine->ReportErrors(PostFutures);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user