View Single Post
  #1  
Old 03-01-2008, 06:48 AM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Global Message System

This is a newer, complete remake, of the Global Message/Event System (please don't post in that thread anymore, in fact, if a moderator feels like it - go ahead and delete it).

Simply put, it's an easy-to-install system that allowed you to send messages on RC too other servers that use the system. The more servers that start using it, the better. None of the "former" versions of the old system works anymore.



Current version: 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.
------------------------
Commands:
/npcglobalmsg "text in quotes"
/npcsendmsg servername "text in quotes"
/npcplayers servername

Step-by-step Installation Guide

1) 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,
    
CHANNEL "#GlobalSys",
    
COMMANDS "globalmsg,sendmsg,players",
    
CHECKCOMMANDS "!globalmessagerequest,!servermessagerequest,!players"
  
};
  
sendtext("irc""logout""");
  
sendtext("irc""login"name);
  
sendtext("irc""join"CHANNEL);
  
sendtext("irc""privmsg", {CHANNEL, { "!register"SERVERVERSIONENABLEMESSAGES }});
}

function 
onReceiveText(texttypetextoptionstextlines)
{
  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 (
iallplayers) {
                if (
i.level != NULLtemp.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(commandparam)
{
  if (
command in COMMANDS.tokenize()) (@command)(param[0], param[1]);
}

function 
globalmsg(text)
{
  if (
text != NULLsendtext("irc""privmsg", {CHANNEL, {CHECKCOMMANDS.tokenize()[0], player.accounttext}});
}

function 
sendmsg(svrtext)
{
  if (
text != NULLsendtext("irc""privmsg", {CHANNEL, {CHECKCOMMANDS.tokenize()[1], player.accounttextsvr}});
}

function 
players(svr)
{
  if (
svr != NULLsendtext("irc""privmsg", {CHANNEL, {CHECKCOMMANDS.tokenize()[2], svr}});

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) 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); 

Of course, offensive chat or too much spam, will result in a timed ban from the system. If you violate it too much, you might even get a permanent ban.

Suggestions, feedback, comments - everything is appreciated. And please, use the forums built-in reputation system. If you think this is a horrible idea, give me bad rep, at least then I know its not liked.


Credits too napo who is hosting the HUB on AEON!
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote