feat(lua): Allow lua scripts to flag modders with a custom reason if needed. (#2248)
This commit is contained in:
63
src/services/player_database/persistent_player.cpp
Normal file
63
src/services/player_database/persistent_player.cpp
Normal file
@ -0,0 +1,63 @@
|
||||
#pragma once
|
||||
#include "persistent_player.hpp"
|
||||
|
||||
#include "core/data/infractions.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
static std::unordered_map<Infraction, const char*> infraction_desc = {
|
||||
{Infraction::DESYNC_PROTECTION, "Used desync protections"},
|
||||
{Infraction::BREAKUP_KICK_DETECTED, "Kicked someone using breakup kick"},
|
||||
{Infraction::LOST_CONNECTION_KICK_DETECTED, "Tried to kick someone using lost connection kick"},
|
||||
{Infraction::SPOOFED_ROCKSTAR_ID, "Had spoofed RID"},
|
||||
{Infraction::TRIGGERED_ANTICHEAT, "Triggered Rockstar's anticheat"},
|
||||
{Infraction::TRIED_CRASH_PLAYER, "Tried to crash you"},
|
||||
{Infraction::TRIED_KICK_PLAYER, "Tried to kick you"},
|
||||
{Infraction::BLAME_EXPLOSION_DETECTED, "Tried to blame someone for their explosion"},
|
||||
{Infraction::ATTACKING_WITH_GODMODE, "Attacked someone while using godmode"},
|
||||
{Infraction::ATTACKING_WITH_INVISIBILITY, "Attacked someone while being invisible"},
|
||||
{Infraction::ATTACKING_WHEN_HIDDEN_FROM_PLAYER_LIST, "Attacked someone while being hidden from the player list"},
|
||||
{Infraction::SPOOFED_DATA, "Had spoofed data"},
|
||||
{Infraction::SPOOFED_HOST_TOKEN, "Had spoofed their host token"},
|
||||
{Infraction::INVALID_PLAYER_MODEL, "Had used an invalid player model"},
|
||||
{Infraction::SUPER_JUMP, "Had used super jump"},
|
||||
{Infraction::UNDEAD_OTR, "Had used undead OTR"},
|
||||
};
|
||||
|
||||
const char* persistent_player::get_infraction_description(int infraction)
|
||||
{
|
||||
if (static_cast<Infraction>(infraction) == Infraction::CUSTOM_REASON)
|
||||
{
|
||||
return custom_infraction_reason.c_str();
|
||||
}
|
||||
|
||||
return infraction_desc[static_cast<Infraction>(infraction)];
|
||||
}
|
||||
|
||||
std::string persistent_player::get_all_infraction_descriptions()
|
||||
{
|
||||
if (!infractions.size())
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
constexpr auto separator = ", ";
|
||||
constexpr size_t separator_length = (std::string(separator)).size();
|
||||
|
||||
std::string s;
|
||||
|
||||
for (const auto infr : infractions)
|
||||
{
|
||||
s += get_infraction_description(infr);
|
||||
s += separator;
|
||||
}
|
||||
|
||||
// Remove last useless separator
|
||||
for (size_t i = 0; i < separator_length; i++)
|
||||
{
|
||||
s.pop_back();
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
#pragma once
|
||||
#include "core/data/infractions.hpp"
|
||||
#include "json_util.hpp"
|
||||
|
||||
#include <unordered_set>
|
||||
@ -43,12 +42,13 @@ namespace big
|
||||
struct persistent_player
|
||||
{
|
||||
std::string name;
|
||||
uint64_t rockstar_id = 0;
|
||||
bool block_join = false;
|
||||
int block_join_reason = 1;
|
||||
bool is_modder = false;
|
||||
bool notify_online = false;
|
||||
uint64_t rockstar_id = 0;
|
||||
bool block_join = false;
|
||||
int block_join_reason = 1;
|
||||
bool is_modder = false;
|
||||
bool notify_online = false;
|
||||
std::unordered_set<int> infractions;
|
||||
std::string custom_infraction_reason = "";
|
||||
std::string notes = "";
|
||||
std::optional<CommandAccessLevel> command_access_level = std::nullopt;
|
||||
bool join_redirect = false;
|
||||
@ -66,7 +66,9 @@ namespace big
|
||||
std::string game_mode_id = "";
|
||||
rage::rlSessionInfo redirect_info{};
|
||||
|
||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(persistent_player, name, rockstar_id, block_join, block_join_reason, is_modder, notify_online, infractions, notes, command_access_level, join_redirect, join_redirect_preference)
|
||||
};
|
||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(persistent_player, name, rockstar_id, block_join, block_join_reason, is_modder, notify_online, infractions, custom_infraction_reason, notes, command_access_level, join_redirect, join_redirect_preference)
|
||||
|
||||
const char* get_infraction_description(int infraction);
|
||||
std::string get_all_infraction_descriptions();
|
||||
};
|
||||
};
|
||||
|
Reference in New Issue
Block a user