aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/bansystem.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'NorthstarDedicatedTest/bansystem.cpp')
-rw-r--r--NorthstarDedicatedTest/bansystem.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/NorthstarDedicatedTest/bansystem.cpp b/NorthstarDedicatedTest/bansystem.cpp
index 16c25b6b..40813f17 100644
--- a/NorthstarDedicatedTest/bansystem.cpp
+++ b/NorthstarDedicatedTest/bansystem.cpp
@@ -3,6 +3,7 @@
#include "bansystem.h"
#include "serverauthentication.h"
#include "concommand.h"
+#include "miscserverscript.h"
#include <filesystem>
const char* BANLIST_PATH = "R2Northstar/banlist.txt";
@@ -11,8 +12,6 @@ ServerBanSystem* g_ServerBanSystem;
void ServerBanSystem::OpenBanlist()
{
- std::filesystem::create_directories(BANLIST_PATH);
-
std::ifstream enabledModsStream(BANLIST_PATH);
std::stringstream enabledModsStringStream;
@@ -26,13 +25,12 @@ void ServerBanSystem::OpenBanlist()
}
// open write stream for banlist
- m_sBanlistStream.open(BANLIST_PATH, std::ios::in | std::ios::binary);
+ m_sBanlistStream.open(BANLIST_PATH, std::ofstream::out | std::ofstream::binary | std::ofstream::app);
}
void ServerBanSystem::BanUID(uint64_t uid)
{
m_vBannedUids.push_back(uid);
-
m_sBanlistStream << std::to_string(uid) << std::endl;
}
@@ -46,7 +44,17 @@ void BanPlayerCommand(const CCommand& args)
if (args.ArgC() < 2)
return;
+ for (int i = 0; i < 32; i++)
+ {
+ void* player = GetPlayerByIndex(i);
+ if (!strcmp((char*)player + 0x16, args.Arg(1)) || strcmp((char*)player + 0xF500, args.Arg(1)))
+ {
+ g_ServerBanSystem->BanUID(strtoll((char*)player + 0xF500, nullptr, 10));
+ CBaseClient__Disconnect(player, 1, "Banned from server");
+ break;
+ }
+ }
}
void InitialiseBanSystem(HMODULE baseAddress)