diff --git a/Release/Plugins/RenX.Core.lib b/Release/Plugins/RenX.Core.lib index e82fada..a99e233 100644 Binary files a/Release/Plugins/RenX.Core.lib and b/Release/Plugins/RenX.Core.lib differ diff --git a/RenX.Core/RenX_Server.cpp b/RenX.Core/RenX_Server.cpp index 95368f6..4209922 100644 --- a/RenX.Core/RenX_Server.cpp +++ b/RenX.Core/RenX_Server.cpp @@ -368,6 +368,26 @@ bool RenX::Server::giveCredits(RenX::PlayerInfo *player, double credits) return RenX::Server::giveCredits(player->id, credits); } +bool RenX::Server::changeTeam(int id, unsigned char options) +{ + return RenX::Server::xRconVersion != 0 && RenX::Server::sock.send(Jupiter::StringS::Format("_x\x07%d%c%c\n", id, RenX::DelimC, options)) > 0; +} + +bool RenX::Server::changeTeam(RenX::PlayerInfo *player, unsigned char options) +{ + return RenX::Server::changeTeam(player->id, options); +} + +bool RenX::Server::setTeam(int id, int team, unsigned char options) +{ + return RenX::Server::xRconVersion != 0 && RenX::Server::sock.send(Jupiter::StringS::Format("_x\x07%d%c%c%c%d\n", id, RenX::DelimC, options, RenX::DelimC, team)) > 0; +} + +bool RenX::Server::setTeam(RenX::PlayerInfo *player, int team, unsigned char options) +{ + return RenX::Server::setTeam(player->id, team, options); +} + const Jupiter::ReadableString &RenX::Server::getPrefix() const { return RenX::Server::IRCPrefix; @@ -1110,12 +1130,12 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line) { PARSE_PLAYER_DATA_P(header); PlayerInfo *player = getPlayerOrAdd(this, name, id, team, isBot, playerData.asUnsignedLongLong(0), action); - player->ping = buff.getToken(4, RenX::DelimC).asUnsignedInt() * 4; - player->kills = buff.getToken(5, RenX::DelimC).asUnsignedInt(); - player->deaths = buff.getToken(6, RenX::DelimC).asUnsignedInt(); - player->score = static_cast(buff.getToken(7, RenX::DelimC).asDouble()); - player->credits = static_cast(buff.getToken(8, RenX::DelimC).asDouble()); - player->character = RenX::getCharacter(buff.getToken(9, RenX::DelimC)); + player->ping = buff.getToken(3, RenX::DelimC).asUnsignedInt() * 4; + player->kills = buff.getToken(4, RenX::DelimC).asUnsignedInt(); + player->deaths = buff.getToken(5, RenX::DelimC).asUnsignedInt(); + player->score = static_cast(buff.getToken(6, RenX::DelimC).asDouble()); + player->credits = static_cast(buff.getToken(7, RenX::DelimC).asDouble()); + player->character = RenX::getCharacter(buff.getToken(8, RenX::DelimC)); } header.shiftLeft(1); break; @@ -1126,7 +1146,7 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line) PlayerInfo *player = getPlayerOrAdd(this, name, id, team, isBot, 0U, Jupiter::ReferenceString::empty); player->ping = playerData.asUnsignedInt(); player->score = static_cast(action.asDouble()); - player->credits = static_cast(buff.getToken(4, RenX::DelimC).asDouble()); + player->credits = static_cast(buff.getToken(3, RenX::DelimC).asDouble()); } header.shiftLeft(1); break; diff --git a/RenX.Core/RenX_Server.h b/RenX.Core/RenX_Server.h index 49a480c..6c15dbc 100644 --- a/RenX.Core/RenX_Server.h +++ b/RenX.Core/RenX_Server.h @@ -296,6 +296,44 @@ namespace RenX */ bool giveCredits(RenX::PlayerInfo *player, double credits); + /** + * @brief Forces a player to change teams, if the server supports it. + * + * @param id ID of the player to give credits to + * @param options Options to pass to the command + * @return True on success, false otherwise. + */ + bool changeTeam(int id, unsigned char options = 0x03); + + /** + * @brief Forces a player to change teams, if the server supports it. + * + * @param player Player to change teams + * @param options Options to pass to the command + * @return True on success, false otherwise. + */ + bool changeTeam(RenX::PlayerInfo *player, unsigned char options = 0x03); + + /** + * @brief Forces a player to change teams, if the server supports it. + * + * @param id ID of the player to give credits to + * @param team Team number to switch to + * @param options Options to pass to the command + * @return True on success, false otherwise. + */ + bool setTeam(int id, int team, unsigned char options = 0x03); + + /** + * @brief Forces a player to change teams, if the server supports it. + * + * @param player Player to change teams + * @param team Team number to switch to + * @param options Options to pass to the command + * @return True on success, false otherwise. + */ + bool setTeam(RenX::PlayerInfo *player, int team, unsigned char options = 0x03); + /** * @brief Fetches a server's IRC logging prefix. *