collapse collapse
* User Info
 
 
Welcome, Guest. Please login or register.
* Search

* Board Stats
  • stats Total Members: 989
  • stats Total Posts: 18366
  • stats Total Topics: 2501
  • stats Total Categories: 7
  • stats Total Boards: 35
  • stats Most Online: 1144

Author Topic: modified Online.php  (Read 28736 times)

0 Members and 3 Guests are viewing this topic.

Offline Akarah

  • Contributor
  • *******
  • Posts: 72
  • Karma: +0/-0
    • http://synergyfactor.net/
modified Online.php
« on: December 04, 2005, 12:12:05 pm »
yup i was really bored and wanted to whip up something trivial and simple, so here is yet another "core" change, not really a module. i added some graphic elements (icons, seperators) to the Online.php file, and also integrated Alreadythere's whois caching stuff (not that we ever have to whois members... but i guess it never hurts to be thorough ;) )

sample:


file:
http://ao.rockwood.us/bebot/Online.phps

rename to .php of course - depends on Alreadythere's WhoisCache module (unless the method is never called..)

cheers,

/Aka

Offline Wanuarmi

  • Contributor
  • *******
  • Posts: 121
  • Karma: +0/-0
modified Online.php
« Reply #1 on: December 04, 2005, 12:24:05 pm »
hey wow that looks nice...

gonna try it out later

edit: do I have to install the whois cache? I tried it and its saying it cant call a function.

Offline Akarah

  • Contributor
  • *******
  • Posts: 72
  • Karma: +0/-0
    • http://synergyfactor.net/
modified Online.php
« Reply #2 on: December 04, 2005, 01:02:27 pm »
i played around with using the images shown during profession selection, but they weren't designed to be alphabetized, and i didn't want to mess up the script any more than i did (ksort() is great.. sorting by fc's order is probably NOT great ;) )

Offline Wanuarmi

  • Contributor
  • *******
  • Posts: 121
  • Karma: +0/-0
modified Online.php
« Reply #3 on: December 04, 2005, 01:06:12 pm »
is there a version that doesnt use the whois cache? I really liked this... also does the privgroup online list looks like the guild online list?

Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
modified Online.php
« Reply #4 on: December 04, 2005, 01:21:46 pm »
Quote from: "Wanuarmi"
is there a version that doesnt use the whois cache? I really liked this...


Just replace only the function online_list(), should do the trick I think.
Or use Akarah's file, and use the whois() function out of your old Online.php.

Not 100% sure which of those two things is the better way :)

Offline Akarah

  • Contributor
  • *******
  • Posts: 72
  • Karma: +0/-0
    • http://synergyfactor.net/
modified Online.php
« Reply #5 on: December 04, 2005, 01:22:45 pm »
yup the only changes affecting display are in online_list()

i didn't test the privgroup, but it uses the same function, so it should.

Offline Wanuarmi

  • Contributor
  • *******
  • Posts: 121
  • Karma: +0/-0
modified Online.php
« Reply #6 on: December 04, 2005, 01:37:51 pm »
cool thanks :)

Offline Khalem

  • BeBot Founder
  • Administrator
  • ********
  • Posts: 1169
  • Karma: +0/-0
    • http://www.ancarim.com
modified Online.php
« Reply #7 on: December 04, 2005, 06:10:49 pm »
I like it, and the icons ara rather unintrusive too.

Now, one thing we need, a switch option to allow icons usage to be disabled or enabled.
BeBot Founder and Fixer Kingpin

Offline Akarah

  • Contributor
  • *******
  • Posts: 72
  • Karma: +0/-0
    • http://synergyfactor.net/
modified Online.php
« Reply #8 on: December 04, 2005, 10:28:54 pm »
i thought about that as i was falling asleep ;)

Offline Xenixa

  • Contributor
  • *******
  • Posts: 307
  • Karma: +0/-0
modified Online.php
« Reply #9 on: December 05, 2005, 03:15:53 am »
Oooh, nice one. :)
Copied the bits you added for the graphics into my copy since mines custom modified for formating. Org likes it alot :)

Might I suggest using the settings table if you implement a switch to turn those Icons on/off? Any thing that can be toggled on/off I been keeping in the settings table using that custom function floating around (get_setting) for bot.php
<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky

Offline Wanuarmi

  • Contributor
  • *******
  • Posts: 121
  • Karma: +0/-0
