diff --git a/Release/Plugins/RenX.Core.lib b/Release/Plugins/RenX.Core.lib index b5ec07e..686455e 100644 Binary files a/Release/Plugins/RenX.Core.lib and b/Release/Plugins/RenX.Core.lib differ diff --git a/RenX.Commands/RenX_Commands.cpp b/RenX.Commands/RenX_Commands.cpp index dfd6444..170b4da 100644 --- a/RenX.Commands/RenX_Commands.cpp +++ b/RenX.Commands/RenX_Commands.cpp @@ -1174,6 +1174,204 @@ const Jupiter::ReadableString &UnMuteIRCCommand::getHelp(const Jupiter::Readable IRC_COMMAND_INIT(UnMuteIRCCommand) +// Kill IRC Command + +void KillIRCCommand::create() +{ + this->addTrigger(STRING_LITERAL_AS_REFERENCE("kill")); + this->setAccessLevel(2); +} + +void KillIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableString &channel, const Jupiter::ReadableString &nick, const Jupiter::ReadableString ¶meters) +{ + if (parameters.isEmpty() == false) + { + Jupiter::IRC::Client::Channel *chan = source->getChannel(channel); + if (chan != nullptr) + { + int type = chan->getType(); + RenX::PlayerInfo *player; + bool match = false; + for (unsigned int i = 0; i != RenX::getCore()->getServerCount(); i++) + { + RenX::Server *server = RenX::getCore()->getServer(i); + if (server->isLogChanType(type)) + { + match = true; + player = server->getPlayerByPartName(parameters); + if (player != nullptr) + { + if (server->kill(player) == false) + source->sendMessage(channel, STRING_LITERAL_AS_REFERENCE("Error: Server does not support muting players.")); + } + else + source->sendNotice(nick, STRING_LITERAL_AS_REFERENCE("Error: Player not found.")); + } + } + if (match == false) + source->sendNotice(nick, STRING_LITERAL_AS_REFERENCE("Error: Channel not attached to any connected Renegade X servers.")); + } + } + else source->sendNotice(nick, STRING_LITERAL_AS_REFERENCE("Error: Too Few Parameters. Syntax: kill ")); +} + +const Jupiter::ReadableString &KillIRCCommand::getHelp(const Jupiter::ReadableString &) +{ + static STRING_LITERAL_AS_NAMED_REFERENCE(defaultHelp, "Kills a player. Syntax: kill "); + return defaultHelp; +} + +IRC_COMMAND_INIT(KillIRCCommand) + +// Disarm IRC Command + +void DisarmIRCCommand::create() +{ + this->addTrigger(STRING_LITERAL_AS_REFERENCE("disarm")); + this->setAccessLevel(2); +} + +void DisarmIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableString &channel, const Jupiter::ReadableString &nick, const Jupiter::ReadableString ¶meters) +{ + if (parameters.isEmpty() == false) + { + Jupiter::IRC::Client::Channel *chan = source->getChannel(channel); + if (chan != nullptr) + { + int type = chan->getType(); + RenX::PlayerInfo *player; + bool match = false; + for (unsigned int i = 0; i != RenX::getCore()->getServerCount(); i++) + { + RenX::Server *server = RenX::getCore()->getServer(i); + if (server->isLogChanType(type)) + { + match = true; + player = server->getPlayerByPartName(parameters); + if (player != nullptr) + { + if (server->disarm(player) == false) + source->sendMessage(channel, STRING_LITERAL_AS_REFERENCE("Error: Server does not support muting players.")); + } + else + source->sendNotice(nick, STRING_LITERAL_AS_REFERENCE("Error: Player not found.")); + } + } + if (match == false) + source->sendNotice(nick, STRING_LITERAL_AS_REFERENCE("Error: Channel not attached to any connected Renegade X servers.")); + } + } + else source->sendNotice(nick, STRING_LITERAL_AS_REFERENCE("Error: Too Few Parameters. Syntax: disarm ")); +} + +const Jupiter::ReadableString &DisarmIRCCommand::getHelp(const Jupiter::ReadableString &) +{ + static STRING_LITERAL_AS_NAMED_REFERENCE(defaultHelp, "Disarms all of a player's deployed objects. Syntax: disarm "); + return defaultHelp; +} + +IRC_COMMAND_INIT(DisarmIRCCommand) + +// DisarmC4 IRC Command + +void DisarmC4IRCCommand::create() +{ + this->addTrigger(STRING_LITERAL_AS_REFERENCE("disarmc4")); + this->setAccessLevel(2); +} + +void DisarmC4IRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableString &channel, const Jupiter::ReadableString &nick, const Jupiter::ReadableString ¶meters) +{ + if (parameters.isEmpty() == false) + { + Jupiter::IRC::Client::Channel *chan = source->getChannel(channel); + if (chan != nullptr) + { + int type = chan->getType(); + RenX::PlayerInfo *player; + bool match = false; + for (unsigned int i = 0; i != RenX::getCore()->getServerCount(); i++) + { + RenX::Server *server = RenX::getCore()->getServer(i); + if (server->isLogChanType(type)) + { + match = true; + player = server->getPlayerByPartName(parameters); + if (player != nullptr) + { + if (server->disarmC4(player) == false) + source->sendMessage(channel, STRING_LITERAL_AS_REFERENCE("Error: Server does not support muting players.")); + } + else + source->sendNotice(nick, STRING_LITERAL_AS_REFERENCE("Error: Player not found.")); + } + } + if (match == false) + source->sendNotice(nick, STRING_LITERAL_AS_REFERENCE("Error: Channel not attached to any connected Renegade X servers.")); + } + } + else source->sendNotice(nick, STRING_LITERAL_AS_REFERENCE("Error: Too Few Parameters. Syntax: disarmC4 ")); +} + +const Jupiter::ReadableString &DisarmC4IRCCommand::getHelp(const Jupiter::ReadableString &) +{ + static STRING_LITERAL_AS_NAMED_REFERENCE(defaultHelp, "Disarms all of a player's deployed C4s. Syntax: disarmc4 "); + return defaultHelp; +} + +IRC_COMMAND_INIT(DisarmC4IRCCommand) + +// DisarmBeacon IRC Command + +void DisarmBeaconIRCCommand::create() +{ + this->addTrigger(STRING_LITERAL_AS_REFERENCE("disarmb")); + this->addTrigger(STRING_LITERAL_AS_REFERENCE("disarmbeacon")); + this->addTrigger(STRING_LITERAL_AS_REFERENCE("disarmbeacons")); + this->setAccessLevel(2); +} + +void DisarmBeaconIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableString &channel, const Jupiter::ReadableString &nick, const Jupiter::ReadableString ¶meters) +{ + if (parameters.isEmpty() == false) + { + Jupiter::IRC::Client::Channel *chan = source->getChannel(channel); + if (chan != nullptr) + { + int type = chan->getType(); + RenX::PlayerInfo *player; + bool match = false; + for (unsigned int i = 0; i != RenX::getCore()->getServerCount(); i++) + { + RenX::Server *server = RenX::getCore()->getServer(i); + if (server->isLogChanType(type)) + { + match = true; + player = server->getPlayerByPartName(parameters); + if (player != nullptr) + { + if (server->disarmBeacon(player) == false) + source->sendMessage(channel, STRING_LITERAL_AS_REFERENCE("Error: Server does not support muting players.")); + } + else + source->sendNotice(nick, STRING_LITERAL_AS_REFERENCE("Error: Player not found.")); + } + } + if (match == false) + source->sendNotice(nick, STRING_LITERAL_AS_REFERENCE("Error: Channel not attached to any connected Renegade X servers.")); + } + } + else source->sendNotice(nick, STRING_LITERAL_AS_REFERENCE("Error: Too Few Parameters. Syntax: disarmb ")); +} + +const Jupiter::ReadableString &DisarmBeaconIRCCommand::getHelp(const Jupiter::ReadableString &) +{ + static STRING_LITERAL_AS_NAMED_REFERENCE(defaultHelp, "Disarms all of a player's deployed beacons. Syntax: disarmb "); + return defaultHelp; +} + +IRC_COMMAND_INIT(DisarmBeaconIRCCommand) + // Kick IRC Command void KickIRCCommand::create() diff --git a/RenX.Commands/RenX_Commands.h b/RenX.Commands/RenX_Commands.h index 4e3052f..1d0d6de 100644 --- a/RenX.Commands/RenX_Commands.h +++ b/RenX.Commands/RenX_Commands.h @@ -1,5 +1,5 @@ /** - * Copyright (C) 2014 Justin James. + * Copyright (C) 2014-2015 Justin James. * * This license must be preserved. * Any applications, libraries, or code which make any use of any @@ -71,6 +71,10 @@ GENERIC_IRC_COMMAND(GameOverIRCCommand) GENERIC_IRC_COMMAND(SetMapIRCCommand) GENERIC_IRC_COMMAND(MuteIRCCommand) GENERIC_IRC_COMMAND(UnMuteIRCCommand) +GENERIC_IRC_COMMAND(KillIRCCommand) +GENERIC_IRC_COMMAND(DisarmIRCCommand) +GENERIC_IRC_COMMAND(DisarmC4IRCCommand) +GENERIC_IRC_COMMAND(DisarmBeaconIRCCommand) GENERIC_IRC_COMMAND(KickIRCCommand) GENERIC_IRC_COMMAND(TempBanIRCCommand) GENERIC_IRC_COMMAND(KickBanIRCCommand) diff --git a/RenX.Core/RenX_Server.cpp b/RenX.Core/RenX_Server.cpp index 6840eca..572bc31 100644 --- a/RenX.Core/RenX_Server.cpp +++ b/RenX.Core/RenX_Server.cpp @@ -422,6 +422,36 @@ bool RenX::Server::kill(RenX::PlayerInfo *player) return RenX::Server::kill(player->id); } +bool RenX::Server::disarm(int id) +{ + return RenX::Server::send(Jupiter::StringS::Format("disarm pid%d", id)) > 0; +} + +bool RenX::Server::disarm(RenX::PlayerInfo *player) +{ + return RenX::Server::disarm(player->id); +} + +bool RenX::Server::disarmC4(int id) +{ + return RenX::Server::send(Jupiter::StringS::Format("disarmc4 pid%d", id)) > 0; +} + +bool RenX::Server::disarmC4(RenX::PlayerInfo *player) +{ + return RenX::Server::disarmC4(player->id); +} + +bool RenX::Server::disarmBeacon(int id) +{ + return RenX::Server::send(Jupiter::StringS::Format("disarmb pid%d", id)) > 0; +} + +bool RenX::Server::disarmBeacon(RenX::PlayerInfo *player) +{ + return RenX::Server::disarmBeacon(player->id); +} + bool RenX::Server::changeTeam(int id, bool resetCredits) { return RenX::Server::send(Jupiter::StringS::Format(resetCredits ? "team pid%d" : "team2 pid%d", id)) > 0; diff --git a/RenX.Core/RenX_Server.h b/RenX.Core/RenX_Server.h index 54ed895..a1500a1 100644 --- a/RenX.Core/RenX_Server.h +++ b/RenX.Core/RenX_Server.h @@ -387,6 +387,54 @@ namespace RenX */ bool kill(RenX::PlayerInfo *player); + /** + * @brief Disarms all of a player's deployed objects. + * + * @param id ID of the player to disarm + * @return True on success, false otherwise. + */ + bool disarm(int id); + + /** + * @brief Disarms all of a player's deployed objects. + * + * @param player Player to disarm + * @return True on success, false otherwise. + */ + bool disarm(RenX::PlayerInfo *player); + + /** + * @brief Disarms all of a player's deployed C4. + * + * @param id ID of the player to disarm + * @return True on success, false otherwise. + */ + bool disarmC4(int id); + + /** + * @brief Disarms all of a player's deployed C4. + * + * @param player Player to disarm + * @return True on success, false otherwise. + */ + bool disarmC4(RenX::PlayerInfo *player); + + /** + * @brief Disarms all of a player's deployed beacons. + * + * @param id ID of the player to disarm + * @return True on success, false otherwise. + */ + bool disarmBeacon(int id); + + /** + * @brief Disarms all of a player's deployed beacons. + * + * @param player Player to disarm + * @return True on success, false otherwise. + */ + bool disarmBeacon(RenX::PlayerInfo *player); + /** * @brief Forces a player to change teams. *