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: AoC Raid Lockout Module  (Read 11297 times)

0 Members and 1 Guest are viewing this topic.

Offline Masterdo

  • BeBot Rookie
  • *
  • Posts: 7
  • Karma: +0/-0
AoC Raid Lockout Module
« on: October 22, 2010, 11:19:03 pm »
Hey!

I installed Bebot about a month ago and tried my hands at a few modules so far. This is the first one I have finished enough to share on the boards.

I started the module based on the Example Module and Timeraa from Getrix. If you add useful modifications I'd be interested in seeing them, to help me make my next ones even better :)

Raid Lockouts

Basically you tell the bot that you are locked on a raid instance, and it will remember it until the next lockout resets.

The main way to use it is just to send " !lock " and do the rest with the chat commands suggested in the blob. Like with the timeraa module, you can check anyone's lockouts with "show" or "showall", but you can change the locks on your own current character only.

I am not that pleased with the way the reset is done, basically I check on a 1hour cron if the current time is 3am on tuesday (raid reset time where the guild is located). Making 167 useless checks every week, but I didn't find any other way :( If you have suggestions, let me know.

So that's it, have fun using it if your guild needs that kind of feature!

Code: [Select]
<?php
/*
* lock.php - Raid Lock Module for Age of Conan
* Module by Icara, Gardiens du Lys @Wiccana
*
* v1.0.2 Cleared some code and sql queries. Modified the chat commands to appear only on the toon you are currently on.
* v1.0.1 Added the !lock command doing a showall and modified display to include the chat commands.
* v1.0.0 Release to guild
*/

$version "v1.0.2 - 2010-10-22";

/*
* BeBot - An Anarchy Online & Age of Conan Chat Automaton
* Copyright (C) 2004 Jonas Jax
* Copyright (C) 2005-2007 Thomas Juberg StensÃ¥s, ShadowRealm Creations and the BeBot development team.
*
*/

$thisClass = new ClassName($bot);

/*
The Class itself...
*/
class ClassName extends BaseActiveModule
{
    
/*
    Constructor:
    Hands over a referance to the "Bot" class.
    Defines access control for the commands
    Creates settings for the module
    Defines help for the commands
    */
    
function __construct (&$bot)
    {
        
//Initialize the base module
        
parent::__construct(&$botget_class($this));
        
$this -> bot -> db -> query("CREATE TABLE IF NOT EXISTS " $this -> bot -> db -> define_tablename("lock""true") . " (
            `lock_id` int(11) NOT NULL AUTO_INCREMENT,
            `lock_username` varchar(255) DEFAULT NULL,
            `lock_yak` bool DEFAULT 0,
            `lock_vis` bool DEFAULT 0,
            `lock_kyl` bool DEFAULT 0,
            `lock_w1` bool DEFAULT 0,
            `lock_w2` bool DEFAULT 0,
            `lock_w3` bool DEFAULT 0,
            `lock_t3` bool DEFAULT 0,
            `lock_t4` bool DEFAULT 0,
            PRIMARY KEY (`lock_id`))"
);
              
        
$this->register_event('cron''1hour');
        
$this->register_command('all''lock''MEMBER');
        
$this -> help['description'] = 'Description of the module';
        
$this -> help['command']['lock']="Does a showall for your current toon";
        
$this -> help['command']['lock on <raid>']="Locks your character on <raid> for the week.";
        
$this -> help['command']['lock off <raid>'] = "Manually unlock a character for the raid.";
        
$this -> help['command']['lock showall <name>'] = "Shows all the lockouts for main and alts of <name>. <name> is optionnal, default is your current toon.";
        
$this -> help['command']['lock show <name>'] = "Shows the lockouts for <name>. <name> is optionnal, default is your current toon.";
        
$this -> help['notes'] = "Values for <raid> can be : yak, vis, kyl, w1, w2, w3, t3, t4. Case insensitive, no extra white space.\n Module by Icara of Gardiens du Lys @Wiccana US.";
    }


    
/*
    Unified message handler
    $source: The originating player
    $msg: The actual message, including command prefix and all
    $type: The channel the message arrived from. This can be either "tell", "pgmsg" or "gc"
    */
    
function command_handler($name$msg$origin)
    {
        
//ALWAYS reset the error handler before parsing the commands to prevent stale errors from giving false reports
        
$this->error->reset();

        
$com $this->parse_com($msg);
        switch(
$com['com'])
        {
            case 
'lock':
                return(
$this -> sub_handler($name$com));
                break;
            default:
                return(
"Invalid command");
          }
    }
    
    function 
