SMF Shop

SMFShop => Beta additions => Items => Topic started by: TrueDestroyer on July 28, 2007, 03:36:24 pm

Title: Slap!
Post by: TrueDestroyer on July 28, 2007, 03:36:24 pm
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: [Select]
<?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($resultMYSQL_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']}!!!";
    }
  }
}

?>

Title: Re: Slap!
Post by: inkstains on August 18, 2007, 12:24:43 am
cool item
Title: Re: Slap!
Post by: Dark_Zero on August 19, 2007, 03:46:21 pm
 :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
Title: Re: Slap!
Post by: breezy on September 04, 2007, 11:06:49 am
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..
Title: Re: Slap!
Post by: Dark_Zero on September 06, 2007, 01:21:44 pm
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
Title: Re: Slap!
Post by: breezy on September 07, 2007, 06:51:36 am
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

I took the same code and made a few changes here and there and also made it where you can purchase kisses.  I'm doing one tonight for lap dances. lmao
Title: Re: Slap!
Post by: Dark_Zero on September 07, 2007, 12:57:30 pm
haha nice O0
Title: Re: Slap!
Post by: breezy on September 08, 2007, 12:42:22 am
What would I need to add/change if I wanted to allow the purchaser to send a lapdance to themselves?
Title: Re: Slap!
Post by: Merch on September 10, 2007, 04:05:01 pm
Sounds funny but I got an error...

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')
ORDER BY mem.lngfile
LIMIT 0' at line 8
File: /home/tmuch3/public_html/forums/Sources/Subs-Post.php
Line: 771

Note: It appears that your database may require an upgrade. Your forum's files are currently at version SMF 1.1.3, while your database is at version 1.1.2. The above error might possibly go away if you execute the latest version of upgrade.php.

How would I do this upgrade!? I'm new to usin' these kind of boards and the whole php thing.
Title: Re: Slap!
Post by: breezy on September 11, 2007, 01:28:40 am
I received a similar error because of a syntax problem when trying to modify the code, but my  database did not need an upgrade.. I just found the line and found what was missing.
Title: Re: Slap!
Post by: doon on September 16, 2007, 11:41:21 am
i installed the php file in the shop item directory ... and when click on add/edit new item in cp

i got this

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/chillpar/public_html/Sources/shop/items/SlapAFoo.php on line 2

Parse error: syntax error, unexpected T_STRING in /home/chillpar/public_html/Sources/shop/items/SlapAFoo.php on line 2




plzz help
Title: Re: Slap!
Post by: ninerskickass on September 22, 2007, 12:54:28 am
Hey! I was wondering how I add this item to the shop? I'd like to test it out, sounds like fun!

I am clueless when it comes to coding though, so if someone could help me out I would truly appreciate it.

Thanks!
Title: Re: Slap!
Post by: Dark_Zero on November 07, 2007, 11:39:30 am
just save it as a php file and upload it through ftp into your shop items' directory. save it as SlapAFoo.php or whatever but dont leave the hanging .txt at the end
Title: Re: Slap!
Post by: ninerskickass on January 14, 2008, 03:29:05 am
just save it as a php file and upload it through ftp into your shop items' directory. save it as SlapAFoo.php or whatever but dont leave the hanging .txt at the end

thanks man!
Title: Re: Slap!
Post by: ctrlz on January 28, 2008, 12:45:03 pm
Is there any way to send the PM from a custom user like "Forum Bot". It gets confusing when the message is being sent by the person doing the slapping and everything is in the third person.
Title: Re: Slap!
Post by: Damian1221 on February 16, 2008, 05:21:01 am
Hah sounds awesome but the images are dead anybody have em   :D
Title: Re: Slap!
Post by: Tweet on March 30, 2008, 04:04:46 am
 :2funny: Just What I Needed For April Fools! >:D

Works fine, no errors for me O0

Yes, need some new images though :(

Thank You For Making This!  :D
Title: Re: Slap!
Post by: TrueDestroyer on October 04, 2008, 02:18:40 pm
Wow... didn't really think anyone had taken this up. Cool though. Yeah, the images are dead because of a forum move. I don't think I have them anymore, they were all just random images I pulled from searching "owned" on Google. I'm sure you're all capable of this.

As per the errors and suggestions, if I get a chance, I'll take a look at making a new version.
Title: Re: Slap!
Post by: mike dijital on October 17, 2008, 06:51:06 am
Installed smooth as glass into a heavily modded 1.1.6   O0


Title: Re: Slap!
Post by: kuwakchai on November 10, 2008, 09:39:57 pm
nice item!

however, got a small glitch: when click on the result on Find Member pop up, the username is not passed back to the input form. Any idea how this happens?
Title: Re: Slap!
Post by: Regina on March 11, 2009, 07:43:48 am
I really want to try this but I get this error:
ERROR: Could not create instance of 'SlapAFoo' item!

Does anyone know where I went wrong?
*Hugs,
Gina
Title: Re: Slap!
Post by: steve51184 on February 09, 2010, 10:33:52 am
any chance of an update for rc2?

Quote
Fatal error: Call to undefined function db_query() in C:\wamp\www\Sources\shop\items\SlapAFoo.php  on line 42
Title: Re: Slap!
Post by: DTeK on October 24, 2010, 12:59:29 am
I received a similar error because of a syntax problem when trying to modify the code, but my  database did not need an upgrade.. I just found the line and found what was missing.



I have the same error. Whatdid you change to getit working?
Title: Re: Slap!
Post by: DTeK on October 25, 2010, 06:35:57 pm
It seems that I got that error because I was trying to slap a member with a space in his name. Can anyone help to fix this?