Minor update, only one new command added, but meh..
Current version: 1.1
------------------------
Functions:
* Ability to send global messages to all servers that use this system.
* Ability to send private messages to all servers that use this system.
* Ability to turn on/off the display of the messages.
* Ability to check the current players/playercount on all servers that use this system.
* Ability to check servers that uses this system. Displays servers playercount, and if they have global messages disabled or not.
------------------------
Commands:
/npcglobalmsg "text in quotes"
/npcsendmsg servername "text in quotes"
/npcplayers servername
-- New -- /npcservers
Step-by-step Installation Guide
1) If upgrading from an old version, replace your old code with this (might want to NOT replace the editable options). Otherwise, create a new database NPC, and name it "GlobalSys", then copy and paste this code.
PHP Code:
function onCreated() doConnect();
function onInitialized() doConnect();
function onServerListerConnect() doConnect();
function doConnect()
{
enum {
//-- EDIT THESE --\\
SERVER = "SERVER NAME HERE",
ACCESS = "account1,account2,account3,etc",
ENABLEMESSAGES = true,
//-- DO NOT EDIT --\\
VERSION = 1.1,
CHANNEL = "#GlobalSys",
COMMANDS = "globalmsg,sendmsg,players,servers",
CHECKCOMMANDS = "!globalmessagerequest,!servermessagerequest,!players,!checkservers"
};
sendtext("irc", "logout", "");
sendtext("irc", "login", name);
sendtext("irc", "join", CHANNEL);
sendtext("irc", "privmsg", {CHANNEL, { "!register", SERVER, VERSION, ENABLEMESSAGES }});
}
function onReceiveText(texttype, textoptions, textlines)
{
if (texttype == "irc") {
switch (textoptions) {
case "privmsg":
switch (textlines[2][0]) {
case "!globalmsg":
if (textlines[2][1] != SERVER && ENABLEMESSAGES == true) echo(textlines[2][2]);
break;
case "!servermsg":
if (textlines[2][1] != SERVER && textlines[2][2] == SERVER && ENABLEMESSAGES == true) echo(textlines[2][3]);
break;
case "!getplayers":
if (textlines[2][1] == SERVER) {
for (i: allplayers) {
if (i.level != NULL) temp.players.add(i.account);
else temp.players.add(i.account SPC "(RC)");
}
sendtext("irc", "privmsg", {CHANNEL, {"!updateplayers", temp.players}});
}
break;
}
break;
case "notice":
if (textlines[2][1] == SERVER) echo(textlines[2][2]);
break;
}
}
}
public function hasAccess(acc) return player.account in ACCESS.tokenize(",");
public function doCommand(command, param)
{
if (command in COMMANDS.tokenize(",")) (@command)(param[0], param[1]);
}
function globalmsg(text)
{
if (text != NULL) sendtext("irc", "privmsg", {CHANNEL, {CHECKCOMMANDS.tokenize(",")[0], player.account, text}});
}
function sendmsg(svr, text)
{
if (text != NULL) sendtext("irc", "privmsg", {CHANNEL, {CHECKCOMMANDS.tokenize(",")[1], player.account, text, svr}});
}
function players(svr)
{
if (svr != NULL) sendtext("irc", "privmsg", {CHANNEL, {CHECKCOMMANDS.tokenize(",")[2], svr}});
}
function servers()
{
sendtext("irc", "privmsg", {CHANNEL, {CHECKCOMMANDS.tokenize(",")[3]}});
}
Edit the options SERVER, ACCESS and ENABLEMESSAGES to suit your needs. Please, do not alter the other options - doing so might result in a permanent ban from the system.
2) If you're doing a fresh install, add the following code inside an
onRCChat() function in your
Control-NPC.
PHP Code:
// -- Events Bot Commands -- \\
temp.args = params;
temp.args.delete(0);
if (("GlobalSys").hasAccess(player.account)) ("GlobalSys").doCommand(params[0], temp.args);