sub_handler($name$com)
    {
        switch(
$com['sub'])
        {
            case 
'on':
                return(
$this -> lock_on($name$com['args']));
            break;
            case 
'off':
                return(
$this -> lock_off($name$com['args']));
            break;
            case 
'show':
                return(
$this -> lock_show($name$com['args']));
            break;
            case 
'showall':
                return(
$this -> lock_showall($name$com['args']));
            break;
            case 
'':
                return(
$this -> lock_showall($name$com['args']));
            default:
                
$this->bot->send_help($name);
            break;
        }
    }
      
    function 
lock_on($name$args)
    {
        if (empty(
$args)){
            
$this->bot->send_help($name);
            return;
        }
      
        if (
$this -> check_raid($args)) {
            
$raid "lock_$args";
            
$raid mysql_real_escape_string($raid);
            
$name mysql_real_escape_string($name);
            
$sql "UPDATE #___lock SET $raid='1' WHERE lock_username='$name'";
            
$res $this -> bot -> db -> query($sql);
        
            if (!empty(
$res)){
                return 
"$name is now locked for $args.";
            } else {
                
$this->bot->send_help($name);
            return;
            }
        }
    }

    function 
lock_off($name$args)
    {
        if (empty(
$args)){
            
$this->bot->send_help($name);
            return;
        }
        
        if (
$this -> check_raid($args)) {
            
$raid "lock_$args";
            
$raid mysql_real_escape_string($raid);
            
$name mysql_real_escape_string($name);
            
$sql "UPDATE #___lock SET $raid='0' WHERE lock_username='$name'";
            
$res $this -> bot -> db -> query($sql);
          
            if (!empty(
$res)){
                return 
"$name is no longer locked for $args.";
            } else {
                
$this->bot->send_help($name);
                return;
            }
        }
    }

    function 
lock_show($name$args)
    {
        if (!empty(
$args)) {
            
$name mysql_real_escape_string($args);
        } else {
            
$name mysql_real_escape_string($name);
        }
      
        
$output "<Center>##ao_infoheadline##:::: Raid lockout info for $name ::::##end##</Center>".$this->brfix(2);
      
        
$chk $this -> bot -> db -> select("SELECT * FROM #___lock WHERE lock_username='$name'");
        
        if (!empty(
$chk)){
            
$output .= $this -> format($name$chk);
            
$output .= $this -> brfix();
        } else if (
$this -> bot -> core("chat") -> get_uid($name)){            
            
$sql "INSERT INTO #___lock (lock_username, lock_yak, lock_vis, lock_kyl, lock_w1, lock_w2, lock_w3, lock_t3, lock_t4) VALUES ('$name', '0', '0', '0', '0', '0', '0', '0', '0')";
            
$this -> bot -> db -> query($sql);
            
$output .= $this -> format($name, array('id','name''0''0''0''0''0''0''0''0'));
            
$output .= $this -> brfix();
        } else {
            return 
"##error##Character ##highlight##$name##end## does not exist.##end##";
        }
      
        
$output $this -> bot -> core("tools") -> make_blob("Raid lockouts for $name"$output);
        return 
$output;
    }

    function 
