1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
|
global $loot;
global $raidlist;
global $raidloot;
if (preg_match("/^add$/i", $message)) {
//Check if a flat(multiroll) or pts roll is going on
if ($chatBot->vars["raid_pts"] > 0) {
$msg = "This raid is pts rolled. Use instead bid.";
$chatBot->send($msg, $sender);
return;
}
if (!isset($raidlist[$sender])) {
$msg = "You need to be on the raidlist to be able to add to an item!";
$chatBot->send($msg, $sender);
return;
}
$index = $chatBot->vars["raid_loot_index"];
$cat = $chatBot->vars["raid_loot_cat"];
//Check if minlvl is set and if the player is higher then it
if (isset($raidloot[$cat][$index]["minlvl"])) {
$whois = Player::get_by_name($sender);
if ($whois === null || $whois->level < $raidloot[$cat][$index]["minlvl"]) {
$msg = "You need to be at least lvl<highlight>{$raidloot[$cat][$index]["minlvl"]}<end> to join this roll.";
$chatBot->send($msg, $sender);
return;
}
}
//Check if the player is already added
if ($raidloot[$cat][$index]["users"][$sender]) {
$msg = "You are already assigned to this roll.";
$chatBot->send($msg, $sender);
return;
}
//Add the player to the choosen slot
$raidloot[$cat][$index]["users"][$sender] = true;
$msg = "You have been assigned to the roll of <highlight>\"{$raidloot[$cat][$index]["name"]}\"<end>.";
$chatBot->send($msg, $sender);
$msg = "<highlight>$sender<end> has been added for this roll.";
$chatBot->send($msg, 'priv');
} else if (preg_match("/^add ([0-9]+)$/i", $message, $arr)) {
$slot = $arr[1];
$found = false;
//Raid with flatrolls
if ($chatBot->vars["raid_status"] != "" && $chatBot->vars["raid_pts"] == 0) {
$slot = $arr[1];
if (!isset($raidlist[$sender])) {
$msg = "You need to be on the raidlist to be able to add to an item!";
$chatBot->send($msg, $sender);
return;
}
//Check if the slot exists
$found = false;
forEach ($raidloot as $key => $value) {
forEach ($value as $key1 => $value1) {
if ($key1 == $slot) {
$found = true;
$cat = $key;
$index = $key1;
break;
}
}
if ($found) {
break;
}
}
if (!$found) {
$msg = "The slot you trying to add in doesn't exist!";
$chatBot->send($msg, $sender);
return;
}
//Check if minlvl is set and if the player is higher then it
if (isset($raidloot[$cat][$index]["minlvl"])) {
$whois = Player::get_by_name($sender);
if ($whois === null || $whois->level < $raidloot[$cat][$index]["minlvl"]) {
$msg = "You need to be at least lvl<highlight>{$raidloot[$cat][$index]["minlvl"]}<end> to join this roll.";
$chatBot->send($msg, $sender);
return;
}
}
//Remove the player from other slots if set
$found = false;
forEach ($raidloot as $key => $value) {
forEach ($value as $key1 => $value1) {
if ($raidloot[$key][$key1]["users"][$sender] == true) {
unset($raidloot[$key][$key1]["users"][$sender]);
$found = true;
break;
}
}
if ($found) {
break;
}
}
//Add the player to the choosen slot
$raidloot[$cat][$index]["users"][$sender] = true;
if ($found == false) {
$msg = "$sender has added to <highlight>\"{$raidloot[$cat][$index]["name"]}\"<end>.";
} else {
$msg = "$sender has moved to <highlight>\"{$raidloot[$cat][$index]["name"]}\"<end>.";
}
$chatBot->send($msg, 'priv');
} else if (count($loot) > 0) {
$slot = $arr[1];
//Check if the slot exists
if (!isset($loot[$slot])) {
$msg = "The slot you trying to add in doesn't exist.";
$chatBot->send($msg, $sender);
return;
}
//Check if minlvl is set and if the player is higher then it
if (isset($loot[$slot]["minlvl"])) {
$whois = Player::get_by_name($sender);
if ($whois === null || $whois->lvl < $loot[$slot]["minlvl"]) {
$msg = "You need to be at least lvl<highlight>{$loot[$slot]["minlvl"]}<end> to join this roll.";
$chatBot->send($msg, $sender);
return;
}
}
//Remove the player from other slots if set
$found = false;
forEach ($loot as $key => $item) {
if ($loot[$key]["users"][$sender] == true) {
unset($loot[$key]["users"][$sender]);
$found = true;
}
}
//Add the player to the choosen slot
$loot[$slot]["users"][$sender] = true;
if ($found == false) {
$msg = "$sender has added to <highlight>\"{$loot[$slot]["name"]}\"<end>.";
} else {
$msg = "$sender has moved to <highlight>\"{$loot[$slot]["name"]}\"<end>.";
}
$chatBot->send($msg, 'priv');
} else {
$chatBot->send("No list available where you can add in.", $sender);
}
} else {
$syntax_error = true;
}
?>
|