<?php
if (!defined('SMF'))
die('Hacking attempt...');
class item_Cards extends itemTemplate
{
function getItemDetails()
{
$this->authorName = 'Inkstains';
$this->authorWeb = '';
$this->authorEmail = '';
$this->name = 'Cards';
$this->desc = 'Try your luck and win. Karma, Credits and more up for grabs, but dont cry if you get burnt.';
$this->price = 100;
$this->require_input = true;
$this->can_use_item = true;
$this->addInput_editable = true;
}
function getAddInput()
{
global $item_info, $db_prefix;
return '
Maximum amount to increase/decrease post count by: <input type="text" name="info1" value="' . $item_info[1] . '" /><br />
Maximum amount to increase/decrease credits by: <input type="text" name="info2" value="' . $item_info[2] . '" /><br />
Maximum amount to increase/decrease karma by: <input type="text" name="info3" value="' . $item_info[3] . '" /><br />
Maximum amount to increase/decrease time online by: <input type="text" name="info4" value="' . $item_info[4] . '" /><br />';
}
function onUse()
{
global $db_prefix, $ID_MEMBER, $item_info;
$value = mt_rand(1, 8);
if ($value == 1) {
$value1 = mt_rand(1, $item_info[1]);
$result = db_query("UPDATE {$db_prefix}members SET posts = posts + {$value1} WHERE ID_MEMBER = {$ID_MEMBER}", __FILE__, __LINE__);
return "You got an Ace and increased your post count by ". ($value1) ."";
}
elseif ($value == 2) {
$value1 = mt_rand(1, $item_info[2]);
$result = db_query("UPDATE {$db_prefix}members SET money = money + {$value1} WHERE ID_MEMBER = {$ID_MEMBER}", __FILE__, __LINE__);
return "You got a King and gained ". formatMoney($value1) ."";
}
elseif ($value == 3) {
$value1 = mt_rand(1, $item_info[3]);
$result = db_query("UPDATE {$db_prefix}members SET karmaGood = karmaGood + {$value1} WHERE ID_MEMBER = {$ID_MEMBER}", __FILE__, __LINE__);
return "You got a Queen and increased you karma by ". ($value1) ."";
}
elseif ($value == 4) {
$value1 = mt_rand(1, $item_info[4]);
$result = db_query("UPDATE {$db_prefix}members SET totalTimeLoggedIn = totalTimeLoggedIn + {$value1} WHERE ID_MEMBER = {$ID_MEMBER}", __FILE__, __LINE__);
return "You got a Jack and increased your time online by ". ($value1) ."";
}
elseif ($value == 5) {
$value1 = mt_rand(1, $item_info[1]);
$result = db_query("UPDATE {$db_prefix}members SET posts = posts - {$value1} WHERE ID_MEMBER = {$ID_MEMBER}", __FILE__, __LINE__);
return "You got a Joker!! and decreased your post count by ". ($value1) ."";
}
elseif ($value == 6) {
$value1 = mt_rand(1, $item_info[2]);
$result = db_query("UPDATE {$db_prefix}members SET money = money - {$value1} WHERE ID_MEMBER = {$ID_MEMBER}", __FILE__, __LINE__);
return "You got a Joker!! and lost ". formatMoney($value1) ."";
}
elseif ($value == 7) {
$value1 = mt_rand(1, $item_info[3]);
$result = db_query("UPDATE {$db_prefix}members SET karmaBad = karmaBad + {$value1} WHERE ID_MEMBER = {$ID_MEMBER}", __FILE__, __LINE__);
return "You got a Joker!! and decreased your karma by ". ($value1) ."";
}
elseif ($value == 8) {
$value1 = mt_rand(1, $item_info[4]);
$result = db_query("UPDATE {$db_prefix}members SET totalTimeLoggedIn = totalTimeLoggedIn - {$value1} WHERE ID_MEMBER = {$ID_MEMBER}", __FILE__, __LINE__);
return "You got a Joker!! and decreased your time online by ". ($value1) ."";
}
}
}
?>
I haven't added the card images or anything yet but that's the basis of it
EDIT: i'm still fairly new to php so this is just my version of how i think it would work. and it does what it needs to.