lock_showall($user$args)
    {
        if (!empty(
$args)) {
            
$name mysql_real_escape_string($args);
        } else {
            
$name mysql_real_escape_string($user);
        }
      
        
$findmain $this -> bot -> db -> select("SELECT main FROM alts WHERE alts.alt='$name'");
        if (empty(
$findmain)) {
            
$main $name;
        } else {
            
$main current($findmain[0]);
        }
        
        
$output "<Center>##ao_infoheadline##:::: Raid lockout info for $main and alts ::::##end##</Center>".$this->brfix(2);
        
$chk $this -> bot -> db -> select("SELECT * FROM #___lock WHERE lock_username='$main'");
        if (!empty(
$chk)){
            if (
$main == $user){
                
$output .= $this -> format_current($main$chk);
                
$output .= $this -> brfix();
            } else {
                
$output .= $this -> format($main$chk);
                
$output .= $this -> brfix();
            }
        } else if (
$this -> bot -> core("chat") -> get_uid($name)){
            
$sql "INSERT INTO #___lock (lock_username, lock_yak, lock_vis, lock_kyl, lock_w1, lock_w2, lock_w3, lock_t3, lock_t4) VALUES ('$main', '0', '0', '0', '0', '0', '0', '0', '0')";
            
$this -> bot -> db -> query($sql);
            if (
$main == $user){
                
$output .= $this -> format_current($main, array('id','name''0''0''0''0''0''0''0''0'));
                
$output .= $this -> brfix();
            } else {
                
$output .= $this -> format($main, array('id','name''0''0''0''0''0''0''0''0'));
                
$output .= $this -> brfix();
            }          
        } else {
            return 
"##error##Character ##highlight##$name##end## does not exist.##end##";
        }
      
        
$altlist $this -> bot -> db -> select("SELECT alt FROM alts WHERE alts.main='$main'");
      
        if (!empty(
$altlist)) {
            foreach(
$altlist as $charname){
            
                
$chk $this -> bot -> db -> select("SELECT * FROM #___lock WHERE lock_username='{$charname[0]}'");
                if (!empty(
$chk)) {
                    
//foreach ($chk as $aa) {
                    
if ($charname[0] == $user){
                        
$output .= $this -> format_current($charname[0], $chk);
                        
$output .= $this -> brfix();
                    } else {
                        
$output .= $this -> format($charname[0], $chk);
                        
$output .= $this -> brfix();
                    }
                    
//}
                
} else if ($this -> bot -> core("chat") -> get_uid($name)){ 
                    
$sql "INSERT INTO #___lock (lock_username, lock_yak, lock_vis, lock_kyl, lock_w1, lock_w2, lock_w3, lock_t3, lock_t4) VALUES ('{$charname[0]}', '0', '0', '0', '0', '0', '0', '0', '0')";
                    
$this -> bot -> db -> query($sql);
                    
                    if (
$charname[0] == $user){
                        
$output .= $this -> format_current($charname[0], array('id','name''0''0''0''0''0''0''0''0'));
                        
$output .= $this -> brfix();
                    } else {
                        
$output .= $this -> format($charname[0], array('id','name''0''0''0''0''0''0''0''0'));
                        
$output .= $this -> brfix();
                    } 
                }
            }
        }
        
$output $this -> bot -> core("tools") -> make_blob("Raid lockouts for $main"$output);
        return 
$output;
    }

    function 
format_current($name$locked)
    {
        
$output "";
        
$yak        $locked[0][2];
        
$vis        $locked[0][3];
        
$kyl        $locked[0][4];
        
$w1         $locked[0][5];
        
$w2         $locked[0][6];
        
$w3         $locked[0][7];
        
$t3         $locked[0][8];
        
$t4         $locked[0][9];
        
        
$output .= "Lockouts for $name :\n";
        
$output .= "- Yakmar : ".($yak == "##red##Locked##end## ".$this -> bot -> core("tools") -> chatcmd("lock off yak""[Unlock]") : "##lime##OK##end## ".$this -> bot -> core("tools") -> chatcmd("lock on yak""[Lock]")).$this -> brfix();
        
$output .= "- Vistrix : ".($vis == "##red##Locked##end## ".$this -> bot -> core("tools") -> chatcmd("lock off vis""[Unlock]") : "##lime##OK##end## ".$this -> bot -> core("tools") -> chatcmd("lock on vis""[Lock]")).$this -> brfix();
        
$output .= "- Kyllikki : ".($kyl == "##red##Locked##end## ".$this -> bot -> core("tools") -> chatcmd("lock off kyl""[Unlock]") : "##lime##OK##end## ".$this -> bot -> core("tools") -> chatcmd("lock on kyl""[Lock]")).$this -> brfix();
        
$output .= "- Wing 1 : ".($w1 == "##red##Locked##end## ".$this -> bot -> core("tools") -> chatcmd("lock off w1""[Unlock]") : "##lime##OK##end## ".$this -> bot -> core("tools") -> chatcmd("lock on w1""[Lock]")).$this -> brfix();
        
$output .= "- Wing 2 : ".($w2 == "##red##Locked##end## ".$this -> bot -> core("tools") -> chatcmd("lock off w2""[Unlock]") : "##lime##OK##end## ".$this -> bot -> core("tools") -> chatcmd("lock on w2""[Lock]")).$this -> brfix();
        
$output .= "- Wing 3 : ".($w3 == "##red##Locked##end## ".$this -> bot -> core("tools") -> chatcmd("lock off w3""[Unlock]") : "##lime##OK##end## ".$this -> bot -> core("tools") -> chatcmd("lock on w3""[Lock]")).$this -> brfix();
        
$output .= "- Tier 3 : ".($t3 == "##red##Locked##end## ".$this -> bot -> core("tools") -> chatcmd("lock off t3""[Unlock]") : "##lime##OK##end## ".$this -> bot -> core("tools") -> chatcmd("lock on t3""[Lock]")).$this -> brfix();
        
$output .= "- Tier 4 : ".($t4 == "##red##Locked##end## ".$this -> bot -> core("tools") -> chatcmd("lock off t4""[Unlock]") : "##lime##OK##end## ".$this -> bot -> core("tools") -> chatcmd("lock on t4""[Lock]")).$this -> brfix();
        return 
$output;
    }
    
    function 
