Author Topic: New items: Red Balls  (Read 46688 times)

Offline Masterhand

New items: Red Balls
« on: November 17, 2006, 09:49:19 am »
Here are the 2 files for the Redball items - There fun,
I had fun making them too.

Redball
Code: [Select]
<?php
/**********************************************\
| SMFSHOP (Shop MOD for Simple Machines Forum) |
|         (c) 2006 DanSoft Australia           |
|      http://www.dansoftaustralia.net/        |
\**********************************************/

//File: RedBall.php
//      Item

// VERSION: 2.3 (Build 11)
// $Date: 2006-10-21 13:34:18 +1000 (Sat, 21 Oct 2006) $
// $Id: RedBall.php 24 2006-10-21 03:34:18Z MH $

class item_RedBall extends itemTemplate {
    function 
getItemDetails() {
$this->authorName "Masterhand";
$this->authorWeb "GAC";
$this->authorEmail "austin.r.tanay@gmail.com";

        
$this->name "RedBall";
        
$this->desc "Bounce It And See What it Does!";
        
$this->price 200;
    }

    function 
getUseInput() {
global $context$scripturl$settings$txt;
        return 
"Bounce to: <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']}' /> Find Member</a><br />";
    }

    function 
onUse() {
        global 
$db_prefix$ID_MEMBER;

if (!isset($_POST['username']) || $_POST['username'] == '') die("ERROR: Please enter a username!");

        
$result db_query("UPDATE {$db_prefix}members
                            SET posts = posts - 100
                            WHERE memberName = '
{$_POST['username']}'",
                            
__FILE____LINE__);
        return 
"Uh-Oh, The Ball Bounced around, and {$_POST['username']}Missed it and it knocked him out, and he lost some of his post count by 100..Whoops..";
    }

}

?>

Redball 2
Code: [Select]
<?php

/**********************************************\
| SMFSHOP (Shop MOD for Simple Machines Forum) |
|         (c) 2006 DanSoft Australia           |
|      http://www.dansoftaustralia.net/        |
\**********************************************/

//File: Redball2.php