modified Online.php
« Reply #10 on: December 05, 2005, 08:44:46 am »
made some modifications so the AI level would show if you are not using the whois cache module

Code: [Select]
<?
  /*
   * Online.php - Online plugin to display online users
   *
   * BeBot - An Anarchy Online Chat Automaton
   * Copyright (C) 2004 Jonas Jax
   *
   * Developed by Blondengy (RK1)
   * Special thanks goes out to Khalem (RK1) for his support.
   *
   * File last changed at $LastChangedDate: 2004-12-29 01:41:32 +0100 (Wed, 29 Dec 2004) $
   * Revision: $Id: Online.php 8 2004-12-29 00:41:32Z blondengy $
   */

 
  $online = new Online($bot);


  $commands["tell"]["online"] = &$online;
  $commands["pgmsg"]["online"] = &$online;
  $commands["gc"]["online"] = &$online;
 
  $commands["pgjoin"][] = &$online;
  $commands["pgleave"][] = &$online;
  $commands["buddy"][] = &$online;

  $commands["connect"][] = &$online;
  $commands["disconnect"][] = &$online;



  /*
    The Class itself...
  */
  class Online
  {
    var $bot;
    var $guild;
    var $pgroup;
    var $connected;
   
   

    /*
      Constructor:
        Hands over a referance to the "Bot" class.
    */
    function Online (&$bot)
    {
      $this -> bot = &$bot;
      $this -> guild = array();
      $this -> pgroup = array();
    }



    /*
      This gets called on a tell with the command
    */
    function tell($name, $msg)
    {
    $disponline = (($this -> bot -> guildbot) ? "both": "pgroup");
    $this -> bot -> send_tell($name, $this -> online_msg($msg, $disponline));
    }



    /*
      This gets called on a msg in the privgroup with the command
    */
    function pgmsg($name, $msg)
    {
      if ($this -> bot -> is_member($name))
      {
      $disponline = (($this -> bot -> guildbot) ? "both": "pgroup");
      $this -> bot -> send_pgroup($this -> online_msg($msg, $disponline));
      }
    }


    /*
      Gets called on a GC message
    */
    function gc($name, $msg)
    {
    $disponline = (($this -> bot -> guildbot) ? "both": "pgroup");
    $this -> bot -> send_gc($this -> online_msg($msg, $disponline));
    }




    /*
      This gets called if someone joins the privgroup
    */
    function pgjoin($name)
    {
      $this -> pgroup[$name] = $this -> whois($name);
    }



    /*
      This gets called if someone leaves the privgroup
    */
    function pgleave($name)
    {
      if (isset($this -> pgroup[$name]))
        unset($this -> pgroup[$name]);
    }



    /*
      This gets called if a buddy logs on/off
    */
    function buddy($name, $msg)
    {
      if ($this -> bot -> is_member($name))
      {
        if ($msg == 1)
          $this -> guild[$name] = $this -> whois($name);
         
        else if (isset($this -> guild[$name]))
          unset($this -> guild[$name]);
      }
    }



     /*
      This gets called when bot disconnects
    */
    function disconnect()
    {
      $this -> guild = array();
      $this -> pgroup = array();
    }



     /*
      This gets called when bot connects
    */
    function connect()
    {
      $this -> connected = time() + 120;
    }



/*
Makes the message.
*/
function online_msg($msg, $what)
{
      preg_match("/^" . $this -> bot -> commpre . "online (.+)$/i", $msg, $info);
     
      if ($info[1] == "all")
$info[1] = "";

      $guild = $this -> online_list($this -> guild, $info[1]);
      $pgroup = $this -> online_list($this -> pgroup, $info[1]);
     
      $online = "";
      $msg = "";
     
      if (($what == "both") || ($what == "guild"))
      {
        $online .= "<font color=CCInfoHeadline>::: " . $guild[0] . " members online in Guild :::</font>\n" . $guild[1];
        $online .= "\n<font color=CCCCTextColor>------------------------------\n";
        $msg .= "<font color=#ffff00>" . $guild[0] . "</font> members online in Guild. ";
    }
    if (($what == "both") || ($what == "pgroup"))
    {
      $online .= "<font color=CCInfoHeadline>::: " . $pgroup[0] . " players in Privategroup :::</font>\n" . $pgroup[1];
        $msg .= "<font color=#ffff00>" . $pgroup[0] . "</font> members in Privategroup. ";
      }


      $msg .= ":: " . $this -> bot -> make_blob("click to view", $online);

      return $msg;
}



    /*
      Gets info on player
    */
    function whois($name)
    {
    $second = (($this -> bot -> guildbot) ? "rank_name" : "guild");
      $result = $this -> bot -> db -> select("SELECT nickname, level, $second, profession, id FROM members WHERE id = " . $this -> bot -> aoc -> get_uid($name));

      if (empty($result))
      {
       $content = $this -> bot -> get_site("http://www.anarchy-online.com/character/bio/d/" . $this -> bot -> dimension . "/name/" . strtolower($name) . "/bio.xml");
        $result[0] = $name;
        $result[1] = $this -> bot -> xmlparse($content, "level");
        $result[2] = $this -> bot -> xmlparse($content, "organization_name");
        $result[3] = $this -> bot -> xmlparse($content, "profession");
        $result[4] = $this -> bot -> aoc -> get_uid($name);
$result[5] = $this -> bot -> xmlparse($content, "defender_rank_id");
      }
      else
 {
        $result = $result[0];
$content = $this -> bot -> get_site("http://www.anarchy-online.com/character/bio/d/" . $this -> bot -> dimension . "/name/" . strtolower($name) . "/bio.xml");
$result[5] = $this -> bot -> xmlparse($content, "defender_rank_id");
 }

      if (empty($result[3]))
        $result[3] = "Unknown";
      if (empty($result[1]))
        $result[1] = "?";
      if (empty($result[2]))
        $result[2] = "<i>soloer</i>";
      if (empty($result[5]))
        $result[5] = "?";
     
 $result[6] = "none";
 
      return $result;
    }



    /*
    make the list of online players
    */
    function online_list($online, $like)
    {
        $profgfx["Meta-Physicist"] = "16308";
        $profgfx["Adventurer"] = "84203";
        $profgfx["Engineer"] = "16252";
        $profgfx["Soldier"] = "16237";
        $profgfx["Keeper"] = "84197";
        $profgfx["Shade"] = "39290";
        $profgfx["Fixer"] = "16300";
        $profgfx["Agent"] = "16186";
        $profgfx["Trader"] = "117993";
        $profgfx["Doctor"] = "44235";
        $profgfx["Enforcer"] = "100998";
        $profgfx["Bureaucrat"] = "16341";
        $profgfx["Martial Artist"] = "16196";
        $profgfx["Nano-Technician"] = "16283";
        $prof_based = "";
        $online_list = "";
        $online_num = 0;

        if (!empty($online))
        {
            foreach ($online as $player)
            {
                $prof_based[$player[3]][(sprintf("%03d", (220 - $player[1])) . $player[0])] = $player;
            }

            ksort($prof_based);

            foreach ($prof_based as $key => $prof)
            {
                if (preg_match("/" . $like . "/i", $key))
                {
                    $online_list .= "\n<img src=tdb://id:GFX_GUI_FRIENDLIST_SPLITTER>\n";
                    $online_list .= "<img src=rdb://" . $profgfx[$key] . ">";
                    $online_list .= " <font color=CCInfoHeader>" . $key . "</font>\n";
                    $online_list .= "<img src=tdb://id:GFX_GUI_FRIENDLIST_SPLITTER>\n";
                    ksort($prof);
                    foreach ($prof as $player)
                    {
                        $admin = "";
                        $online_num++;
                        $main = $this -> bot -> alts -> main($player[4]);
                        $alts = $this -> bot -> alts -> get_alts($main);

                        if ($this -> bot -> admin -> in_group($player[0], "superadmin"))
                        {
                            $admin = " :: <font color=#FF0000>Superadmin</font> ";
                        }
                        else if ($this -> bot -> admin -> in_group($player[0], "admin"))
                        {
                            $admin = " :: <font color=#FF0000>Admin</font> ";
                        }
                        else if ($this -> bot -> admin -> in_group($player[0], "raidleader"))
                        {
                            $admin = " :: <font color=#FF0000>Raidleader</font> ";
                        }



                        if (empty($alts))
                        {
                            $alts = "";
                        }
                        else if ($main == $this -> bot -> aoc -> get_uname($player[4]))
                        {
                            $alts = ":: <a href='chatcmd:///tell <botname> <pre>alts " . $player[0] . "'>Alts</a> ::";
                        }
                        else
                        {
                            $alts = ":: <a href='chatcmd:///tell <botname> <pre>alts " . $player[0] . "'>" . $main . "'s Alts</a> ";
                        }

                        if ($player[6] != "none")
                        {
                            $chatclient = "(" . $player[6] . ") ";
                        }
                        else
                        {
                            $chatclient = "";
                        }

                        $online_list .= "<font color=CCCCTextColor> - L " . $player[1] . " / AL " . $player[5] . " <font color=CCInfoText>" . $player[0] . "</font> (" . $player[2] . ") " . $admin . $chatclient . $alts . "</font>";

                        if($this -> bot -> commands["tell"]["afk"] -> afk[$player[0]])
                        {
                            $online_list .= ":: <font color=#FFFFFF>( AFK )</font>\n";
                        }
                        else
                        {
                            $online_list .= "\n";
                        }
                    }
                }
            }
        }

        return array($online_num, $online_list);
    }



    /*
      Is called if user is using a chat client...
    */
    function chatclient($name, $type)
    {
      if (isset($this -> guild[$name]))
      {
        $this -> guild[$name][5] = $type;
      }
      if (isset($this -> pgroup[$name]))
      {
        $this -> pgroup[$name][5] = $type;
      }
    }
  }
