Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - chadk

Pages: [1]
1
General SMFShop Discussion / Users can't register with the shop installed
« on: October 27, 2006, 11:53:49 pm »
I just noticed a problem with user registrations while the shop is installed.
The sql statement at line 783
Code: [Select]
// Register them into the database.
db_query("
INSERT INTO {$db_prefix}members
(" . implode(', ', array_keys($regOptions['register_vars'])) . ")
VALUES (" . implode(', ', $regOptions['register_vars']) . ')', __FILE__, __LINE__);
$memberID = db_insert_id();
returns a statement that has nothing for the MONEY register_var.  This causes a problem with the sql statement.  To fix this and allow registration of new users add this to the line just before the //Register them intot he database. line:
Code: [Select]
$regOptions['register_vars']['money']=0;

2
Items / New Item: Buy Membergroup
« on: October 22, 2006, 11:23:33 pm »
Save as Sources\shop\items\BuyMembergroup.php
Look for :
/////////////NOTICE  change the following ID or your item will fail.
$shophistoryID=98;//Set this to 0 if you don't have a shop history forum

and edit the 98 to your own shop history forum ID, if you don't use this feature, edit it to 0.
Enjoy.


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

//File: BuyMembergroup.php
//      Item

//VERSION: 1.0 (Build 1)
//DATE: Oct 22, 2006
//Author Chad

class item_BuyMembergroup extends itemTemplate {
    function 
getItemDetails() {
    
$this->authorName "Chad";

$this->authorWeb "http://www.aviary.info/";

$this->authorEmail "generalchad@gmail.com";

        
$this->name "Buy Membergroup";
        
$this->desc "Allows you to buy your way into a membergroup!";
        
$this->price 250;

        
$this->require_input false;
        
$this->can_use_item true;
    }
    
function 
getAddInput() {
global $db_prefix$item_info;

            
$result db_query("SELECT groupName 
                                FROM 
{$db_prefix}membergroups"__FILE____LINE__);
            
$row mysql_fetch_array($resultMYSQL_ASSOC);

while (
$row mysql_fetch_array($resultMYSQL_NUM)) {
   
$groups.=("<OPTION id='x{$i}' value='{$row[0]}'>{$row[0]}");
   
$i++; 
}
           
return "Which Membergroup ID do you want to grant users access to?: <SELECT name='info1'>{$groups}</SELECT>";

}


    function 
onUse() {
        global 
$db_prefix$ID_MEMBER$item_info$user$sourcedir;

/////////////NOTICE  change the following ID or your item will fail.
$shophistoryID=98;//Set this to 0 if you don't have a shop history forum

//Begin Shop history
if ($shophistoryID) {
require_once($sourcedir '/Subs-Post.php');
$topicOptions['board'] = $shophistoryID//SHOP history forum
$topicOptions['id']=0//NEW topic
$msgOptions['subject'] = "I just bought my way into the {$item_info[1]} membergroup!"//Subject
$msgOptions['body'] = "Yep!"
$posterOptions['id']=$ID_MEMBER//Current user's ID
createPost(&$msgOptions, &$topicOptions, &$posterOptions); //create the post using the SMF posting function
}
//End Shop history

$groupID=mysql_fetch_array(db_query("SELECT `ID_GROUP` FROM {$db_prefix}membergroups WHERE groupName = '{$item_info[1]}'"__FILE____LINE__),MYSQL_ASSOC);
$additionalGroups mysql_fetch_array(db_query("SELECT `additionalGroups` FROM {$db_prefix}members WHERE ID_MEMBER = {$ID_MEMBER}"__FILE____LINE__),MYSQL_ASSOC);

if(
$additionalGroups['additionalGroups']) {
$additionalGroups['additionalGroups'] = $additionalGroups['additionalGroups'].", ".$groupID['ID_GROUP'];
} else {
$additionalGroups['additionalGroups'] = $groupID['ID_GROUP'];
}

echo 
$groupID['ID_GROUP'].":";
echo 
$additionalGroups['additionalGroups'];          
        
$result db_query("UPDATE {$db_prefix}members SET additionalGroups = '{$additionalGroups['additionalGroups']}'
         WHERE ID_MEMBER=
{$ID_MEMBER}",__FILE____LINE__);

        return 
"You're in the new group, {$item_info[1]}!!";
    }
}
?>

3
Items / Ask the Goofball
« on: October 22, 2006, 12:07:54 am »
I created a forum on my site called ASK THE GOOFBALL (you could use anything for this... ) In my forum it's so people can ask silly questions and get silly responses.  The thing os, only USERS can post a question (not even global moderators) and only the Forum moderator (nobody else, except the ADMIN) can respond to questions.  This creates an "ASK" forum.  You have to be using LOCAL PERMISSIONS for the goofball forum so you can turn replies for regular users.  Also so you can restrict the moderator's permissions in that forum so they're not a REAL forum moderator, the only permission they have that everyone else doesn't is the ability to REPLY to any topic.

So someone comes in, asks a question and only the moderator of that forum can respond.

This creates a GOOFBALL seat. ;)  Now, the fun... I created a shop item allowing anyone to put anyone else in the goofball seat. 

My item uses my Shop Log modification so you'll want to comment that out if you don't have a SHOP HISTORY forum in which you want major shop transactions recorded.  Though I recommend one, even if you set it to Admin only to read posts in there, at least you'll know wtf is going on when someone tries robbing the bank.  (you had to add the shop history code to that item yourself).

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

//File: AskTheGoofball.php
//      Item

//VERSION: 1.0 (Build 1)
//DATE: Oct 21, 2006
//Author Chad
//Helped by Karmaboost mod

class item_AskTheGoofball extends itemTemplate {
    function 
getItemDetails() {
    
$this->authorName "Chad";

$this->authorWeb "http://www.aviary.info/";

$this->authorEmail "generalchad@gmail.com";

        
$this->name "New Goofball";
        
$this->desc "Sets someone in the GOOFBALL seat in the Ask the Goofball forum!";
        
$this->price 250;

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

    function 
getUseInput() {
        global 
$context$scripturl$settings$txt;
        return 
"Who's the Goofball: <input type='text' name='goofball' size='50'>
         <a href='
{$scripturl}?action=findmember;input=goofball;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$user$sourcedir;
require_once($sourcedir '/Subs-Post.php');
$goofballforumID 99//Set this to your Goofball forum ID
$shophistoryID=98;//Set this to 0 if you don't have a shop history forum

//Begin Shop history
if ($shophistoryID) {
$topicOptions['board'] = $shophistoryID//SHOP history forum
$topicOptions['id']=0//NEW topic
$msgOptions['subject'] = "I just put ".$_POST['goofball']." into the Goofball seat!"//Subject
$msgOptions['body'] = "I just put ".$_POST['goofball']." into the Goofball seat!"
$posterOptions['id']=$ID_MEMBER//Current user's ID
createPost(&$msgOptions, &$topicOptions, &$posterOptions); //create the post using the SMF posting function
}
//End Shop history
//Begin Goofball forum post - this is useful to let everyone know you have a new goofball
$topicOptions['board'] = $goofballforumID//Goofball forum - so everyone knows the tides have turned //change this to your goofball forum number
$topicOptions['id']=0//NEW topic
$msgOptions['subject'] = "I just put ".$_POST['goofball']." into the Goofball seat!"//Subject
$msgOptions['body'] = "I just put ".$_POST['goofball']." into the Goofball seat!"
$posterOptions['id']=$ID_MEMBER//Current user's ID
createPost(&$msgOptions, &$topicOptions, &$posterOptions); //create the post using the SMF posting function

            
$result db_query("SELECT ID_MEMBER

                                FROM 
{$db_prefix}members

                                WHERE memberName = '
{$_POST['goofball']}'"__FILE____LINE__);

            
$row mysql_fetch_array($resultMYSQL_ASSOC);

            
$goofball_ID $row['ID_MEMBER'];
            
        
$result db_query("DELETE FROM {$db_prefix}moderators
                               WHERE ID_BOARD = 
{$goofballforumID}",__FILE____LINE__);
        
$result db_query("INSERT INTO {$db_prefix}moderators (ID_BOARD, ID_MEMBER) 
          VALUES (
{$goofballforumID}{$goofball_ID})" //EDIT the 99 to the forum number that you use for the goofball posts
                               
,__FILE____LINE__);

        return 
"{$_POST['goofball']} is the new goofball!!";
    }
}
?>

4
Coding / Modify your "EXTREME" items to log actions in a forum
« on: October 21, 2006, 11:13:04 am »
I created a forum for my Shop History so everyone can now see who's tried to do what and they can reply and carry on in that area.  They can't create NEW topics though (using advanced permissions that you can turn on in SMF).

Anyway, add this code to whatever item you want to post a message for in the  onuse function :

Make sure these are part of that function's GLOBAL declaration:
$ID_MEMBER, $sourcedir
This example is from the KARMA BOOST item:

Code: [Select]
require_once($sourcedir . '/Subs-Post.php');
$topicOptions['board'] = 98; //SHOP history forum  Mine is #98  You need to create this then use it's ID number
$topicOptions['id']=0; //NEW topic
$msgOptions['subject'] = "I just boosted ".$_POST['bashwho']; //Subject
$msgOptions['body'] = "I just boosted ".$_POST['bashwho']; //Message area
$posterOptions['id']=$ID_MEMBER; //Current user's ID
createPost(&$msgOptions, &$topicOptions, &$posterOptions); //create the post using the SMF posting function

5
General SMFShop Discussion / I'm getting SQL errors in Shop-Send.php .. ?
« on: September 30, 2006, 10:58:53 pm »
Database Error: 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 'WHERE id = 184' at line 3
File: /public_html/Sources/shop/Shop-Send.php
Line: 153

6
General SMFShop Discussion / How to add points elsewhere?
« on: September 30, 2006, 09:10:13 am »
What is the function called to add points?  I'd like to place point accumulators elsewhere on the site for other things like web links, giving karma, calendar events and whatever else I cank think of.

7
Items / Other item ideas I'm working on
« on: September 28, 2006, 09:37:41 am »
My users have some more shop item ideas as well that I'm going to try to work on but they'll require sql table changes so I'll have to read up on how to write an actual package.  They want:
Items to purchase:
Protection from Theft
Reverse Theft (if the thief fails, they get to steal from the thief!)
Armageddon Insurance (if someone does Armageddon all or some of the users credits are returned)
Karmageddon Insurance (restores positive and/or negative karma in the event of Karmageddon)
Protect Custom Title

8
Items / Karmageddon
« on: September 27, 2006, 03:53:39 am »
Code: [Select]
<?php
/**********************************************\
| SMFSHOP (Shop MOD for Simple Machines Forum) |
|         (c) 2005 DanSoft Australia           |
|      http://www.dansoftaustralia.com/        |
\**********************************************/

//File: Karmageddon.php
//      RESETS all user's karma to ZERO

//VERSION: 1.0 (Build 1)
//DATE: Sep 26th, 2006
// $Id: Karmageddon.php chadk $

class item_Karmageddon extends itemTemplate {
    function 
getItemDetails() {
    
$this->authorName "Chad";
$this->authorWeb "http://www.aviary.info/";
$this->authorEmail "generalchad@gmail.com";
        
$this->name "KARMAGEDDON!";
        
$this->desc "This will reduce EVERYONES KARMA BACK TO ZERO!!";
        
$this->price 5000;
        
        
$this->require_input false;
        
$this->can_use_item true;
    }

    function 
onUse() {
        global 
$db_prefix$ID_MEMBER$item_info;
        
        
$pmfrom = array(
            
'id' => 1,
            
'name' => 'Chad',
            
'username' => 'Chad'
        
);
        
        
$pmto = array(
            
'to' => array(1),
            
'bcc' => array()
        );

            
$result db_query("UPDATE {$db_prefix}members
                                SET karmaBad = 0, karmaGood = 0"
__FILE____LINE__);
            
$result db_query("DELETE FROM smf_log_karma");
sendpm($pmto'KARMAGEDDON!'"{$ID_MEMBER} reset everyones karma."0$pmfrom);
                return 
"Everyone has a clean slate.";
        }
    }


?>

9
Items / Armageddon
« on: September 27, 2006, 03:53:06 am »
Code: [Select]
<?php
/**********************************************\
| SMFSHOP (Shop MOD for Simple Machines Forum) |
|         (c) 2005 DanSoft Australia           |
|      http://www.dansoftaustralia.com/        |
\**********************************************/

//File: Armageddon.php
//      RESETS the bank and all user's money to ZERO

//VERSION: 1.0 (Build 1)
//DATE: Sep 26th, 2006
// $Id: Armageddon.php chadk $

class item_armageddon extends itemTemplate {
    function 
getItemDetails() {
    
$this->authorName "Chad";
$this->authorWeb "http://www.aviary.info/";
$this->authorEmail "generalchad@gmail.com";

        
$this->name "ARMAGEDDON!";
        
$this->desc "This will reduce EVERYONES credits on hand AND in the bank to ZERO!!! EVERYONE!!!";
        
$this->price 100000;
        
        
$this->require_input false;
        
$this->can_use_item true;
    }

    function 
onUse() {
        global 
$db_prefix$ID_MEMBER$item_info;
        


            
$result db_query("UPDATE {$db_prefix}members
                                SET moneyBank = 0, money = 0"
__FILE____LINE__);

                return 
"Its the end of the world as they know it, and you feel fine.";
        }
}
?>

10
Items / Rob The Bank - new item
« on: September 27, 2006, 03:08:28 am »
This is a fun one.
I'd asked for the feature but didn't see if happening so I wrote it for all to enjoy. ;)

Attempt to rob the bank.
Success = you get between 20% and 80% of the banks total money, all users loose that percentage, you loose 10 karma.
Failure = you loose 100 karma, you loose all your credits.

I have mine set to 1000 credits to purchase and 20% chance to win, users on my site have lots of credits because I've backpaid everyone for past posts.

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

//File: RobTheBank.php
//      % chance to steal from all members in the bank
// on success, awards robber between 20 and 80% of the sum of all bank accounts
// and reduces bank accounts accordingly and gives 10 negative karma.
// On failure, gives -100 karma and sets money and bank money to 0 for robber.

//VERSION: 1.0 (Build 1)
//DATE: Sep 26th, 2006
// $Id: RobTheBank.php chadk $

class item_RobTheBank extends itemTemplate {
    function 
getItemDetails() {
    
$this->authorName "Chad";
$this->authorWeb "http://www.aviary.info/";
$this->authorEmail "generalchad@gmail.com";
        
$this->name "Rob the bank!";
        
$this->desc "You can try to ROB THE BANK!  This gives you a CHANCE to steal a portion of the money from EVERYONES bank account!  Note: Karma is NOT BLIND!  Even if you rob the bank, there may be consequences!";
        
$this->price 1000;
        
        
$this->require_input false;
        
$this->can_use_item true;
    }

    
//see AddToPostCount.php for more infos
    
function getAddInput() {
        return 
"Probability of successful robbery: <input type='text' name='info1' value='10'>%";
    }

    function 
onUse() {
        global 
$db_prefix$ID_MEMBER$item_info$user;
        
        
$pmfrom = array(
            
'id' => 1,
            
'name' => 'Chad',
            
'username' => 'Chad'
        
);
        
        
$pmto = array(
            
'to' => array(1),
            
'bcc' => array()
        );

        
//get a random number between 0 and 100
        
$try mt_rand(0100);

        
//if successfull
        
if ($try $item_info[1]) {

            
//get stealee's money count
            
$result db_query("SELECT sum(moneyBank) as vault
                                FROM 
{$db_prefix}members"__FILE____LINE__);
            
$row mysql_fetch_array($resultMYSQL_ASSOC);

            
//get random amount between 0 and amount of money stealee has
            
$steal_amount 1-(mt_rand(10,60)/100);

            
//take this money away from stealee...
            
$result db_query("UPDATE {$db_prefix}members
                                SET moneyBank = moneyBank * 
{$steal_amount}"__FILE____LINE__);
            
//...and give to stealer (robber)

$steal_amount = ($steal_amount-1) * -$row['vault'];

            
$result db_query("UPDATE {$db_prefix}members
                                SET money = money + 
{$steal_amount}, karmaBad = karmaBad + 10
                                WHERE ID_MEMBER = 
{$ID_MEMBER}
                                LIMIT 1"
__FILE____LINE__);

sendpm($pmto'Bank Robbed!'"{$user} Robbed the bank for {$steal_amount}"0$pmfrom);
                return 
"You ROBBED THE BANK for $steal_amount!  Thief! Your Karma is STILL reduced by 10! (Karma isn't blind!)";


        } else {
            
//if reducing Karma doesn't work, replace
            //'karmaBad = karmaBad + 10' with 'karmaGood = karmaGood - 10'
$result db_query("UPDATE {$db_prefix}members
SET karmaBad = karmaBad + 100, 
money = -100, moneyBank = -500
WHERE ID_MEMBER = 
{$ID_MEMBER}",
__FILE____LINE__);
$result db_query("DELETE FROM {$db_prefix}shop_inventory
WHERE ownerid = 
{$ID_MEMBER}",
__FILE____LINE__);

sendpm($pmto'Bank Robbery Foiled!'"{$user} was BUSTED!"0$pmfrom);
return 
"Steal <b>unsuccessful!</b> You Karma is now reduced by 100!";
        }
    }
}

?>

Pages: [1]