• Forum
  • Doc
  • Screenshots
  • Download
  • Donate
  • Contributors
  • Contact
  • Follow @phpfreechat
  • DEMO
  • Board index ‹ Version 1.x branch ‹ Contributions (v1.x)
  • Change font size
  • FAQ
  • Register
  • Login

/slap command

Post a bug fix, a new feature, a theme ...

Moderators: OldWolf, re*s.t.a.r.s.*2

Post a reply
7 posts • Page 1 of 1

Postby mak2k » Sun Mar 18, 2007 5:24 pm

Here is my first command i have "written" for this (written being in quotations since it's a stupid easy hack :P). Basically all i did was change me.class.php to suit what i want... (which in this case was what to display on screen). I'll add more random object for users to slap with later on ;)

Instructions: save the following code as slap.class.php into src/commands. Don't forget to rehash your chatroom

the class:
Code: Select all
<?php

require_once(dirname(__FILE__)."/../pfccommand.class.php");

class pfcCommand_slap extends pfcCommand
{
  var $usage = "/slap {nick}";

  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();

    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;
    }

    $container =& pfcContainer::Instance();
    $msg = phpFreeChat::PreFilterMsg($param);
   
   // concatenated the * in front of the nick 'cause i can't seem to find where in the code that it adds that, like the /me command
    $container->write($recipient, "*me*", $this->name, "* ".$u->nick." slaps ".$msg." around a bit with a large trout");
   
    if ($c->debug) pxlog("/slap ".$msg, "chat", $c->getId());
  }
}

?>

add this to the css style sheet of your theme (of course, feel free to change color, style and other funky features you want to have on your page)
Code: Select all
.pfc_cmd_slap{
  font-style: italic;
  color: black;
}
Last edited by mak2k on Sun Mar 18, 2007 6:56 pm, edited 1 time in total.
mak2k
New member
 
Posts: 2
Joined: Thu Mar 15, 2007 3:09 am
Top

Postby robi_bagoes » Wed Jun 13, 2007 11:01 am

Slaps..... ain't that's fun?

I found some bugs however. With ur code, i can :
1. slap someone who's not in the chatroom. Example : /slap nobody.
2. Slap myself ! no way unless i've to stay awake all night.

I changed ur code a bit to fix those bugs, and add another option as well i.e. the tool to slap with. If no tool is given, the default is to slap with a large trout.

So here's the class i re-wrote :
Code: Select all
<?php

require_once(dirname(__FILE__)."/../pfccommand.class.php");

class pfcCommand_slap extends pfcCommand
{
  var $usage = "/slap {nick} [ {tool} ]"; //modif 0

  function run(&$xml_reponse, $p)
  {
    $clientid    = $p["clientid"];
    $param       = $p["param"];
    $params      = $p["params"]; // modif 1
    $sender      = $p["sender"];
    $recipient   = $p["recipient"];
    $recipientid = $p["recipientid"];
   
    $c =& pfcGlobalConfig::Instance();
    $u =& pfcUserConfig::Instance();

    $nick   = isset($params[0]) ? $params[0] : ''; //modif 2
    $tool = isset($params[1]) ? $params[1] : ''; //modif 3
    $tool = $tool==''?"large trout":$tool; //modif 4
    if (trim($param) == "" || $nick== "") //modif 5
    {
      // error
      $cmdp = $p;
      $cmdp["param"] = _pfc("Missing parameter");
      $cmdp["param"] .= " (".$this->usage.")";
      $cmd =& pfcCommand::Factory("error");
      $cmd->run($xml_reponse, $cmdp);
      return;
    }

    $container =& pfcContainer::Instance();
#    $msg = phpFreeChat::PreFilterMsg($param);
    if($otherid=$container->getNickId($nick) && $u->nick!=$nick){ //modif 6
   // concatenated the * in front of the nick 'cause i can't seem to find where in the code that it adds that, like the /me command
#    $container->write($recipient, "*me*", $this->name, "* ".$u->nick." slaps ".$msg." around a bit with a large trout");
    $container->write($recipient, "*me*", $this->name, "* ".$u->nick." slaps ".$nick." around a bit with a ".$tool); //modif 7
   
    if ($c->debug) pxlog("/slap ".$msg, "chat", $c->getId());
    } // modif 8
  }
}

?>

I wonder how to add this slap thing to appear when we click others nick on the right column....
Last edited by robi_bagoes on Wed Jun 13, 2007 11:13 am, edited 1 time in total.
robi_bagoes
New member
 
Posts: 3
Joined: Wed Jun 13, 2007 8:52 am
Top

Postby ninjaw » Fri Oct 05, 2007 6:49 pm

Hello I use 1.0 stabe, only the first command class works ! thank you
Last edited by ninjaw on Fri Oct 05, 2007 6:58 pm, edited 1 time in total.
ninjaw
Member
 
Posts: 49
Joined: Thu Oct 04, 2007 10:40 pm
Top

Postby runebergen » Mon Oct 27, 2008 7:08 pm

Thanx a lot

Worked excellent!

Great work
runebergen
Member
 
Posts: 30
Joined: Tue Aug 12, 2008 10:00 am
Top

Postby DreadPirateVane » Thu Nov 05, 2009 11:53 pm

this code is awesome,, many laughs!!,, i would, however, like to use the command without having to use the "" around 2 part names and/or the tool to use other than default

and maybe even an alternate slap message, like say, shakes the hand of, for example.
Last edited by DreadPirateVane on Thu Nov 05, 2009 11:53 pm, edited 1 time in total.
Station Built by the Bands,, For the Fans!!
DreadPirateVane
Member
 
Posts: 47
Joined: Tue Dec 23, 2008 10:44 pm
Location: Kansas City, Mo.
  • Website
  • YIM
Top

Postby Bulqr4eto » Fri Jul 16, 2010 3:29 pm

works perfectly with the first post :) thanks !!
Bulqr4eto
New member
 
Posts: 3
Joined: Fri Jul 09, 2010 2:46 pm
Top

Postby bhootnath » Fri Nov 26, 2010 9:00 pm

works perfect.. tested both... kept the second one with slight mod.. that allowed users to slap themselves.. well if they wanna slap themselves who are we to stop.. :-p
bhootnath
Member
 
Posts: 13
Joined: Fri Nov 19, 2010 10:12 pm
Top


Post a reply
7 posts • Page 1 of 1

Return to Contributions (v1.x)

Who is online

Users browsing this forum: No registered users and 10 guests

  • Board index
  • The team • Delete all board cookies • All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
Sign in
Wrong credentials
Sign up I forgot my password
.
jeu-gratuit.net | more partners
Fork me on GitHub