SMF Shop
SMFShop => Beta additions => Items => Topic started 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.
<?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']}!!!";
}
}
}
?>
-
cool item
-
: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
-
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..
-
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
-
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
-
haha nice O0
-
What would I need to add/change if I wanted to allow the purchaser to send a lapdance to themselves?
-
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.
-
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 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
-
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!
-
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
-
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!
-
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.
-
Hah sounds awesome but the images are dead anybody have em :D
-
: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
-
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.
-
Installed smooth as glass into a heavily modded 1.1.6 O0
-
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?
-
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
-
any chance of an update for rc2?
Fatal error: Call to undefined function db_query() in C:\wamp\www\Sources\shop\items\SlapAFoo.php on line 42
-
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?
-
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?