Hi, I'm new to all this coding malarky but I had a go on an adaptation of this script whereby you can take a random amount of karma. You can set (the maximum and minimum) when you make the item in the shop.
<?php
/**********************************************\
| SMFSHOP (Shop MOD for Simple Machines Forum) |
| (c) 2005 DanSoft Australia |
| http://www.dansoftaustralia.com/ |
\**********************************************/
//File: KarmaBash2.php
// Item
//VERSION: 1.1 (Build 4)
//DATE: 10th April 2005
//Author Tazpot
//Helped by Basil Beard
// Slightly modified by Daniel15 and War Chief
class item_KarmaBash2 extends itemTemplate {
function getItemDetails() {
$this->name = "Karma Bash 2";
$this->desc = "Bash xx points of another members karma";
$this->price = 50;
$this->require_input = true;
$this->can_use_item = true;
}
function getAddInput() {
return "Minimum karma removed: <input type='text' name='info1' value='1'><br>
Maximum karma removed: <input type='text' name='info2' value='10'>";
}
function getUseInput() {
global $context, $scripturl, $settings, $txt;
return "Karma Bash: <input type='text' name='bashwho' size='50'>
<a href='{$scripturl}?action=findmember;input=bashwho;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>";
}
function onUse() {
global $db_prefix, $ID_MEMBER, $item_info;
$amount = mt_rand($item_info[1], $item_info[2]);
$result = db_query("UPDATE {$db_prefix}members
SET karmaBad = karmaBad + {$amount}
WHERE membername = '{$_POST['bashwho']}'"
,__FILE__, __LINE__);
return "Successfully bashed {$amount} karma points from {$_POST['bashwho']}!";
$result = db_query("SELECT ID_MEMBER
FROM {$db_prefix}members
WHERE memberName = '{$_POST['bashwho']}'", __FILE__, __LINE__);
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$pmfrom = array(
'id' => 1,
'name' => 'Tazpot',
'username' => 'Tazpot'
);
$pmto = array(
'to' => array($row['ID_MEMBER']),
'bcc' => array()
);
sendpm($pmto, 'You have been bashed', "{$user} bashed {$amount} points off your karma! [i] You do not need to reply to this automated message[/i]", 0, $pmfrom);
return "You have bashed {$_POST['bashwho']} for {$amount} points off their karma!";
}
}
?>