Browse Source

Added disarm(), disarmC4(), and disarmBeacon() functions to RenX::Server; Added "Kill", "Disarm", "DisarmC4", and "DisarmBeacon" IRC commands.

pull/3/head
JustinAJ 10 years ago
parent
commit
2fa480854e
  1. BIN
      Release/Plugins/RenX.Core.lib
  2. 198
      RenX.Commands/RenX_Commands.cpp
  3. 6
      RenX.Commands/RenX_Commands.h
  4. 30
      RenX.Core/RenX_Server.cpp
  5. 48
      RenX.Core/RenX_Server.h

BIN
Release/Plugins/RenX.Core.lib

Binary file not shown.

198
RenX.Commands/RenX_Commands.cpp

@ -1174,6 +1174,204 @@ const Jupiter::ReadableString &UnMuteIRCCommand::getHelp(const Jupiter::Readable
IRC_COMMAND_INIT(UnMuteIRCCommand) 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 &parameters)
{
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 <player>"));
}
const Jupiter::ReadableString &KillIRCCommand::getHelp(const Jupiter::ReadableString &)
{
static STRING_LITERAL_AS_NAMED_REFERENCE(defaultHelp, "Kills a player. Syntax: kill <player>");
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 &parameters)
{
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 <player>"));
}
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 <player>");
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 &parameters)
{
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 <player>"));
}
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 <player>");
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 &parameters)
{
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 <player>"));
}
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 <player>");
return defaultHelp;
}
IRC_COMMAND_INIT(DisarmBeaconIRCCommand)
// Kick IRC Command // Kick IRC Command
void KickIRCCommand::create() void KickIRCCommand::create()

6
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. * This license must be preserved.
* Any applications, libraries, or code which make any use of any * 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(SetMapIRCCommand)
GENERIC_IRC_COMMAND(MuteIRCCommand) GENERIC_IRC_COMMAND(MuteIRCCommand)
GENERIC_IRC_COMMAND(UnMuteIRCCommand) 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(KickIRCCommand)
GENERIC_IRC_COMMAND(TempBanIRCCommand) GENERIC_IRC_COMMAND(TempBanIRCCommand)
GENERIC_IRC_COMMAND(KickBanIRCCommand) GENERIC_IRC_COMMAND(KickBanIRCCommand)

30
RenX.Core/RenX_Server.cpp

@ -422,6 +422,36 @@ bool RenX::Server::kill(RenX::PlayerInfo *player)
return RenX::Server::kill(player->id); 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) bool RenX::Server::changeTeam(int id, bool resetCredits)
{ {
return RenX::Server::send(Jupiter::StringS::Format(resetCredits ? "team pid%d" : "team2 pid%d", id)) > 0; return RenX::Server::send(Jupiter::StringS::Format(resetCredits ? "team pid%d" : "team2 pid%d", id)) > 0;

48
RenX.Core/RenX_Server.h

@ -387,6 +387,54 @@ namespace RenX
*/ */
bool kill(RenX::PlayerInfo *player); 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. * @brief Forces a player to change teams.
* *

Loading…
Cancel
Save