You will need 2 text files for the code to randomly pull information from (which can go anywhere, I've put them in the data folder from where my chat is located.)
A text file with a list of characters - characters.txt
Example:
- Code: Select all
The Warrior
The Healer
The Mage
The Thief
The Carddealer
A text file with a list of actions/general prompts - action.txt
- Code: Select all
smile
stars
heading off to the bar
going skiing
jumping the shark
playing Go
arguing
sleeping
coding
chatting
In src/commands create a file prompt.class.php
- Code: Select all
<?php
require_once(dirname(__FILE__)."/../pfccommand.class.php");
// Prompt command by Qem
class pfcCommand_prompt extends pfcCommand
{
var $usage = "/prompt {hero | duo | trio}";
function run(&$xml_reponse, $p)
{
$clientid = $p["clientid"];
$param = $p["param"];
$sender = $p["sender"];
$recipient = $p["recipient"];
$recipientid = $p["recipientid"];
$c =& pfcGlobalConfig::Instance();
$u =& pfcUserConfig::Instance();
$ct =& pfcContainer::Instance();
if (trim($param) == "")
{
// error
$cmdp = $p;
$cmdp["param"] = _pfc("Missing parameter");
$cmdp["param"] .= " (".$this->usage.")";
$cmd =& pfcCommand::Factory("error");
$cmd->run($xml_reponse, $cmdp);
return;
}
$msg = phpFreeChat::PreFilterMsg($param);
// values
$i=0; //if some other option was selected.
if($msg=="hero") $i=1;
if($msg=="duo") $i=2;
if($msg=="trio") $i=3;
//this pulls from the folder structure of where your chat is located
$f_character = file("data/characters.txt");
if($i==0){
$result="Anyone ";
}
for($j = 0; $j < $i; $j++){'
$char = $f_character[rand(0, count($f_character) - 1)];
$result=$result . $char . " and ";
}
$f_action = file("data/action.txt");
$action = $f_action[rand(0, count($f_action) - 1)];
$result=$result ."the prompt: " . $action;
$ct->write($recipient, "*me*", $this->name, $u->getNickname()." asked for a prompt and got: " .$result);
}
}
?>