Author Topic: Free Money Idea  (Read 6822 times)

Offline ShadowStriker

Free Money Idea
« on: June 17, 2007, 01:20:31 am »
I have an idea for a shop item. A "Free Money" item. But the name doesnt quite say it all. For when the item is used it would say something like "Hah, did you really think you would get free money!?" and then they lose 5 karma. Is this possible?

Offline ShadowStriker

Re: Free Money Idea
« Reply #1 on: June 17, 2007, 01:43:43 am »
sry I didnt see the items child board, can a moderator move it there?

Offline Daniel15

Re: Free Money Idea
« Reply #2 on: June 23, 2007, 12:05:22 pm »
Very easy to do :)
Save this into Sources/shop/items as "FreeMoney.php":
Code: [Select]
<?php
if (!defined('SMF'))
die('Hacking attempt...');

class 
item_FreeMoney extends itemTemplate
{
function getItemDetails()
{
$this->authorName 'Daniel15';
$this->authorWeb 'http://www.dansoftaustralia.net/';
$this->authorEmail 'dansoft@dansoftaustralia.net';

$this->name 'Free money';
$this->desc 'FREE money!';
$this->price 0;

$this->require_input false;
$this->can_use_item true;
}

function onUse()
{
global $context;

updateMemberData($context['user']['id'], array('karmaBad' => 'karmaBad + 5'));
return 'Hah, did you really think you would get free money!?';
}
}
?>

Then add it via the "Add/Edit/Delete Items" section in the admin panel :)
« Last Edit: June 23, 2007, 12:24:55 pm by Daniel15 »

Offline ShadowStriker

Re: Free Money Idea
« Reply #3 on: June 23, 2007, 12:14:00 pm »
Awesome, thanks!  ;D

Offline ShadowStriker

Re: Free Money Idea
« Reply #4 on: June 23, 2007, 12:21:34 pm »
Wait, I get this when trying to get into the add/edit/delete item menu:

Parse error: syntax error, unexpected ';' in /home/strikere/public_html/forums/Sources/shop/items/FreeMoney.php on line 25

Offline Daniel15

Re: Free Money Idea
« Reply #5 on: June 23, 2007, 12:25:39 pm »
Ah, that was me being stupid and not testing the code :P. It should be fixed now.

Find:
Code: [Select]
updateMemberData($context['user']['id'], array('karmaBad' => 'karmaBad + 5');

Replace with:
Code: [Select]
updateMemberData($context['user']['id'], array('karmaBad' => 'karmaBad + 5'));

Offline Basil Beard

Re: Free Money Idea
« Reply #6 on: June 24, 2007, 10:04:27 am »
How long has there been an updateMemberData function and why didn't I know about it?

It sure beats those massive database queries XD
Arrrrr!

Offline Daniel15

Re: Free Money Idea
« Reply #7 on: June 30, 2007, 05:00:16 pm »
How long has there been an updateMemberData function and why didn't I know about it?

It sure beats those massive database queries XD
It's been in SMF since the beginning (indeed, I didn't know about it either). :P

Offline David

Re: Free Money Idea
« Reply #8 on: June 30, 2007, 06:58:18 pm »
Just thinking out loud...I tend to avoid Karma changing items or adapt them to change money...maybe this one could deduct money from the user and give it to either the poorest member or equally to all members (with or without a PM notification?) Would that seem useful/reasonable as an alternative?