SMF Shop
SMFShop => Items => Topic started by: checho_vacan on December 14, 2006, 11:50:28 pm
-
Hi, im noob on this... so i want to make some items... i had like 3 now n_n
This item it's called "Soul Eater" (aka Chupasangre)
the code is very simple, but i want to implement a little more of code
What i does?
- Steal 15 Karma point to a user and give it to you (>=D)
- you need to use 30 extra gold when use it
My problem is that if the user have 0 gold, still can use the item ¬¬.... please some one fix this :D
chupasangre.php
<?php
/**********************************************\
| SMFSHOP (Shop MOD for Simple Machines Forum) |
| (c) 2006 DanSoft Australia |
| http://www.dansoftaustralia.net/ |
\**********************************************/
//File: testitem.php
// Test Item (requires NO input)
// VERSION: 2.3 (Build 11)
// $Date: 2006-10-21 13:34:18 +1000 (Sat, 21 Oct 2006) $
// $Id: testitem.php 24 2006-10-21 03:34:18Z daniel15 $
// Your class should always be called item_filename, eg. if your file is
// myCoolItem.php then the class should be called 'item_myCoolItem'. This
// class should always extend itemTemplate.
class item_chupasangre extends itemTemplate {
// When this function is called, you should set all the item's
// variables (see inside this example)
function getItemDetails() {
// The author's name
$this->authorName = "Checho";
// The author's website
$this->authorWeb = "http://www.foro-qliao.cl.nu/";
// The author's email address
$this->authorEmail = "chechovacan@gmail.com";
//VALUES CHANGEABLE FROM WITHIN ADMIN PANEL:
// The name of the item
$this->name = "Chupasangre";
// The item's description
$this->desc = "Este item te permite robar cosmo y agregarlo al tuyo";
// The item's price
$this->price = 100000;
}
function getUseInput() {
global $context, $scripturl, $settings, $txt;
return "Nombre de usuario: <input type='text' name='username' />
<a href='{$scripturl}?action=findmember;input=username;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']}' /> Burcar</a><br />";
}
function onUse() {
global $db_prefix, $ID_MEMBER, $item_info;
if (!isset($_POST['username']) || $_POST['username'] == '') die("ERROR: Debes ingresar un nombre de usuario!");
// if (!isset($ID_MEMBER == '(money < 30)') die("Debes tener almenos 30 de oro para usar este item");
$result = db_query("UPDATE {$db_prefix}members
SET karmaGood = karmaGood + 15, money = money - 30
WHERE ID_MEMBER = {$ID_MEMBER}", __FILE__, __LINE__);
$result = db_query("UPDATE {$db_prefix}members
SET karmaBad = karmaBad + 15
WHERE memberName = '{$_POST['username']}'",
__FILE__, __LINE__);
return "Le haz robado 15 puntos de cosmo a {$_POST['username']}!";
}
}
?>
-
Your commented out bit:
// if (!isset($ID_MEMBER == '(money < 30)') die("Debes tener almenos 30 de oro para usar este item");
Replace it with:
$result_money = db_query("SELECT money FROM {$db_prefix}members WHERE ID_MEMBER = {$ID_MEMBER}", __FILE__, __LINE__);
$row = mysql_fetch_assoc($result_money);
if ($row['money'] < 30) die('Debes tener almenos 30 de oro para usar este item');
-
Thanks!... but it doesn't nothing now :(
-
Hmmm... Any errors in the error log?
-
Nup.... just nothing happend XD
-
is there an English version of this?
-
is there an English version of this?
Just install and use the item then copy the messages you see when you use it and search for those in the php. It only takes five minutes.