?>

Offline Akarah

  • Contributor
  • *******
  • Posts: 72
  • Karma: +0/-0
    • http://synergyfactor.net/
modified Online.php
« Reply #11 on: December 05, 2005, 11:01:31 am »
updated link in first post, Online.php now includes a way to change modes

/tell <bot> !online mode fancy to enable
/tell <bot> !online mode basic to disable

this doesn't really scale, and will need to be rewritten if i add more modes, since in a couple places i only do if (fancy) {} else {}


but i don't foresee adding any more modes to the one i use anyway ;p

Offline Xenixa

  • Contributor
  • *******
  • Posts: 307
  • Karma: +0/-0
modified Online.php
« Reply #12 on: December 05, 2005, 12:40:42 pm »
Quote from: "Wanuarmi"
made some modifications so the AI level would show if you are not using the whois cache module
...snip


Heheh, I did that long ago. Post on this forum down there somewhere from me in which also I fixed the displaying of AFK. :P
<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky

Offline Khalem

  • BeBot Founder
  • Administrator
  • ********
  • Posts: 1169
  • Karma: +0/-0
    • http://www.ancarim.com
Re: modified Online.php
« Reply #13 on: December 13, 2005, 03:50:25 am »
Added to SVN
BeBot Founder and Fixer Kingpin

