Hey guys, need some help reprogramming the source code of a bot. The bot works by using various modules and I'm reprogramming the function called "FLATROLL". Flatroll is a function that randomly selects the winner of an item that the user has previously added to. What I want to do is reprogram it so I, "Bobby", am always the winner when I add to that item. . The problem that I'm having is that the $winner is stored in an array. So if I change $winner to "Bobby" it makes ALL the winners "Bobby", not just the item I added to. This is problematic. Any help would be appreciated.
Heres the Code for FLATROLL :
Code:
global $loot;
global $loot_winners;
global $residual;

if (preg_match("/^flatroll$/i", $message)) {
    //Check if a loot list exits
      if (!is_array($loot)) {
        $msg = "There is nothing to roll atm.";
        $chatBot->send($msg, $sendto);
        return;
    }
    
    srand( ((int)((double)microtime()*1000003)) ); // get a good seed
      
      $list = "<header> :::::: Win List :::::: <end>\n\n";
      //Roll the loot
    $resnum = 1;
    forEach ($loot as $key => $item) {
            $list .= "Item: <orange>{$item["name"]}<end>\n";
            $list .= "Winner(s): ";
        $users = count($item["users"]);
         if ($users == 0) {
             $list .= "<highlight>None added.<end>\n\n";
            $residual[$resnum]["name"] = $item["name"];
            $residual[$resnum]["icon"] = $item["icon"];
            $residual[$resnum]["linky"] = $item["linky"];
            $residual[$resnum]["multiloot"] = $item["multiloot"];
            $resnum++;
         } else {
            if ($item["multiloot"] > 1) {
                if ($item["multiloot"] > sizeof($item["users"])) {
                    $arrolnum = sizeof($item["users"]);
                } else {
                    $arrolnum = $item["multiloot"];
                }

                for ($i = 0; $i < $arrolnum; $i++) {
                    $winner = array_rand($item["users"], 1);
                    unset($item["users"][$winner]);
                    $list .= "<red>$winner<end> ";
                }

                if ($arrolnum < $item["multiloot"]) {
                    $newmultiloot = $item["multiloot"]-$arrolnum;
                    $residual[$resnum]["name"] = $item["name"];
                    $residual[$resnum]["icon"] = $item["icon"];
                    $residual[$resnum]["linky"] = $item["linky"];
                    $residual[$resnum]["multiloot"] = $newmultiloot;
                    $resnum++;
                }
            } else {
                $winner = array_rand($item["users"], 1);
                $list .= "<red>$winner<end>";
            }
            $list .= "\n\n";
        }
    }
    //Reset loot
    $winner = "";
    $arrolnum = "";
    $loot = "";
    //Show winner list
    $msg = Text::make_blob("Winner List", $list);
    if (is_array($residual)) {
        $rerollmsg = " (There are item(s) left to be rolled. To re-add, type <symbol>reroll)";
    } else {
        $rerollmsg = "";
    }

    $chatBot->send($msg.$rerollmsg, 'priv');

    if ($type != 'priv') {
        $chatBot->send($msg.$rerollmsg, $sendto);
    }
} else {
    $syntax_error = true;
}

?>
Here is the code for Adding a player to item slot in the roll
Code:
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;
}

?>
thanks for the help!