SMFShop > Items

Slap!

(1/5) > >>

TrueDestroyer:
Alright, I'm trying to make an item that sends a taunt, an image, and a message to a user, along with lowering their Karma. It's called 'Slap A Foo', I thought it would just be something fun that members could do. Anyway, I think I have it working. Anyone want to try it out? Opinions and comments very welcome. There's probably a bug in there somewhere, this is my first custom item.

--- Code: ---<?php
//Author: TrueDestroyer
//File: SlapAFoo.php
//Copyright 2007

// VERSION: 1.0
// Date: 2007-07-38

global $sourcedir;
require_once($sourcedir.'/Subs-Post.php');
class item_SlapAFoo extends itemTemplate {
    
  function getItemDetails() {
    //My info
$this->authorName = "TrueDestroyer";
    $this->authorWeb = "http://forum.briskfire.net";
    $this->authorEmail = "dkrieg@briskfire.net";
    //Item info
    $this->name = "Slap A Foo";
    $this->desc = 'Show that fool the disrespect they deserve! Slap'.
      ' them and knock their Karma down a little.';
    $this->price = 500;
    $this->require_input = true;
    $this->can_use_item = true;
  }
 
  function getAddInput() {
    //Get the amount of Karma to knock off of the user.
    return "Karma to knock out : <input type='text' name='info1' value='5'>'";
  }  

  function getUseInput() {
    global $context, $scripturl, $settings, $txt;
    return "<table><tr><td>Slap : </td><td><input type='text' name='slapwho' size='50'>
        <a href='{$scripturl}?action=findmember;input=slapwho;quote=0;sesc={$context['session_id']}' onclick='return reqWin(this.href, 350, 400);'><img src='{$settings['images_url']}/icons/assist.gif' border='0' alt='{$txt['find_members']}' /> Find Member</a></td></tr>
        <tr><td valign='top'>Talk smack : </td><td><textarea name='talksmack' cols='50' rows='2'></textarea></td></tr></table>";
  }
    
  function onUse() {
    global $db_prefix, $ID_MEMBER, $user, $item_info;
    //Get the current user's display name
    $result = db_query("SELECT realName, memberName
                  FROM {$db_prefix}members
                  WHERE ID_MEMBER = {$ID_MEMBER}", __FILE__, __LINE__);
    $row = mysql_fetch_array($result, MYSQL_ASSOC);
    $user = $row["realName"];
    //Set up the pm
    $pmfrom = array(
        'id' => $ID_MEMBER,
        'name' => $row['realName'],
        'username' => $row['memberName']
        );
        
    $pmto = array(
        'to' => array($_POST['slapwho']),
        'bcc' => array()
        );

    if ($user == $_POST['slapwho']) {
      return "You can't slap yourself!";
      die();
    }else{
      $amount = $item_info[1];
      $result = db_query("UPDATE {$db_prefix}members
                  SET karmaBad = karmaBad + {$amount}
                  WHERE realName = '{$_POST['slapwho']}'", 
                  __FILE__, __LINE__);
                  
      //Pick random taunt.
      $message = rand()%5;
      $mess_ar = array(
              "[b]{$user}[/b] has just slapped you back to the stone age.\n",
              "[b]{$user}[/b] has just shamed you with a slap across the face.\n",
              "[b]{$user}[/b] has just slapped you hard enough to make your grandmother feel it.\n",
              "[b]{$user}[/b] just smacked you with a fish.\n",
              "[b]{$user}[/b] just delivered some ownage on your face.\n"
              );
      //Pick random image.
      $image = rand()%5;
      $img_ar = array(
              "[img]http://images.briskfire.net/forum/tangs.jpg[/img]\n",
              "[img]http://images.briskfire.net/forum/biff.jpg[/img]\n",
              "[img]http://images.briskfire.net/forum/face.jpg[/img]\n",
              "[img]http://images.briskfire.net/forum/ninjacat.jpg[/img]\n",
              "[img]http://images.briskfire.net/forum/kid_smack.gif[/img]\n"
              );

      $talk_smack = '';
      if(isset($_POST['talksmack'])&&$_POST['talksmack']!='')
        $talk_smack = 'And to add insult to injury, they said :
'.$_POST['talksmack']; 
      
      sendpm($pmto, 'You Have Just Been Slapped!', 
          $mess_ar[$message].$img_ar[$image].$talk_smack, 
          0, $pmfrom); ;
      return "You've slapped {$_POST['slapwho']}!!!";
    }
  }
}

?>

--- End code ---

inkstains:
cool item

Dark_Zero:
 :D nice item man this will surely pi$$ off my members ;D in a good way of course; thanks though O0 i'll probably use it

breezy:
THIS IS THE BEST MOD EVER!!!! LOLOLOLOL  I AM STILL CRACKING UP!!!  I had no errors and it ran perfectly.  Im buying them just to see the different messages.. lol..  One suggestion.. make a link back to the shop that will allow the person who was slapped to go directly to purchase one.. lmao..

Dark_Zero:
o yah breezy to make this even more fun just add a few more statements and increase the rand()% number to the number of total statements you have.. it's pretty cool :laugh: O0

Navigation

[0] Message Index

[#] Next page

Go to full version