From another PHP based Bot (ragebot)
<?php
global $guildmates,$guildmains,$guildlookup,$PluginConfig;
/* Already loaded guildmates? If not we currently may logon and receive the status of every buddy */
if ($guildmates[0]&&$guildmates[$args["name"]]) {
/*Do we have a state-change caused by a refresh?*/
if ($guildlookup[$args["name"]]) {
/*do we have a levelup?*/
if ($args["level"]!=$guildlookup[$args["name"]]["level"]) {
say("Guildupdate :: Levelup for guildmate ".$args["name"]." from ".$args["level"]." to ".$guildlookup[$args["name"]]["level"],1);
if ($PluginConfig["guildupdate"]["gratz"]) {
include($currentplugin."/gratz.php");
send_guild_channel_message(colortext(":: ".$msg." ::"));
}
global $db, $dbconfig;
$stmt = $db->prepare('UPDATE '.$dbconfig['dbprefix'].'toons SET toon_level = :toon_level WHERE toon_name = :toon_name;');
$stmt->bindParam(':toon_name', $args["name"]);
$stmt->bindParam(':toon_level', $args["level"]);
$stmt->execute();
}
/*do we have a playfieldchange?*/
if ($args["playfield"]!=$guildlookup[$args["name"]]["playfield"]) {
say("Guildupdate :: Playfieldchange for guildmate ".$args["name"]." from ".$args["playfield"]." to ".$guildlookup[$args["name"]]["playfield"],1);
}
/*unset lookup*/
unset($guildlookup[$args["name"]]);
if (!$msg) say("Guildupdate :: Statuschange ignored",1);
} else {
say("Guildupdate :: lookup flag not set",1);
}
} else {
say("Guildupdate :: Buddystatus of a none-guildmate suppressed",1);
}
?>
and the grats portion of it
<?php
/**** Idea: Creator
***** Strings: Creator
*****/
if ($level==80){
switch (rand(1,2)) {
case 1:
$msg="Big gratz ".$args["name"]."! You reached the end of the line, you can finally log off and quit aoc.";
break;
case 2:
$msg="Big gratz ".$args["name"]."! Game Over!";
break;
}
} else {
switch (rand(1,4)) {
case 1:
$msg="Hey ".$args["name"]."! Why don't you come over and apprentice me for a change?";
break;
case 2:
$msg="Come on save some dings for the rest ".$args["name"]."!";
break;
case 3:
$msg="Enough with the dingin ".$args["name"].".. you are making me feel low enough!";
break;
case 4:
$msg="Gratz to level ".$args["level"]." ".$args["name"]."!";
break;
}
}
?>
60% of the time, it works every time.