// VERSION: 2.3 (Build 11)
// $Date: 2006-11-17 13:34:18 +1000 (Fri, 17 Nov 2006) $
// $Id: Redball2.php 24 2006-10-21 03:34:18Z Mh $
global $sourcedir;
require_once(
$sourcedir '/Subs-Post.php');
class 
item_Redball2 extends itemTemplate {
    
    function 
getItemDetails() {

$this->authorName "Masterhand";
                
$this->authorWeb "http://www.gameandcoders.uni.cc";
$this->authorEmail "austin.r.tanay@gmail.com";

          
$this->name "RedBall2";
          
          
$this->desc "Redball 2";
          
// The item's price
          
$this->price 100;

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

    
      function 
getAddInput() {
        return 
"Max amount to give: <input type='text' name='info1' value='100'><br>
               Max amount to take: <input type='text' name='info2' value='-100'>"
;
    
}  


       function 
getUseInput() {
       
global 
$context$scripturl$settings$txt;
        return 
"Bounce To: <input type='text' name='stealfrom' size='50'>
         <a href='
{$scripturl}?action=findmember;input=stealfrom;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$user$item_info;
   
$pmfrom = array(
            
'id' => 1,
            
'name' => 'Admin',
            
'username' => 'Admin'
        
);
        
        
$pmto = array(
            
'to' => array($_POST['stealfrom']),
            
'bcc' => array()
        );
     
$result db_query("SELECT realName
                                FROM 
{$db_prefix}members
                                WHERE ID_MEMBER = 
{$ID_MEMBER}"__FILE____LINE__);
     
$row mysql_fetch_array($resultMYSQL_ASSOC);
$user $row["realName"];

       if (
$user == $_POST['stealfrom']) {
return 
"You cant throw it too yourself!";
die();
  }

else {
$amount mt_rand($item_info[2], $item_info[1]);

$result db_query("UPDATE {$db_prefix}members
                                SET money = money + 
{$amount}
                                WHERE realName = '
{$_POST['stealfrom']}'"__FILE____LINE__);
                                
sendpm($pmto'Heres a redball?'"<b>{$user}</b> Bounces The Ball To You And You Lose/Win ".formatMoney($amount)."! [i] You do not need to reply to this automated message"0$pmfrom); ;
                                return 
"You've thrown the ball to {$_POST['stealfrom']} if he catches it he'll gain money, else he'll lose it!!!";

       
$result db_query("SELECT ID_MEMBER
       FROM 
{$db_prefix}members
       WHERE realName = '
{$_POST['stealfrom']}'"__FILE____LINE__);
       
$row mysql_fetch_array($resultMYSQL_ASSOC);


            }

  }
  }

?>

« Last Edit: March 17, 2007, 02:16:03 am by Masterhand »
~If at first you don't succed, hide all evidence that you tried.~ - Homer Simpson

Offline Basil Beard

Re: New item: Red Ball
« Reply #1 on: November 17, 2006, 12:49:59 pm »
You should change the code to make the target have a change to catch (and keep) the ball instead of missing. =)
Arrrrr!

Offline Masterhand

Re: New item: Red Ball
« Reply #2 on: November 17, 2006, 09:32:17 pm »
See First Post For Files
« Last Edit: December 21, 2006, 01:37:59 am by Masterhand »
~If at first you don't succed, hide all evidence that you tried.~ - Homer Simpson

Offline Basil Beard

Re: New item: Red Ball
« Reply #3 on: November 18, 2006, 02:05:34 pm »
Cool. =).

(Be warned, this code won't work, hoever, because you used a quote mark for the "can't", thus throwing off the rest of the code. Use '`' instead =P.)
Arrrrr!

Offline Masterhand

Re: New item: Red Ball
« Reply #4 on: November 18, 2006, 07:46:07 pm »
 :D No, won't work, says: Prase Error: enespected T_IF ....*sigh*
« Last Edit: November 18, 2006, 07:54:05 pm by Masterhand »
~If at first you don't succed, hide all evidence that you tried.~ - Homer Simpson

Offline Basil Beard

Re: New item: Red Ball
« Reply #5 on: November 19, 2006, 12:34:51 am »
"$user = $row[‘memberName’]" doesn't have a semi colon ;-) (it should)
Arrrrr!

Offline Masterhand

Re: New item: Red Ball
« Reply #6 on: November 19, 2006, 02:00:27 am »
$user = $row["memberName"], Ok, i'll try that.

EDIT: Nope, Parse error: syntax error, unexpected T_IF in /home/***/public_html/forum/Sources/shop/items/Redball2.php on line 59

 
« Last Edit: November 19, 2006, 02:03:27 am by Masterhand »
~If at first you don't succed, hide all evidence that you tried.~ - Homer Simpson

Offline Basil Beard

Re: New item: Red Ball
« Reply #7 on: November 19, 2006, 10:25:14 am »
So you added the semi colon after that? Strange. You shouldn't be getting that error. =(
Arrrrr!

Offline Masterhand

Re: New item: Red Ball
« Reply #8 on: November 19, 2006, 09:21:55 pm »
Yea, it is...
~If at first you don't succed, hide all evidence that you tried.~ - Homer Simpson

Lucid_Dream

  • Guest
Re: New item: Red Ball
« Reply #9 on: December 19, 2006, 08:27:52 am »
I tried to sort this out for you but only got this far

Code: [Select]
<?php

/**********************************************\
| SMFSHOP (Shop MOD for Simple Machines Forum) |
|         (c) 2006 DanSoft Australia           |
|      http://www.dansoftaustralia.net/        |
\**********************************************/

//File: Redball2.php

// VERSION: 2.3 (Build 11)
// $Date: 2006-11-17 13:34:18 +1000 (Fri, 17 Nov 2006) $
// $Id: Redball2.php 24 2006-10-21 03:34:18Z Mh $

class item_Redball2 extends itemTemplate {
    
    function 
getItemDetails() {

$this->authorName "Masterhand";
                
$this->authorWeb "http://www.gameandcoders.uni.cc";
$this->authorEmail "austin.r.tanay@gmail.com";

          
$this->name "RedBall2";
          
          
$this->desc "Redball 2";
          
// The item's price
          
$this->price 100;

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

    
      function 
getAddInput() {
        return 
"Max amount to give: <input type='text' name='info1' value='100'><br>
               Max amount to take: <input type='text' name='info2' value='-100'>"
;
    
}  


       function 
getUseInput() {
       
global 
$context$scripturl$settings$txt;
        return 
"Bounce To: <input type='text' name='stealfrom' size='50'>
         <a href='
{$scripturl}?action=findmember;input=stealfrom;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;
     
$result db_query("SELECT memberName
                                FROM 
{$db_prefix}members
                                WHERE ID_MEMBER = 
{$ID_MEMBER}"__FILE____LINE__);
     
$row mysql_fetch_array($resultMYSQL_ASSOC);
$user $row["memberName"];
       
       if (
$user == $_POST[&#8216;stealfrom&#8217;]) {
return "You cant throw it too yourself tbh!!!";
die();
  }

else {
$amount mt_rand($item_info[2], $item_info[1]);

$result db_query("UPDATE {$db_prefix}members
                                SET money = money + 
{$amount}
                                WHERE memberName = '
{$_POST[&#8216;stealfrom&#8217;]}'", __FILE__, __LINE__);

global $sourcedir;
require_once(
$sourcedir '/Subs-Post.php');

$result db_query("SELECT ID_MEMBER
       FROM 
{$db_prefix}members
                           WHERE memberName = '
{$_POST[&#8216;stealfrom&#8217;]}'", __FILE__, __LINE__);
$row mysql_fetch_array($resultMYSQL_ASSOC);
$pmfrom = array(
'id' => 1,
'name' => 'Masterhand',
'username' => 'Masterhand'
);
$pmto = array(
'to' => array($row['ID_MEMBER']),
'bcc' => array()
);
sendpm($pmto'Care For Some Ball?'"{$user} Bounces The Ball To You And You Lose ".formatMoney($amount)."! [i] You do not need to reply to this automated message"0$pmfrom);                                           
            }


  }
  }

?>


Can add the item to the shop and buy but when i go to use it does this

Quote
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')
ORDER BY mem.lngfile
LIMIT 0' at line 8
File: /home/sites/opiate2.com/public_html/forum/Sources/Subs-Post.php
Line: 739

Will look at it again l8r, ur only problem was some syntax errors from wat i saw.    Sorry if i overstepped myself but i wanted this item on my site and thought i'd give it a tinker.

Offline Daniel15

Re: New item: Red Ball
« Reply #10 on: December 20, 2006, 05:29:17 pm »
Code: [Select]
WHERE memberName = '{$_POST[‘stealfrom’]}'"That doesn't look right... That ‘ and ’ should probably be single quotes ( ' )

Lucid_Dream

  • Guest
Re: New item: Red Ball
« Reply #11 on: December 20, 2006, 10:09:14 pm »
Got it working.  Full code below

Code: [Select]
<?php

/**********************************************\
| SMFSHOP (Shop MOD for Simple Machines Forum) |
|         (c) 2006 DanSoft Australia           |
|      http://www.dansoftaustralia.net/        |
\**********************************************/

//File: Redball2.php

// VERSION: 2.3 (Build 11)
// $Date: 2006-11-17 13:34:18 +1000 (Fri, 17 Nov 2006) $
// $Id: Redball2.php 24 2006-10-21 03:34:18Z Mh $

class item_Redball2 extends itemTemplate {
    
    function 
getItemDetails() {

$this->authorName "Masterhand";
                
$this->authorWeb "http://www.gameandcoders.uni.cc";
$this->authorEmail "austin.r.tanay@gmail.com";

          
$this->name "RedBall2";
          
          
$this->desc "Redball 2";
          
// The item's price
          
$this->price 100;

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

    
      function 
getAddInput() {
        return 
"Max amount to give: <input type='text' name='info1' value='100'><br>
               Max amount to take: <input type='text' name='info2' value='-100'>"
;
    
}  


       function 
getUseInput() {
       
global 
$context$scripturl$settings$txt;
        return 
"Bounce To: <input type='text' name='stealfrom' size='50'>
         <a href='
{$scripturl}?action=findmember;input=stealfrom;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;
     
$result db_query("SELECT memberName
                                FROM 
{$db_prefix}members
                                WHERE ID_MEMBER = 
{$ID_MEMBER}"__FILE____LINE__);
     
$row mysql_fetch_array($resultMYSQL_ASSOC);
$user $row["memberName"];
       
       if (
$user == $_POST[&#8216;stealfrom&#8217;]) {
return "You cant throw it too yourself tbh!!!";
die();
  }

else {
$amount mt_rand($item_info[2], $item_info[1]);

$result db_query("UPDATE {$db_prefix}members
                                SET money = money + 
{$amount}
                                WHERE memberName = '
{$_POST['stealfrom']}'"__FILE____LINE__);
return 
"You've thrown the ball to {$_POST['stealfrom']} if he catches it he'll gain money, else he'll lose it!!!"
/*global $sourcedir;
require_once($sourcedir . '/Subs-Post.php');
*/
$result db_query("SELECT ID_MEMBER
       FROM 
{$db_prefix}members
                           WHERE memberName = '
{$_POST['stealfrom']}'"__FILE____LINE__);
$row mysql_fetch_array($resultMYSQL_ASSOC);
$pmfrom = array(
'id' => 1,
'name' => 'Masterhand',
'username' => 'Masterhand'
);
$pmto = array(
'to' => array($row['ID_MEMBER']),
'bcc' => array()
);
sendpm($pmto'Heres a redball?'"{$user} Bounces The Ball To You And You Lose/Win ".formatMoney($amount)."! [i] You do not need to reply to this automated message"0$pmfrom); ;                                          
            }

  }
  }

?>


Thanks to Masterhand for this great item
« Last Edit: December 20, 2006, 10:25:05 pm by Lucid_Dream »

Offline Masterhand

Re: New item: Red Ball
« Reply #12 on: December 21, 2006, 01:15:06 am »
Got it working.  Full code below

Code: [Select]
<?php

/**********************************************\
| SMFSHOP (Shop MOD for Simple Machines Forum) |
|         (c) 2006 DanSoft Australia           |
|      http://www.dansoftaustralia.net/        |
\**********************************************/

//File: Redball2.php

// VERSION: 2.3 (Build 11)
// $Date: 2006-11-17 13:34:18 +1000 (Fri, 17 Nov 2006) $
// $Id: Redball2.php 24 2006-10-21 03:34:18Z Mh $

class item_Redball2 extends itemTemplate {
    
    function 
getItemDetails() {

$this->authorName "Masterhand";
                
$this->authorWeb "http://www.gameandcoders.uni.cc";
$this->authorEmail "austin.r.tanay@gmail.com";

          
$this->name "RedBall2";
          
          
$this->desc "Redball 2";
          
// The item's price
          
$this->price 100;

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

    
      function 
getAddInput() {
        return 
"Max amount to give: <input type='text' name='info1' value='100'><br>
               Max amount to take: <input type='text' name='info2' value='-100'>"
;
    
}  


       function 
getUseInput() {
       
global 
$context$scripturl$settings$txt;
        return 
"Bounce To: <input type='text' name='stealfrom' size='50'>
         <a href='
{$scripturl}?action=findmember;input=stealfrom;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;
     
$result db_query("SELECT memberName
                                FROM 
{$db_prefix}members
                                WHERE ID_MEMBER = 
{$ID_MEMBER}"__FILE____LINE__);
     
$row mysql_fetch_array($resultMYSQL_ASSOC);
$user $row["memberName"];
       
       if (
$user == $_POST[&#8216;stealfrom&#8217;]) {
return "You cant throw it too yourself tbh!!!";
die();
  }

else {
$amount mt_rand($item_info[2], $item_info[1]);

$result db_query("UPDATE {$db_prefix}members
                                SET money = money + 
{$amount}
                                WHERE memberName = '
{$_POST['stealfrom']}'"__FILE____LINE__);
return 
"You've thrown the ball to {$_POST['stealfrom']} if he catches it he'll gain money, else he'll lose it!!!"
/*global $sourcedir;
require_once($sourcedir . '/Subs-Post.php');
*/
$result db_query("SELECT ID_MEMBER
       FROM 
{$db_prefix}members
                           WHERE memberName = '
{$_POST['stealfrom']}'"__FILE____LINE__);
$row mysql_fetch_array($resultMYSQL_ASSOC);
$pmfrom = array(
'id' => 1,
'name' => 'Masterhand',
'username' => 'Masterhand'
);
$pmto = array(
'to' => array($row['ID_MEMBER']),
'bcc' => array()
);
sendpm($pmto'Heres a redball?'"{$user} Bounces The Ball To You And You Lose/Win ".formatMoney($amount)."! [i] You do not need to reply to this automated message"0$pmfrom); ;                                          
            }

  }
  }

?>


Thanks to Masterhand for this great item

Your welcome xD, and thank you!  :)
~If at first you don't succed, hide all evidence that you tried.~ - Homer Simpson

Lucid_Dream

  • Guest
Re: New items: Red Balls
« Reply #13 on: December 21, 2006, 02:06:34 am »
Its no problem man, no need to give me credit, ur the one that coded it i just found the syntax error. 

Offline Masterhand

Re: New items: Red Balls
« Reply #14 on: December 21, 2006, 05:19:18 am »
Ok, but thanks anyway.
~If at first you don't succed, hide all evidence that you tried.~ - Homer Simpson