Hello,
I would like to make map vote to game with php!
Vote should go like this
• Team B removes one of the 7 maps;
• Team A removes one of the 6 remaining maps;
• Team B removes one of the 5 remaining maps;
• Team A removes one of the 4 remaining maps;
• Team B removes one of the 3 remaining maps;
• Team A picks the map to be played on;
The last map remaining will be discarded.
Problem is that i don't know how i can remove map from array when its voted like if somebody uses "!map test" that the map would be removed and last map will be used
$maps = $array = array(test1, "test2", test3, "test4", "test5");
print_r(array_count_values($array));
or how could i remove from list?
$maps = \folder\Config\Config::getInstance()->getMaps();
PHP Vote
Moderator: General Moderators
Re: PHP Vote
Forgot this:
Code: Select all
$text = trim($message->getText());
if (preg_match('/\!map (?<mapname>.*)/i', $text, $preg)) {
if (!$this->mapIsEngaged && (( $this->getStatus() == self::STATUS_WU_KNIFE && $this->config_kniferound ) || ( $this->getStatus() == self::STATUS_WU_1_SIDE && !$this->config_kniferound ))) {
$this->addLog($message->getUserName() . " (" . $message->getUserTeam() . ") removed" . $preg['mapname']);
Logger::log($message->getUserName() . " (" . $message->getUserTeam() . ") removed " . $preg['mapname']);
if ($message->getUserTeam() == "CT") {
$team = ($this->side['team_a'] == "ct") ? $this->teamAName : $this->teamBName;
$maps = $array = array(test1, "test2", test3, "test4", "test5");
print_r(array_count_values($array));Re: PHP Vote
You do know that nobody here knows what you're talking about, right? No idea what these maps are or where this code is coming from or how it's used...
Assuming this is running like a regular PHP script, you have to store the maps somewhere so that the next time PHP runs it can look up the current set of maps and act accordingly. Though your use of "!map" suggests an IRC bot, in which case this isn't a regular PHP script and the $maps stays in memory and you just need to make sure that you're passing that variable around your application so it doesn't get lost during execution.
Assuming this is running like a regular PHP script, you have to store the maps somewhere so that the next time PHP runs it can look up the current set of maps and act accordingly. Though your use of "!map" suggests an IRC bot, in which case this isn't a regular PHP script and the $maps stays in memory and you just need to make sure that you're passing that variable around your application so it doesn't get lost during execution.
Re: PHP Vote
Okey so the game is counter-strike global offensive and by maps i mean like de_dust2 or de_nuke etc
The softare is called eBOT https://github.com/deStrO/eBot-CSGO
I hope this helps.
The softare is called eBOT https://github.com/deStrO/eBot-CSGO
I hope this helps.
Re: PHP Vote
The answer depends on whether PHP is staying active or whether there's a new request every time something happens. Do you know the answer to that?
If not, set a global variable somewhere like
and put that in a place you know only executes once. Like a bootloader or init script. Then check the value of
at some point in your code to see if that value ever changes. Hopefully not.
If not, set a global variable somewhere like
Code: Select all
global $asdfg; $asdfg = time();Code: Select all
$GLOBALS["asdfg"]