View Single Post
  #15  
Old 03-06-2008, 03:09 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
Just added more commands and a check ensuring no commands that doesn't exist are called, nothing major. But still. Updated the HUB a little too, though.



Current version: 1.2
------------------------
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.
* Ability to find a player on any of the servers that use this system.
------------------------
Commands:
/npcglobalmsg "text in quotes"
/npcsendmsg servername "text in quotes"
/npcplayers servername
/npcservers
-- New -- /npcfindplayer playeraccount
-- New -- /npcgetlatesturl

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,

    
//-- CUSTOMIZEABLE --\\
    
COMMANDS "globalmsg,sendmsg,players,servers,findplayer,getlatesturl",

    
//-- DO NOT EDIT --\\
    
VERSION 1.2,
    
CHANNEL "#GlobalSys",
    
CHECKCOMMANDS "!globalmessagerequest,!servermessagerequest,!players,!checkservers,!findplayer,!getlatesturl"
  
};
  
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 
validCommand(command) return command in COMMANDS.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}});
}

function 
servers()
{
  
sendtext("irc""privmsg", {CHANNEL, {CHECKCOMMANDS.tokenize(",")[3]}});
}

function 
findplayer(pl)
{
  if (
pl != NULLsendtext("irc""privmsg", {CHANNEL, {CHECKCOMMANDS.tokenize(",")[4], pl}});
}

function 
getlatesturl()
{
  
sendtext("irc""privmsg", {CHANNEL, {CHECKCOMMANDS.tokenize(",")[5]}});

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. Otherwise replace your old with this.

PHP Code:
  // -- Events Bot Commands -- \\
  
temp.args params;
  
temp.args.delete(0);

  if ((
"GlobalSys").hasAccess(player.account) && ("GlobalSys").validCommand(params[0])) ("GlobalSys").doCommand(params[0], temp.args); 
__________________
Follow my work on social media post-Graal:Updated august 2025.

Last edited by xXziroXx; 03-06-2008 at 04:31 AM..
Reply With Quote