Buvian Posted November 16, 2013 Share Posted November 16, 2013 First of let me start by saying I have not a clue about PHP and coding in general. I'm running a PHP/MySQL Chat bot for a game I play and I have a module that I'm having issues with. The script is for recruiting people. This is the error it keeps throwing. Fatal error: Can't use method return value in write context in /home/guild/service48/modules/aoc/Ginfo.php on line 19 This is the PHP code. Any help would be greatly appreciated and I'm sorry if I posting in wrong section. I would ask the developers, but they do not monitor the project often. <?php /* * GuildInfo * This module helps people with guild recruitment. * * */ $GuildInfo = new GuildInfo($bot); class GuildInfo extends BaseActiveModule { function __construct(&$bot) { parent::__construct(&$bot, get_class($this)); $this -> register_command('all', 'ginfo', "ANONYMOUS"); $this -> bot -> core("colors") -> define_scheme("GI", "highlight", "yellow"); $this -> bot -> core("colors") -> define_scheme("GI", "normal", "white"); $this -> bot -> core("colors") -> define_scheme("GI", "info", "lightgreen"); $this -> bot -> core("colors") -> define_scheme("GI", "red", "red"); $this -> bot -> core("colors") -> define_scheme("GI", "Silver", "Silver"); $this -> help['description'] = 'Helps with guild recruitment.'; $this -> help['command']['ginfo']="Displays guild's info tab."; $this -> help['command']['ginfo members']="Displays a list of members in the guild."; $this -> help['command']['ginfo classes']="Displays a list of classes in the guild."; $this -> help['command']['grecruit']="Displays a recruitment link in OOC (usable only with priveleges)."; } function command_handler($name, $msg, $origin) { if (preg_match('/^ginfo/i', $msg, $info)) { $words = trim(substr($msg, strlen('ginfo'))); if ($words == "members") { return $this -> memberslist(); } else if($words == "classes") { return $this -> memberscount(); } else { return $this -> info(); } } else if(preg_match('/^grecruit/i', $msg, $info)) { //return "Command under development"; $msg = $this -> recruit(); $channel = $this -> bot -> core("chat") -> lookup_group("Playfield"); return "Currently under development: ".$channel; } else { $this -> bot -> send_help($name); } } /* Guilds Info */ function info() { $txt.= "##GI_red##GUILD NAME HERE##end##\n\n"; $txt.= "##end##\n"; $txt.= "##highlight##Leader:##end##\n\n"; $online = $this -> officercheck("GUILD LEADER NAME"); $online_state = $online[0]; $txt.= "##GI_highlight##".$online_state['content'] . $online[1]; $txt.= "##end##\n"; $txt.= "##end##\n"; $txt.= "##highlight##Officers:##end##\n"; $online = $this -> officercheck("OFFICER 1"); $online_state = $online[0]; $txt.= "##GI_highlight##".$online_state['content'] . $online[1]; $txt.= "##end##\n"; $online = $this -> officercheck("OFFICER 2"); $online_state = $online[0]; $txt.= "##GI_highlight##".$online_state['content'] . $online[1]; $txt.= "##end##\n"; $online = $this -> officercheck("OFFICER 3"); $online_state = $online[0]; $txt.= "##GI_highlight##".$online_state['content'] . $online[1]; $txt.= "##end##\n"; $online = $this -> officercheck("OFFICER 4"); $online_state = $online[0]; $txt.= "##GI_highlight##".$online_state['content'] . $online[1]; $txt.= "##end##\n"; $online = $this -> officercheck("OFFICER 5"); $online_state = $online[0]; $txt.= "##GI_highlight##".$online_state['content'] . $online[1]; $txt.= "##end##\n"; $online = $this -> officercheck("OFFICER 6"); $online_state = $online[0]; $txt.= "##GI_highlight##".$online_state['content'] . $online[1]; $txt.= "##end##\n"; $txt.= "##end##\n"; $txt.= "##GI_red##Website:##end## ##GI_info## WWW. YOUR WEBSITE HERE .COM##end##\n\n"; $txt.= "##GI_red##City:##end## ##Silver##WHAT YOUVE BUILT##end##\n\n"; $txt.= "##GI_red##Raids:##end## ##Silver##WHAT YOUVE KILLED##end##\n\n"; $txt.= "##GI_red##Recruitment:##end## ##Silver##SPECIAL REQUIREMENTS??.##end##\n\n"; $txt.= "##end##\n"; $txt.= "##highlight##Assassin:##end## ##Red##[Closed]##end##\n"; $txt.= "##highlight##Barbarian:##end## ##Red## [Closed]##end##\n"; $txt.= "##highlight##Bear Shaman:##end## ##Red##[Closed]##end##\n"; $txt.= "##highlight##Conqueror:##end## ##Red##[Closed]##end##\n"; $txt.= "##highlight##Dark Templer:##end## ##Red##[Closed]##end##\n"; $txt.= "##highlight##Demonologist:##end## ##Red##[Closed]##end##\n"; $txt.= "##highlight##Guardian:##end## ##Red##[Closed]##end##\n"; $txt.= "##highlight##Herald of Xotli:##end## ##Red##[Closed]##end##\n"; $txt.= "##highlight##Necromancer:##end## ##Red##[Closed]##end##\n"; $txt.= "##highlight##Priest of Mitra:##end## ##Red##[Closed]##end##\n"; $txt.= "##highlight##Ranger:##end## ##Red##[Closed]##end##\n"; $txt.= "##highlight##Tempest of Set:##end## ##Red##[Closed]##end##\n\n"; $txt.= "##end##\n"; $txt.= "##GI_red##Guild Info:##end##\n"; $txt.= "##Silver##"; $txt.= "GUILD INFO SECTION 1\n\n"; $txt.= "##end##\n"; $txt.= "##Silver##"; $txt.= "GUILD INFO SECTION 2\n\n"; $txt.= "##end##\n"; $txt.= "##Silver##"; $txt.= "GUILD INFO SECTION 3\n\n"; $txt.= "##end##"; return $this -> bot -> core("tools") -> make_blob("WHAT YOU WANT THE BOT TO TELL THE PLAYER", $txt); } /* Still working on this, for now just some random debugging stuff I was trying */ function recruit() { $blob = "Guild Name is Recruiting!: '"; $blob.= $this -> info(); $blob.= " Playfield ID: "; return $blob; } /* Checks online list for presence of officer of $name Returns online status, and if online, name of current main/alt */ function officercheck($name) { $online = $this -> bot -> db -> select("SELECT t1.nickname FROM " . "#___online AS t1 LEFT JOIN #___whois AS t2 ON t1.nickname = t2.nickname WHERE status_gc=1"); $found = FALSE; if (!empty($online)) { foreach ($online as $player) { if(isset($this -> listed[$channel][$player[0]])) Continue; $main = $this -> bot -> core("alts") -> main($player[0]); if ($name == $main) { $online_state = $this -> bot -> core("online") -> get_online_state($this -> bot -> core("chat") -> get_uname($player[0])); $retstr = " - " . $this -> bot -> core("chat") -> get_uname($player[0]); $found = TRUE; break; } else if ($name == $this -> bot -> core("chat") -> get_uname($player[0])) { $online_state = $this -> bot -> core("online") -> get_online_state($main); $retstr = " - " . $main; $found = TRUE; break; } } if ($found == FALSE) { $online_state = $this -> bot -> core("online") -> get_online_state($name); $retstr = " - " . $name; } } return array($online_state, $retstr); } /* Need to revize so it just uses core */ function memberslist() { $blob = ""; $count = 0; $result = $this -> bot -> db -> select("SELECT nickname, last_seen FROM #___users WHERE user_level = " . MEMBER . " ORDER BY nickname ASC"); if (!empty($result)) { $inside = "##blob_title##:::: <botname>'s Member List ::::##end##\n\n"; foreach ($result as $val) { $count++; $inside .= "##blob_text##&#8226; " . $val[0]; if ($val[1] > 0) { $inside .= ", last seen at " . gmdate($this -> bot -> core("settings") -> get("Time", "FormatString"), $val[1]); } else { $inside .= ", never seen online"; } $inside .= "##end## ".$this -> bot -> core("tools") -> chatcmd("whois " . $val[0], "[Whois]")."\n"; } $blob = " :: " . $this -> bot -> core("tools") -> make_blob("click to view", $inside); } return $count . " Guild Members:" . $blob; } /* Need to revize so it just uses core */ function memberscount() { $blob = ""; $total = 0; $buddies = count($this -> bot -> aoc -> buddies); //Get a list of professions $profession_list = "'".$this->bot->core('professions')->get_professions("', '")."'"; $counts = $this -> bot -> db -> select("SELECT t2.class, COUNT(DISTINCT t1.nickname) FROM #___users AS t1 LEFT JOIN #___whois AS t2 ON t1.nickname = t2.nickname WHERE user_level = " . MEMBER . " AND t2.class IN ($profession_list) GROUP BY class"); foreach ($this -> bot->core('professions')->get_profession_array() as $prof) $count[$prof] = 0; if (!(empty($counts))) { foreach ($counts as $profcount) { $count[$profcount[0]] += $profcount[1]; $total += $profcount[1]; } } $inside = "##blob_title##:::: <botname>'s Member Count ::::##end##\n"; $inside .= "\n##blob_text##Buddy List Count: ##blob_title##".$buddies."##end##\n"; foreach ($count as $key => $value) $inside .= "\n&#8226; ".$key." = ##blob_title##".$value."##end##"; $blob = " :: " . $this -> bot -> core("tools") -> make_blob("click to view", $inside); return $total . " Guild Classes:" . $blob; } } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.