Offline Xenixa

  • Contributor
  • *******
  • Posts: 307
  • Karma: +0/-0
Re: modified Online.php
« Reply #14 on: January 13, 2006, 02:32:33 am »
Just minor update to this Module to Keep guest list players from showing in the Members area of the Online list after they are added to the Guest List.

In side this function:
Code: [Select]
    /*
      This gets called if a buddy logs on/off
    */
    function buddy($name, $msg)
    {
      if ($this -> bot -> is_member($name))
      {
        if ($msg == 1)
          $this -> guild[$name] = $this -> whois($name);
         
        else if (isset($this -> guild[$name]))
          unset($this -> guild[$name]);
      }
    }
Change the if ($this -> bot -> is_member($name)) To read:
Code: [Select]
if ($this -> bot -> is_member($name) == 1)
Discovered when fixing auto invites.
<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky

 

* Recent Posts
Com bot module by bitnykk
[November 25, 2024, 05:36:11 pm ]


0.8.x updates for AO by bitnykk
[June 23, 2024, 03:19:47 pm ]


0.8.x updates for AoC by bitnykk
[June 23, 2024, 03:19:44 pm ]


[AoC] special char for items module by bitnykk
[February 09, 2024, 09:41:18 pm ]


BeBot still alive & kicking ! by bitnykk
[December 17, 2023, 12:58:44 am ]

* Who's Online
  • Dot Guests: 316
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.
* Forum Staff
bitnykk admin bitnykk
Administrator
Khalem admin Khalem
Administrator
WeZoN gmod WeZoN
Global Moderator
SimplePortal 2.3.7 © 2008-2024, SimplePortal