Browse Source

Added PMsg command

pull/3/head
JustinAJ 10 years ago
parent
commit
0564220080
  1. 48
      RenX.Commands/RenX_Commands.cpp
  2. 1
      RenX.Commands/RenX_Commands.h

48
RenX.Commands/RenX_Commands.cpp

@ -123,6 +123,54 @@ const Jupiter::ReadableString &MsgIRCCommand::getHelp(const Jupiter::ReadableStr
IRC_COMMAND_INIT(MsgIRCCommand) IRC_COMMAND_INIT(MsgIRCCommand)
// PMsg IRC Command
void PMsgIRCCommand::create()
{
this->addTrigger(STRING_LITERAL_AS_REFERENCE("pmsg"));
this->addTrigger(STRING_LITERAL_AS_REFERENCE("psay"));
this->addTrigger(STRING_LITERAL_AS_REFERENCE("page"));
this->addTrigger(STRING_LITERAL_AS_REFERENCE("ppage"));
this->setAccessLevel(1);
}
void PMsgIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableString &channel, const Jupiter::ReadableString &nick, const Jupiter::ReadableString &parameters)
{
if (parameters.wordCount(WHITESPACE) >= 2)
{
int type = source->getChannel(channel)->getType();
Jupiter::ReferenceString name = Jupiter::ReferenceString::getWord(parameters, 0, WHITESPACE);
RenX::PlayerInfo *player;
Jupiter::StringL msg = source->getChannel(channel)->getUserPrefix(nick);
msg += nick;
msg += "@IRC: ";
msg += Jupiter::ReferenceString::gotoWord(parameters, 1, WHITESPACE);
if (parameters.size() != 0)
{
for (unsigned int i = 0; i != RenX::getCore()->getServerCount(); i++)
{
RenX::Server *server = RenX::getCore()->getServer(i);
if (server->isLogChanType(type))
{
player = server->getPlayerByPartName(name);
if (player != nullptr)
server->sendMessage(player, msg);
else source->sendNotice(nick, STRING_LITERAL_AS_REFERENCE("Error: Player not found."));
}
}
}
}
else source->sendNotice(nick, STRING_LITERAL_AS_REFERENCE("Error: Too Few Parameters. Syntax: PMsg <Player> <Message>"));
}
const Jupiter::ReadableString &PMsgIRCCommand::getHelp(const Jupiter::ReadableString &)
{
static STRING_LITERAL_AS_NAMED_REFERENCE(defaultHelp, "Sends a message in - game.Syntax: PMsg <Player> <Message>");
return defaultHelp;
}
IRC_COMMAND_INIT(PMsgIRCCommand)
// Host Msg IRC Command // Host Msg IRC Command
void HostMsgIRCCommand::create() void HostMsgIRCCommand::create()

1
RenX.Commands/RenX_Commands.h

@ -41,6 +41,7 @@ GENERIC_CONSOLE_COMMAND(RCONConsoleCommand)
//GENERIC_CONSOLE_COMMAND(RCONSelectConsoleCommand) //GENERIC_CONSOLE_COMMAND(RCONSelectConsoleCommand)
GENERIC_IRC_COMMAND(MsgIRCCommand) GENERIC_IRC_COMMAND(MsgIRCCommand)
GENERIC_IRC_COMMAND(PMsgIRCCommand)
GENERIC_IRC_COMMAND(HostMsgIRCCommand) GENERIC_IRC_COMMAND(HostMsgIRCCommand)
GENERIC_IRC_COMMAND(PlayersIRCCommand) GENERIC_IRC_COMMAND(PlayersIRCCommand)
GENERIC_IRC_COMMAND(PlayerInfoIRCCommand) GENERIC_IRC_COMMAND(PlayerInfoIRCCommand)

Loading…
Cancel
Save