format($name$locked)
    {
        
$output "";
        
$yak        $locked[0][2];
        
$vis        $locked[0][3];
        
$kyl        $locked[0][4];
        
$w1         $locked[0][5];
        
$w2         $locked[0][6];
        
$w3         $locked[0][7];
        
$t3         $locked[0][8];
        
$t4         $locked[0][9];
        
        
$output .= "Lockouts for $name :\n";
        
$output .= "- Yakmar : ".($yak == "##red##Locked##end##" "##lime##OK##end##").$this -> brfix();
        
$output .= "- Vistrix : ".($vis == "##red##Locked##end##" "##lime##OK##end##").$this -> brfix();
        
$output .= "- Kyllikki : ".($kyl == "##red##Locked##end##" "##lime##OK##end##").$this -> brfix();
        
$output .= "- Wing 1 : ".($w1 == "##red##Locked##end##" "##lime##OK##end##").$this -> brfix();
        
$output .= "- Wing 2 : ".($w2 == "##red##Locked##end##" "##lime##OK##end##").$this -> brfix();
        
$output .= "- Wing 3 : ".($w3 == "##red##Locked##end##" "##lime##OK##end##").$this -> brfix();
        
$output .= "- Tier 3 : ".($t3 == "##red##Locked##end##" "##lime##OK##end##").$this -> brfix();
        
$output .= "- Tier 4 : ".($t4 == "##red##Locked##end##" "##lime##OK##end##").$this -> brfix();
        return 
$output;
    }

    function 
brfix($count=1
    {
        if (
$count == 2) { $br "<b></b><br><b></b><br>";}
        elseif (
$count == 3) { $br "<b></b><br><b></b><br><b></b><br>"; }
        else { 
$br "<b></b><br>"; }
        return 
$br;
    }
    
    function 
check_raid($raid)
    {
        
$arr = array('yak''vis''kyl''w1''w2''w3''t3''t4');
      
        if (
in_array(strtolower($raid), $arr)){
            return 
true;
        }
        return 
false;
    }
    
    function 
cron($interval)
    {
        if(
date("l") == "Tuesday" && date("G") == 3){
            
$sql "UPDATE #___lock SET lock_yak='0', lock_vis='0', lock_kyl='0', lock_w1='0', lock_w2='0', lock_w3='0', lock_t3='0', lock_t4='0'";
            
$this -> bot -> db -> query($sql);
        }
    }
}
?>

Offline Yite

  • BeBot Apprentice
  • ***
  • Posts: 152
  • Karma: +0/-0
    • Niflheim - Crom
Re: AoC Raid Lockout Module
« Reply #1 on: October 23, 2010, 03:38:24 pm »
Getrix also wrote the !bound module http://bebot.link/generic-custom-modules/instance-bound-tracker/ which does the same.
-Yite [Crom]

Offline Masterdo

  • BeBot Rookie
  • *
  • Posts: 7
  • Karma: +0/-0
Re: AoC Raid Lockout Module
« Reply #2 on: October 24, 2010, 08:56:33 am »
Nice, didn't know that part of the forum so far. I'll check it, thanks.

Offline Runemy

  • BeBot Apprentice
  • ***
  • Posts: 97
  • Karma: +0/-0
    • Exalted [Age of Conan guild - Aquilonia EU]
Re: AoC Raid Lockout Module
« Reply #3 on: October 24, 2010, 06:58:50 pm »
Thanks for this one mate!

