Author Topic: Help with my Item: Soul Eater  (Read 7212 times)

Offline checho_vacan

Help with my Item: Soul Eater
« 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
Code: [Select]
<?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']}!";
    }

}

?>


Offline Daniel15

Re: Help with my Item: Soul Eater
« Reply #1 on: December 16, 2006, 07:50:08 pm »
Your commented out bit:
Code: [Select]
//    if (!isset($ID_MEMBER == '(money < 30)') die("Debes tener almenos 30 de oro para usar este item");

Replace it with:
Code: [Select]
        $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');

Offline checho_vacan

Re: Help with my Item: Soul Eater
« Reply #2 on: December 19, 2006, 04:09:22 am »
Thanks!... but it doesn't nothing now :(

Offline Daniel15

Re: Help with my Item: Soul Eater
« Reply #3 on: December 20, 2006, 05:31:38 pm »
Hmmm... Any errors in the error log?

Offline checho_vacan

Re: Help with my Item: Soul Eater
« Reply #4 on: December 20, 2006, 11:15:00 pm »
Nup.... just nothing happend XD

Offline mike dijital

Re: Help with my Item: Soul Eater
« Reply #5 on: October 17, 2008, 06:55:44 am »
is there an English version of this?

Offline DTeK

Re: Help with my Item: Soul Eater
« Reply #6 on: November 13, 2010, 11:52:44 pm »
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.