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

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

Author Topic: Bane Module  (Read 1606 times)

0 Members and 1 Guest are viewing this topic.

Offline Jiheld

  • BeBot User
  • **
  • Posts: 53
  • Karma: +0/-0
Bane Module
« on: December 09, 2009, 11:16:43 pm »
Hi guyz,

I changed the raid module abit to a Bane module:

Code: [Select]
<?php
/*
* Bane.php - Announces the Banelist.
*
* 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.
*
* Developed by:
* - Alreadythere (RK2)
* - Blondengy (RK1)
* - Blueeagl3 (RK1)
* - Glarawyn (RK1)
* - Khalem (RK1)
* - Naturalistic (RK1)
* - Temar (RK1)
*
* See Credits file for all aknowledgements.
*
*  This program is free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; version 2 of the License only.
*
*  This program is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  You should have received a copy of the GNU General Public License
*  along with this program; if not, write to the Free Software
*  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
*  USA
*
* Revision: $Id: bane.php 2008-08-05 Jiheld $
* Thanks to alreadythere for the raid.php 
*/


$bane = new Bane($bot);

/*
The Class itself...
*/
class Bane extends BaseActiveModule
{
var $bane;
var $user;
var $announce;
var $start;




function __construct(&$bot)
{
parent::__construct(&$botget_class($this));

$this -> bane false;
$this -> user = array();
$this -> announce 0;

$this -> register_command("tell""c""ANONYMOUS");
$this -> register_command("all""Bane""ANONYMOUS");
        
$this -> register_event("pgleave");

        
$this -> bot -> core("settings") -> create("Bane""Command""LEADER""Who should be able to access the higher level raid commands (all commands     except join/leave)?""ADMIN;LEADER;MEMBER;GUEST;ANONYMOUS");


$this -> help['description'] = 'Module to manage and announce the Banelist.';
$this -> help['command']['bane start <description>']="Starts the Banelist with optional description.";
$this -> help['command']['bane end'] = "Ends the Banelist.";
$this -> help['command']['bane join'] = "Join the active Banelist.";
$this -> help['command']['bane leave'] = "Leave the active Banelist.";

$this -> help['command']['bane add <name>'] = "Adds player <name> to the current banelist";
$this -> help['command']['bane kick <name>'] = "Kicks player <name> from the current banelist.";
$this -> help['command']['bane check'] = "Generates a list of active banelist members with assist links in a window for attendance checking.";

}


function command_handler($name$msg$type)
{
$var explode (" "$msg2);

switch($var[0])
{
case 'c':
$this -> bane_command($name$var[1]);
Break;
case 'bane':
$var explode(" "$msg3);
switch($var[1])
{
case 'start':
$this -> bot -> send_output($name$this -> start_bane($name$var[2]), $type);
Break;
case 'stop':
case 'end':
$this -> bot -> send_output($name$this -> end_bane($name), $type);
Break;
case 'join':
$this -> bot -> send_output($name$this -> join_bane($name), $type);
Break;
case 'leave':
$this -> bot -> send_output($name$this -> leave_bane($name), $type);
Break;
case 'kick':
$this -> bot -> send_output($name$this -> kick_bane($name$var[2]), $type);
Break;
case 'check':
$this -> bot -> send_output($name$this -> check_bane($name), $type);
Break;

case 'add':
$this -> bot -> send_output($name$this -> addto_bane($name$var[2]), $type);
Break;

Default:
$this -> bot -> send_help($name"bane");
}
Break;
Default:
$this -> bot -> send_output($name"##error##Error : Broken plugin, bane.php recieved unhandled command: ".$var[0]."##end##"$type);
}
}



/*
This gets called if someone leaves the privgroup
*/
function pgleave($name)
{
if ($this -> bot -> core("settings") -> get("Bane""Remonleave"))
{
if (isset($this -> user[$name]))
{
unset($this -> user[$name]);
return "##highlight##$name##end## was removed from the Banelist.";

}
}
}

/*
Starts a Banelist
*/
function start_bane($name$desc)
{
if ($this -> bot -> core("security") -> check_access($name$this -> bot -> core("settings") -> get('Bane''Command')))
{
if (!$this -> bane)
{
$this -> description $desc;
$this -> bane true;
$this -> start time();
$this -> bot -> send_output($name"##highlight##$name##end## has started the Banelist :: " $this -> clickjoin(), "both");
$this -> pause(TRUE);
$this -> register_event("cron""1min");
return "Banelist started.";
}
else
return "Banelist already running.";
}
else
return "You must be a " $this -> bot -> core("settings") -> get('Bane''Command') . " to start a Banelist";
}



/*
Ends the banelist
*/
function end_bane($name)
{
if ($this -> bot -> core("security") -> check_access($name$this -> bot -> core("settings") -> get('Bane''Command')))
{
if ($this -> bane)
{
$this -> bane false;
$this -> user = array();
$this -> announce 0;
$this -> unregister_event("cron""1min");
$this -> bot -> send_output($name"##highlight##$name##end## has stopped the Banelist.""both");

$this -> locked false;
Return "Banelist stopped.";
}
else
return "No banelist running.";
}
else
return "You must be a " $this -> bot -> core("settings") -> get('Bane''Command') . " to do this";
}

/*
Issues a bane command
*/
function bane_command($name$command)
{
if ($this -> bot -> core("security") -> check_access($name$this -> bot -> core("settings") -> get('Bane''Command')))
{
$msg $this -> bot -> core("settings") -> get('Bane''Cformat');
$msg str_replace("##name##"$name$msg);
$msg str_replace("##msg##"$command$msg);
$this -> bot -> send_output($name$msg"both");
}
else
$this -> bot -> send_tell($name"You must be a ".$this -> bot -> core("settings") -> get('Bane''Command')." to do this");
}



/*
Adds a player to the banelist
*/
function addto_bane($name$player)
{
$player ucfirst(strtolower($player));
if ($this -> bot -> core("security") -> check_access($name$this -> bot -> core("settings") -> get('Bane''Command')))
{
if (!$this -> bane)
return "No Banelist in progress";
else if (isset($this -> user[$player]))
return $player." is already on the banelist";
$uid $this -> bot -> core("chat") -> get_uid($player);
if (!$uid)
return "Player ##highlight##$player##end## does not exist.";
else
{


//Update last_banelist
$query "UPDATE #___users SET last_bane = " time() . " WHERE nickname = '$player'";
$this -> bot -> db -> query($query);

$this -> user[$player] = $uid;
$this -> bot -> send_tell($player"##highlight##$name##end## added you to the Banelist.");
$this -> bot -> send_output("""##highlight##$player##end## was ##highlight##added##end## to the Banelist by ##highlight##$name##end## :: " $this -> clickjoin(), "both");
return "##highlight##$player##end## has been ##highlight##added##end## to the Banelist";
}
}
}


/*
Joins the banelist
*/
function join_bane($name)
{
if (isset($this -> user[$name]))
{
return "You are already on the banelist";
}
else if ($this -> locked)
{
return "The banelist status is currently ##highlight##locked##end##.";
}
else if ($this -> bane)
{


//Update last_bane
$query "UPDATE #___users SET last_bane = " time() . " WHERE nickname = '$name'";
$this -> bot -> db -> query($query);
$this -> user[$name] = $this -> bot -> core("chat") -> get_uid($name);
$this -> bot -> send_output("""##highlight##$name##end## has ##highlight##joined##end## the Banelist :: " $this -> clickjoin(), "both");
return "you have joined the Banelist";
}
else
return "No Banelist in progress";
}



/*
Leaves the banelist
*/
function leave_bane($name)
{
if (!isset($this -> user[$name]))
return "You are not on the Banelist.";
else
{
unset($this -> user[$name]);
$this -> bot -> send_tell($name"You have ##highlight##left##end## the Banelist."1);
return "##highlight##$name##end## has ##highlight##left##end## the Banelist :: " $this -> clickjoin();
}
}



/*
Kicks someone from the banelist
*/
function kick_bane($name$who)
{
if ($this -> bot -> core("security") -> check_access($name$this -> bot -> core("settings") -> get('Bane''Command')))
{
if (!isset($this -> user[$who]))
return "##highlight##$who##end## is not on the Banelist.";
else
{
unset($this -> user[$who]);

$this -> bot -> send_tell($who"##highlight##$name##end## kicked you from the Banelist.");
return "##highlight##$who##end## was kicked from the Banelist.";
}
}
else
return "You must be a " $this -> bot -> core("settings") -> get('Bane''Command') . " to do this";
}




/*
Checks memebers on the banelist
*/
function check_bane($name)
{
if ($this -> bot -> core("security") -> check_access($name$this -> bot -> core("settings") -> get('Bane''Command')))
{
$players array_keys($this -> user);
sort($players);

$inside "##blob_title##:::: People on the Banelist ::::##end##\n\n";

if (!empty($players))
{
if($this -> bot -> game == "ao")
{
foreach ($players as $player)
{
if (!empty($assist))
$assist .= " \\n /assist $player";
else
$assist "/assist $player";
}

$inside .= "<a href='chatcmd://$assist'>Check all banelist members</a>\n\n";
}
foreach ($players as $player)
{
$inside .= $player " [".$this -> bot -> core("tools") -> chatcmd(
"bane kick ".$player"Kick")."]\n";
}
}
else
$inside .= "There are no members of this banelist.";

return "Players on the Banelist :: " .
$this -> bot -> core("tools") -> make_blob("click to view"$inside);
}
else
return "You must be a " $this -> bot -> core("settings") -> get('Bane''Command') . " to do this";
}


/*
Make click to join blob
*/
function clickjoin()
{
$inside "##blob_title##:::: Join/Leave Banelist ::::##end##\n\n";
if($this -> description && !empty($this -> description))
$inside .= "Description:\n     ".$this -> description;
$inside .= "\n\n - ".$this -> bot -> core("tools") -> chatcmd("bane join""Join the Banelist")."\n";
$inside .= " - ".$this -> bot -> core("tools") -> chatcmd("bane leave""Leave the Banelist")."\n";

return $this -> bot -> core("tools") -> make_blob("click to join"$inside);
}



}
?>

But the names are comming in alphabetically order. Is there a way we can move players on the list, so people know who is number one, two ect.

thnx

Jih.

Offline snyder

  • BeBot User
  • **
  • Posts: 34
  • Karma: +0/-0
  • CRO guild
    • CRO Guild @ Crom
Re: Bane Module
« Reply #1 on: December 10, 2009, 12:44:20 pm »
well, as i see here bane users are added like keys to array and becouse of that they are sorted by their name, try to add em as value and put number in key of that user.

and you dont need to use db here, just put em all in simple array like:
Code: [Select]
$users[ $bane_order ] = $name;
then you need to write some more code to switch players places

 

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


0.8.x updates for AoC by bitnykk
[January 30, 2024, 11:16:08 pm]


0.8.x updates for AO by bitnykk
[January 30, 2024, 11:15:37 pm]


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


Bebot and Rasberry by bitnykk
[November 29, 2023, 11:04:14 pm]

* Who's Online
  • Dot Guests: 723
  • 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