Getrix already had made a module for this but yours seem to have the option to check all alts at once with showall, so I'll be giving yours a go. (All those alts.. ^^)

I'm also sure that Getrix wouldn't mind you looking into his code for the reset functionality if it's troubling you.
Wood of Exalted
Age of Conan
Aquilonia - EU

Offline Runemy

  • BeBot Apprentice
  • ***
  • Posts: 97
  • Karma: +0/-0
    • Exalted [Age of Conan guild - Aquilonia EU]
Re: AoC Raid Lockout Module
« Reply #4 on: October 25, 2010, 01:33:06 pm »
I like the interface, but this one is not working at our end.
I get a "/tell Ourbot !help" when I click a Lock link in the interface so it's not registering my locks.
Wood of Exalted
Age of Conan
Aquilonia - EU

Offline Getrix

  • Contributor
  • *******
  • Posts: 509
  • Karma: +0/-0
Re: AoC Raid Lockout Module
« Reply #5 on: October 25, 2010, 04:30:08 pm »
Did a fast overlook on the code and it seems good start. Not tried it as i allready got my own !bound script.

If i should give you some advice i would say try to stay away from to much hardcoding. If there is new bosses added to game, you need to do alot more coding then my version where you just add the boss to a row in MySQL.
You can take a look on my script and use it as base to add the functions ppl are missing that your script has. I wouldnt mind if you redistribute it with modifications requested as long im credited for my part ;)
Success is not final, failure is not fatal: it is the courage to continue that counts.
- Sorry, i dont have time to reply question on PM. Make a topic.

Offline Masterdo

  • BeBot Rookie
  • *
  • Posts: 7
  • Karma: +0/-0
Re: AoC Raid Lockout Module
« Reply #6 on: October 26, 2010, 01:39:35 pm »
Did a fast overlook on the code and it seems good start. Not tried it as i allready got my own !bound script.

If i should give you some advice i would say try to stay away from to much hardcoding. If there is new bosses added to game, you need to do alot more coding then my version where you just add the boss to a row in MySQL.
You can take a look on my script and use it as base to add the functions ppl are missing that your script has. I wouldnt mind if you redistribute it with modifications requested as long im credited for my part ;)

Nice, noted for my next modules, maybe I'll try to modify this one too. A good start would probably be to add admin commands to add and delete bosses, then check other features to be more flexible with that in mind. I guess that type of thinking comes with experience, thanks for sharing!

I like the interface, but this one is not working at our end.
I get a "/tell Ourbot !help" when I click a Lock link in the interface so it's not registering my locks.

I'm surprised it doesn't work on your end... Since we are just past the reset time, I'll try to remove my module completely and check with another new install. On your end, can you check if sending manual commands (like !lock on w2) works directly? Clicking the links should basically send those tells to your bot, but it has to be able to receive them manually first I guess. The cause for this could be my error to hardcode too many things. For example, in the tells sent I assumed that the module was named "lock" and sent the tell as such, instead of coding a variable for the module's name. Sorry :(

I know our altoholics could not live without this module now that it's installed, I hope I can manage to help yours as well  :)
« Last Edit: October 26, 2010, 01:43:53 pm by Masterdo »

Offline Runemy

  • BeBot Apprentice
  • ***
  • Posts: 97
  • Karma: +0/-0
    • Exalted [Age of Conan guild - Aquilonia EU]
Re: AoC Raid Lockout Module
« Reply #7 on: October 26, 2010, 04:01:05 pm »
[15:57] To [Exalted]: !lock
[15:57] [Exalted]: Raid lockouts for Wood
[15:57] To [Exalted]: !lock on w3 <-- Clicked through interface
[15:57] [Exalted]: /tell Exalted !help
[15:57] To [Exalted]: !lock on w3 <-- Manual type
[15:57] [Exalted]: /tell Exalted !help

So not working unfortunately :)
Wood of Exalted
Age of Conan
Aquilonia - EU

Offline Runemy

  • BeBot Apprentice
  • ***
  • Posts: 97
  • Karma: +0/-0
    • Exalted [Age of Conan guild - Aquilonia EU]
Re: AoC Raid Lockout Module
« Reply #8 on: November 02, 2010, 04:25:12 pm »
Found out that your sql wont create the lock table in our database. Will work around it when time permits and see if it works then.
Wood of Exalted
Age of Conan
Aquilonia - EU

 

* 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: 257
  • 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