SMF Shop

SMFShop => Items => Topic started by: xfollowthereaperx on February 20, 2007, 07:09:38 am

Title: Insurance (Still needs work!)
Post by: xfollowthereaperx on February 20, 2007, 07:09:38 am
Huge thanks to Basil Beard and TechnoDragon for making this item
The item is still in testing

With this item no one can bash your karma, steal your credits, change your member title,  or rob your bank.

Install the package
If you would like insurance from an item that isn't listed then edit one of theses two into the item.

Add this code to each item you want insurances to block (Single member affects, ie: steal your credits, bash karma)

Code: [Select]
$result = db_query("SELECT insurance from {$db_prefix}members WHERE id_member = ($_POST['target'])", __FILE__, __LINE__);
$row = mysql_fetch_assoc($result);
if ($row > 0) {
     db_query("UPDATE {$db_prefix}members SET insurance = (insurance - 1) WHERE id_member = ($_POST['target']))", __FILE__, __LINE__);

     return "That user has insurance, and wasn't affected.";
}
else {
//rest of code goes here
}


And as for multiple member affects, (ie: Rob the bank, Karmageddon)

Code: [Select]
$result = db_query("SELECT insurance from {$db_prefix}members WHERE id_member = ($_POST['target'])", __FILE__, __LINE__);
$row = mysql_fetch_assoc($result);
if ($row > 0) {
     db_query("UPDATE {$db_prefix}members SET insurance = (insurance - 1) WHERE insurance > 0)", __FILE__, __LINE__);

     return "Some users have insurance and weren't affected.";
}
else {
//rest of code goes here
}
Title: Re: Idea: Insurance
Post by: Basil Beard on February 20, 2007, 12:41:19 pm
Yes. It would be possible.

Basically, you would want to add a column to the smf_members table called "insurance" or something like that. It would store a 1 if they are insured, and a 0 if not. You would then have to edit the code to all of those items with something like

Code: [Select]
$result = db_query("SELECT insurance from {$db_prefix}members WHERE id_member = ($_POST['target'])", __FILE__, __LINE__);
$row = mysql_fetch_assoc($result);
if ($row == 1) {
     return "That user has insurance";
}
else {
//rest of code goes here
}

Of course, an item like tha would be rather powerful. so you might want to consider either making it work only a certain amount of the time, or make it die after a certain amount of ti,e.
Title: Re: Idea: Insurance
Post by: xfollowthereaperx on February 20, 2007, 01:38:50 pm
Hmm, I know how to add the code to each item I want insurance from but I'm not sure how to code the item. If someone would be nice enough to code it I'd give them a big old hug
Title: Re: Idea: Insurance
Post by: Basil Beard on February 20, 2007, 11:32:07 pm
Code: [Select]
$result = db_query(SELECT insurance FROM {$db_prefix}members WHERE ID_MEMBER = {$ID_MEMBER}", __FILE__, __LINE__);
$row = mysql_fetch_assoc($result);
if ($row['insurance'] == 1) {
     return "you are already insured";
}
else {
     $result = db_query(UPDATE {$db_prefix}members SET insurance = 1 WHERE ID_MEMBER = {$ID_MEMBER}", __FILE__, __LINE__);
     return "You are now insured!";
}
Title: Re: Idea: Insurance
Post by: xfollowthereaperx on February 21, 2007, 08:39:51 am
Is there a tutorial on time expiring items?
Title: Re: Idea: Insurance
Post by: xfollowthereaperx on February 21, 2007, 08:51:46 am
Here is the code, not working though  :buck2:

Code: [Select]
<?php
/**********************************************************************************
* SMFShop item                                                                    *
***********************************************************************************
* SMFShop: Shop MOD for Simple Machines Forum                                     *
* =============================================================================== *
* Software Version:           SMFShop 3.0 (Build 12)                              *
* $Date:: 2007-01-18 19:26:55 +1100 (Thu, 18 Jan 2007)                          $ *
* $Id:: Insurance.php         79 2007-01-18 08:26:55Z daniel15                  $ *
* Software by:                DanSoft Australia (http://www.dansoftaustralia.net/)*
* Copyright 2005-2007 by:     DanSoft Australia (http://www.dansoftaustralia.net/)*
* Support, News, Updates at:  http://www.dansoftaustralia.net/                    *
*                                                                                 *
* Forum software by:          Simple Machines (http://www.simplemachines.org)     *
* Copyright 2006-2007 by:     Simple Machines LLC (http://www.simplemachines.org) *
*           2001-2006 by:     Lewis Media (http://www.lewismedia.com)             *
***********************************************************************************
* This program is free software; you may redistribute it and/or modify it under   *
* the terms of the provided license as published by Simple Machines LLC.          *
*                                                                                 *
* This program is distributed in the hope that it is and will be useful, but      *
* WITHOUT ANY WARRANTIES; without even any implied warranty of MERCHANTABILITY    *
* or FITNESS FOR A PARTICULAR PURPOSE.                                            *
*                                                                                 *
* See the "license.txt" file for details of the Simple Machines license.          *
* The latest version of the license can always be found at                        *
* http://www.simplemachines.org.                                                  *
**********************************************************************************/

if (!defined('SMF'))
die('Hacking attempt...');

// 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_Insurance extends itemTemplate
{

// When this function is called, you should set all the item's
// variables (see inside this example)
function getItemDetails()
{

// The author of the item
$this->authorName 'xfollowthereaperx';
// The author's website
$this->authorWeb '';
// And their email address
$this->authorEmail 'xfollowthereaperx@hotmail.com';


// VALUES CHANGEABLE FROM WITHIN ADMIN PANEL:
  // The name of the item
  $this->name 'Insurance';
  // The item's description
  $this->desc 'Buy this item to stop negitive affects from other users';
  // The item's price
  $this->price 1000;
  
//UNCHANGEABLE VALUES:
  // Whether the item requires input or not.
  $this->require_input false;
  // Useable?
  $this->can_use_item true;

// Since this item requires no input, we don't need to have a getUseInput function

$result db_query(SELECT insurance FROM {$db_prefix}members WHERE ID_MEMBER = {$ID_MEMBER}", __FILE__, __LINE__);
$row = mysql_fetch_assoc($result);
if (
$row['insurance'] == 1) {
     return "
you are already insured";
}
else {
     
$result = db_query(UPDATE {$db_prefix}members SET insurance = 1 WHERE ID_MEMBER = {$ID_MEMBER}"__FILE____LINE__);
     return 
"You are now insured!";
}

?>

Title: Re: Idea: Insurance
Post by: TechnoDragon on February 21, 2007, 02:03:01 pm
cool item, but the main issue would be figuring out how to set some kind of counter so it expires...

EDIT

Ok, here's an idea, still add the new field to the member table, but istead of doing just a one, have it a number set in the admin panel for items...so anything from say 1 to ten.  then in the query for the items that insurance would protect them, you would have the query look for insurance where it is greater than zero.  if it is, then they are insured, and the the same query would then deduct one from the total, until it reached zero...at which point they would no longer be insured
Title: Re: Idea: Insurance
Post by: xfollowthereaperx on February 21, 2007, 03:56:13 pm
cool item, but the main issue would be figuring out how to set some kind of counter so it expires...

EDIT

Ok, here's an idea, still add the new field to the member table, but istead of doing just a one, have it a number set in the admin panel for items...so anything from say 1 to ten.  then in the query for the items that insurance would protect them, you would have the query look for insurance where it is greater than zero.  if it is, then they are insured, and the the same query would then deduct one from the total, until it reached zero...at which point they would no longer be insured
You could also do that, but I'd much rather have it timed because some of my items are cheaper and if they used to to take someone's insurance it would be very inexpensive.

But I suppose the insurance item is very cheap and very effective in the first place.
Title: Re: Insurance (Still needs work!)
Post by: xfollowthereaperx on February 21, 2007, 04:08:18 pm
Also it would need a script for items like Karmageddon.
Title: Re: Insurance (Still needs work!)
Post by: TechnoDragon on February 21, 2007, 09:52:44 pm
Well here is the conceptual code for the items...

Code: [Select]
$result = db_query("SELECT insurance from {$db_prefix}members WHERE id_member = ($_POST['target'])", __FILE__, __LINE__);
$row = mysql_fetch_assoc($result);
if ($row > 0) {
     db_query("UPDATE {$db_prefix}members SET insurance = (insurance - 1))", __FILE__, __LINE__);

     return "That user has insurance";
}
else {
//rest of code goes here
}
Title: Re: Insurance (Still needs work!)
Post by: xfollowthereaperx on February 22, 2007, 04:09:01 am
Well here is the conceptual code for the items...

Code: [Select]
$result = db_query("SELECT insurance from {$db_prefix}members WHERE id_member = ($_POST['target'])", __FILE__, __LINE__);
$row = mysql_fetch_assoc($result);
if ($row > 0) {
     db_query("UPDATE {$db_prefix}members SET insurance = (insurance - 1))", __FILE__, __LINE__);

     return "That user has insurance";
}
else {
//rest of code goes here
}

Then I guess if an item effects all members like 'rob the bank' then it would be written like this?

Code: [Select]
$result = db_query("SELECT insurance from {$db_prefix}members WHERE id_member = ($_POST['target'])", __FILE__, __LINE__);
$row = mysql_fetch_assoc($result);
if ($row > 0) {
     db_query("UPDATE {$db_prefix}members SET insurance = (insurance - 1))", __FILE__, __LINE__);

     return "Some users have insurance and weren't affected.";
}
else {
//rest of code goes here
}
Title: Re: Insurance (Still needs work!)
Post by: TechnoDragon on February 22, 2007, 06:11:53 am
Close....

ok, for the specific member the query would look like this....
Code: [Select]
$result = db_query("SELECT insurance from {$db_prefix}members WHERE id_member = ($_POST['target'])", __FILE__, __LINE__);
$row = mysql_fetch_assoc($result);
if ($row > 0) {
     db_query("UPDATE {$db_prefix}members SET insurance = (insurance - 1) WHERE id_member = ($_POST['target']))", __FILE__, __LINE__);

     return "That user has insurance";
}
else {
//rest of code goes here
}

for items like rob the bank, then you would use this one...
Code: [Select]
$result = db_query("SELECT insurance from {$db_prefix}members WHERE id_member = ($_POST['target'])", __FILE__, __LINE__);
$row = mysql_fetch_assoc($result);
if ($row > 0) {
     db_query("UPDATE {$db_prefix}members SET insurance = (insurance - 1) WHERE insurance > 0)", __FILE__, __LINE__);

     return "That user has insurance";
}
else {
//rest of code goes here
}

Otherwise you run the risk of setting every members insurance field...even the ones that were zero...those checks keep that from happening
Title: Re: Insurance (Still needs work!)
Post by: xfollowthereaperx on February 22, 2007, 06:13:47 am
Close....

ok, for the specific member the query would look like this....
Code: [Select]
$result = db_query("SELECT insurance from {$db_prefix}members WHERE id_member = ($_POST['target'])", __FILE__, __LINE__);
$row = mysql_fetch_assoc($result);
if ($row > 0) {
     db_query("UPDATE {$db_prefix}members SET insurance = (insurance - 1) WHERE id_member = ($_POST['target']))", __FILE__, __LINE__);

     return "That user has insurance";
}
else {
//rest of code goes here
}

for items like rob the bank, then you would use this one...
Code: [Select]
$result = db_query("SELECT insurance from {$db_prefix}members WHERE id_member = ($_POST['target'])", __FILE__, __LINE__);
$row = mysql_fetch_assoc($result);
if ($row > 0) {
     db_query("UPDATE {$db_prefix}members SET insurance = (insurance - 1) WHERE insurance > 0)", __FILE__, __LINE__);

     return "That user has insurance";
}
else {
//rest of code goes here
}

Otherwise you run the risk of setting every members insurance field...even the ones that were zero...those checks keep that from happening
Okay, I'll update it


Now we need to work on the item  ::)
Title: Re: Insurance (Still needs work!)
Post by: xfollowthereaperx on February 22, 2007, 06:24:19 am
Also, the code you're giving makes it so that the item you use on someone who has insurance fails and is delete, correct?
Title: Re: Insurance (Still needs work!)
Post by: TechnoDragon on February 22, 2007, 06:30:34 am
well, with a slight modification to the first part, yes you could have the item delete from inventory if the person they use it on has insurance
Title: Re: Insurance (Still needs work!)
Post by: xfollowthereaperx on February 22, 2007, 06:44:15 am
Here is what I've got to far for the whole item, I'm probably missing something very simple  :uglystupid2:

Code: [Select]
<?php
/**********************************************************************************
* SMFShop item                                                                    *
***********************************************************************************
* SMFShop: Shop MOD for Simple Machines Forum                                     *
* =============================================================================== *
* Software Version:           SMFShop 3.0 (Build 12)                              *
* $Date:: 2007-01-18 19:26:55 +1100 (Thu, 18 Jan 2007)                          $ *
* $Id:: Insurance.php         79 2007-01-18 08:26:55Z daniel15                  $ *
* Software by:                DanSoft Australia (http://www.dansoftaustralia.net/)*
* Copyright 2005-2007 by:     DanSoft Australia (http://www.dansoftaustralia.net/)*
* Support, News, Updates at:  http://www.dansoftaustralia.net/                    *
*                                                                                 *
* Forum software by:          Simple Machines (http://www.simplemachines.org)     *
* Copyright 2006-2007 by:     Simple Machines LLC (http://www.simplemachines.org) *
*           2001-2006 by:     Lewis Media (http://www.lewismedia.com)             *
**********************************************************************************/

if (!defined('SMF'))
die('Hacking attempt...');

// Your class should always be called item_filename
class item_Insurance extends itemTemplate
{

// When this function is called, you should set all the item's
// variables (see inside this example)
function getItemDetails()
{

// The author of the item
$this->authorName 'xfollowthereaperx5';
// The author's website
$this->authorWeb '';
// And their email address
$this->authorEmail 'xfollowtehreaperx@hotmail.com';


// VALUES CHANGEABLE FROM WITHIN ADMIN PANEL:
  // The name of the item
  $this->name 'Insurance';
  // The item's description
  $this->desc 'Prevents negitive affects from occuring to you, one time use.';
  // The item's price
  $this->price 500;
  
//UNCHANGEABLE VALUES:
  // Whether the item requires input or not. In this case, we don't need
  // any input
  $this->require_input false;
  // Since this is a rock (you can't use it), we set this to false
  $this->can_use_item true;


// Since this item requires no input, we don't need to have a getUseInput function
// here (see the testitem2.php file if you want to make an item that needs input)

// Also, since this is a rock, you don't need an onUse function (since it doesn't get used)
$result db_query(SELECT insurance FROM {$db_prefix}members WHERE ID_MEMBER = {$ID_MEMBER}", __FILE__, __LINE__);
$row = mysql_fetch_assoc($result);
if (
$row['insurance'] == 1) {
     return "
you are already insured";}
else {
     
$result = db_query(UPDATE {$db_prefix}members SET insurance = 1 WHERE ID_MEMBER = {$ID_MEMBER}"__FILE____LINE__);
     return 
"You are now insured!";}

?>

Title: Re: Insurance (Still needs work!)
Post by: TechnoDragon on February 22, 2007, 06:52:06 am
ok, well for the items that you want insurance to protect from here's an example...

This is from the steal.php item...

here is the original onuse function:
Code: [Select]
    function onUse() {
        global $db_prefix, $ID_MEMBER, $item_info, $sourcedir, $user_info;

// Check some inputs
if (!isset($_POST['stealfrom']) || $_POST['stealfrom'] == '') die("ERROR: Please enter a username to steal from!");
       
        // Get a random number between 0 and 100
        $try = mt_rand(0, 100);

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

            // Get stealee's money count
            $result = db_query("SELECT money
                                FROM {$db_prefix}members
                                WHERE memberName = '{$_POST['stealfrom']}'", __FILE__, __LINE__);

// If user doesn't exist
if (mysql_num_rows($result) == 0) die("ERROR: The specified user doesn't exist!");

            $row = mysql_fetch_array($result, MYSQL_ASSOC);



            // Get random amount between 0 and amount of money stealee has
            $steal_amount = mt_rand(0, $row['money']);

            // Take this money away from stealee...
            $result = db_query("UPDATE {$db_prefix}members
                                SET money = money - {$steal_amount}
                                WHERE memberName = '{$_POST['stealfrom']}'
                                LIMIT 1", __FILE__, __LINE__);
            //...and give to stealer (robber)
            $result = db_query("UPDATE {$db_prefix}members
                                SET money = money + {$steal_amount}
                                WHERE ID_MEMBER = {$ID_MEMBER}
                                LIMIT 1", __FILE__, __LINE__);

            if($steal_amount < 50){
                return "Steal successful, although you only stole {$steal_amount}!";
            } else {
require_once($sourcedir . '/Subs-Post.php');
$topicOptions['board'] = 127; //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 am a Thief {$user_info['username']}"; //Subject
$msgOptions['body'] = "{$user_info['username']} just used a sticky hand and stole {$steal_amount} from ".$_POST['stealfrom']; //Message area
  $msgOptions['icon'] = 'exclamation';
$posterOptions['id']=$ID_MEMBER; //Current user's ID
createPost(&$msgOptions, &$topicOptions, &$posterOptions); //create the post using the SMF posting function
                return "Successfully stole $steal_amount from {$_POST['stealfrom']}! It's their fault they don't have their money in the bank!";
            }
        } 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 + 10
                               WHERE ID_MEMBER = {$ID_MEMBER}",
                               __FILE__, __LINE__);
           return "Steal <b>unsuccessful!</b> You Karma is now reduced by 10!";
        }
    }
}

and here is how the new function looks with the insurance check added in...

Code: [Select]
    function onUse() {
        global $db_prefix, $ID_MEMBER, $item_info, $sourcedir, $user_info;

// Check some inputs
if (!isset($_POST['stealfrom']) || $_POST['stealfrom'] == '') die("ERROR: Please enter a username to steal from!");
       
        // Get a random number between 0 and 100
        $try = mt_rand(0, 100);

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

            // Get stealee's money count
            $result = db_query("SELECT money, insurance
                                FROM {$db_prefix}members
                                WHERE memberName = '{$_POST['stealfrom']}'", __FILE__, __LINE__);

// If user doesn't exist
if (mysql_num_rows($result) == 0) die("ERROR: The specified user doesn't exist!");

            $row = mysql_fetch_array($result, MYSQL_ASSOC);

if ($row['insurance'] > 0) {
      db_query("UPDATE {$db_prefix}members SET insurance = (insurance - 1) WHERE insurance > 0 AND memberName = '{$_POST['stealfrom']}'", __FILE__, __LINE__);

      return "That user has insurance";
}
else {
            // Get random amount between 0 and amount of money stealee has
            $steal_amount = mt_rand(0, $row['money']);

            // Take this money away from stealee...
            $result = db_query("UPDATE {$db_prefix}members
                                SET money = money - {$steal_amount}
                                WHERE memberName = '{$_POST['stealfrom']}'
                                LIMIT 1", __FILE__, __LINE__);
            //...and give to stealer (robber)
            $result = db_query("UPDATE {$db_prefix}members
                                SET money = money + {$steal_amount}
                                WHERE ID_MEMBER = {$ID_MEMBER}
                                LIMIT 1", __FILE__, __LINE__);
}
            if($steal_amount < 50){
                return "Steal successful, although you only stole {$steal_amount}!";
            }
else {
require_once($sourcedir . '/Subs-Post.php');
$topicOptions['board'] = 127; //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 am a Thief {$user_info['username']}"; //Subject
$msgOptions['body'] = "{$user_info['username']} just used a sticky hand and stole {$steal_amount} from ".$_POST['stealfrom']; //Message area
  $msgOptions['icon'] = 'exclamation';
$posterOptions['id']=$ID_MEMBER; //Current user's ID
createPost(&$msgOptions, &$topicOptions, &$posterOptions); //create the post using the SMF posting function
                return "Successfully stole $steal_amount from {$_POST['stealfrom']}! It's their fault they don't have their money in the bank!";
}
        }
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 + 10
                               WHERE ID_MEMBER = {$ID_MEMBER}",
                               __FILE__, __LINE__);
           return "Steal <b>unsuccessful!</b> You Karma is now reduced by 10!";
        }
    }
}


I will work on the actual item itself here shortly...you have a good start though!
Title: Re: Insurance (Still needs work!)
Post by: xfollowthereaperx on February 22, 2007, 06:54:43 am
Hmm, this is very confusing for someone like me :p

I'll hopefully have new versions for each item (with insurance coding in them) available. Once you finish the actuall item that is.


Thanks a lot for the help
Title: Re: Insurance (Still needs work!)
Post by: TechnoDragon on February 22, 2007, 07:00:00 am
ok, here's the completed item:

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

//File: Insurance.php

class item_Insurance extends itemTemplate {
    function 
getItemDetails() {
$this->authorName "TechnoDragon";
$this->authorWeb "http://dragontalk.net";
$this->authorEmail "admin@dragontalk.net";

        
$this->name "Item Protection";
        
$this->desc "Protect yourself from bad items.";
        
$this->price 100;

        
$this->require_input false;
        
$this->can_use_item true;
    }
    
    
// See 'AddToPostCount.php' for info on how this works
    
function getAddInput() {
        return 
"Number of times to protect from bad items: <input type='text' name='info1' value='5' />";
    }

    function 
getUseInput() {
        return 
"";
    }

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

        
$result db_query("UPDATE {$db_prefix}members
                            SET insurance = insurance + 
{$item_info[1]}
                            WHERE ID_MEMBER = 
{$ID_MEMBER}",
                            
__FILE____LINE__);
        return 
"You are now protected from bad items for {$item_info[1]} times!";
    }

}

?>


Just make sure to call it Insurance.php (notice the case of the letters)
Title: Re: Insurance (Still needs work!)
Post by: xfollowthereaperx on February 22, 2007, 07:27:09 am
Okay, when I go to use the insurance item it tells me that I need to upgrade my database

Where can I do that?


It says my database is 1.1 and my SMF is 1.1.2

Quote
Unknown column 'insurance' in 'field list'
File: /hosted/subs/ulmb.com/p/o/powerspike/public_html/forums/Sources/shop/items/Insurance.php
Line: 39

Note: It appears that your database may require an upgrade. Your forum's files are currently at version SMF 1.1.2, while your database is at version 1.1. The above error might possibly go away if you execute the latest version of upgrade.php.
Title: Re: Insurance (Still needs work!)
Post by: xfollowthereaperx on February 22, 2007, 09:38:34 am
How do I add the insurance thing to my database?

I'm really confused about this part, I found smf_members, but thats it, once I go into that thing it doesn't show anything like "add database item" or whatever. What would be the inputs as well.
Title: Re: Insurance (Still needs work!)
Post by: TechnoDragon on February 22, 2007, 10:23:20 am
ok, give me a few and I will make up a package so you can install the item through the smf package manager...
Title: Re: Insurance (Still needs work!)
Post by: xfollowthereaperx on February 22, 2007, 10:24:03 am
ok, give me a few and I will make up a package so you can install the item through the smf package manager...
Wow, thanks so much   :smitten:
Title: Re: Insurance (Still needs work!)
Post by: TechnoDragon on February 22, 2007, 10:36:11 am
ok, you can download an installable package HERE (http://dragontalk.net/index.php?action=tpmod;dl=item84)

This will do everything for you so all you'll have to do is add the item to your shop through the admin panel!
Title: Re: Insurance (Still needs work!)
Post by: xfollowthereaperx on February 22, 2007, 10:37:02 am
Thanks a billion
Title: Re: Insurance (Still needs work!)
Post by: xfollowthereaperx on February 22, 2007, 10:43:53 am
Didn't work  :'(

Quote
Fatal error: require() [function.require]: Failed opening required '/hosted/subs/ulmb.com/p/o/powerspike/public_html/forums/Packages/temp/avtr_install.php' (include_path='.:') in /hosted/subs/ulmb.com/p/o/powerspike/public_html/forums/Sources/Packages.php on line 552
Title: Re: Insurance (Still needs work!)
Post by: TechnoDragon on February 22, 2007, 11:09:25 am
hold on...apparently i missed an edit...give me a sec
Title: Re: Insurance (Still needs work!)
Post by: TechnoDragon on February 22, 2007, 11:10:57 am
ok, redownload and try again
Title: Re: Insurance (Still needs work!)
Post by: xfollowthereaperx on February 22, 2007, 11:22:59 am
Quote
Error: The installer was unable to add a needed setting to the {db_prefix}members table. You may have to do this yourself.

I'm sure, if I try hard enough, that I can add that part.  :coolsmiley:

Thanks a lot
Title: Re: Insurance (Still needs work!)
Post by: TechnoDragon on February 22, 2007, 11:25:27 am
that would be the insurance field...
Title: Re: Insurance (Still needs work!)
Post by: xfollowthereaperx on February 22, 2007, 01:50:55 pm
:\

So, it didn't work? :(
Title: Re: Insurance (Still needs work!)
Post by: TechnoDragon on February 22, 2007, 02:03:07 pm
are you sure you didn't already add the insurance field to your member table?
Title: Re: Insurance (Still needs work!)
Post by: xfollowthereaperx on February 22, 2007, 02:04:47 pm
No, it's still giving me errors   :'(



Quote
Unknown column 'insurance' in 'field list'
File: /hosted/subs/ulmb.com/p/o/powerspike/public_html/forums/Sources/shop/items/Insurance.php
Line: 39

Note: It appears that your database may require an upgrade. Your forum's files are currently at version SMF 1.1.2, while your database is at version 1.1. The above error might possibly go away if you execute the latest version of upgrade.php.
Title: Re: Insurance (Still needs work!)
Post by: TechnoDragon on February 24, 2007, 07:48:25 am
ok, mediumint 10 default is zero
Title: Re: Insurance (Still needs work!)
Post by: xfollowthereaperx on February 24, 2007, 07:49:23 am
I got the item to work, now I need to edit in the codes for the items that I would like to prevent.

If I get them to work, I'll put them in a Zip and host them for everyone
Title: Re: Insurance (Still needs work!)
Post by: xfollowthereaperx on February 24, 2007, 07:57:49 am
Can you do me a favor and post another example item that works with insurance, and if you already coded all of the items with the new insurance code, could you please post them?

Thanks, it looks as if you made it so that the items STILL can be unsuccessful, but if they are successful, and the member has insurance, the item still does nothing. Very awesome idea, I wouldn't have thought of it.

Thanks a lot
Title: Re: Insurance (Still needs work!)
Post by: TechnoDragon on February 24, 2007, 07:58:07 am
Well, that opackage you downloaded from me already has the steal item edited...as for mass use items (like aramageddon or rob the bank) i already have those figured out how to make them work!
Title: Re: Insurance (Still needs work!)
Post by: xfollowthereaperx on February 24, 2007, 07:59:02 am
Is the steal item the updated version without the bug in it?
Title: Re: Insurance (Still needs work!)
Post by: TechnoDragon on February 24, 2007, 07:59:46 am
it has been working perfectly for me...though i suppose i could zip up all of the items i have edited and post them here...
Title: Re: Insurance (Still needs work!)
Post by: xfollowthereaperx on February 24, 2007, 08:00:22 am
it has been working perfectly for me...though i suppose i could zip up all of the items i have edited and post them here...

PLEASE DO IT  :D
Title: Re: Insurance (Still needs work!)
Post by: TechnoDragon on February 24, 2007, 08:04:36 am
Ok, just added a zip file to my downloads section at my site that hass ALL of the items i have edited to work with insursurance...as well as a few other extras in them...

I have modified them to also post a new topic to the forum when used...though you will have to modify them to insert your own board id...
This line is what tells it what board to post to:
Code: [Select]
$topicOptions['board'] = 127; //SHOP history forum  Mine is #98  You need to create this then use it's ID number
Title: Re: Insurance (Still needs work!)
Post by: xfollowthereaperx on February 24, 2007, 08:06:32 am
Ok, just added a zip file to my downloads section at my site that hass ALL of the items i have edited to work with insursurance...as well as a few other extras in them...

I have modified them to also post a new topic to the forum when used...though you will have to modify them to insert your own board id...
This line is what tells it what board to post to:
Code: [Select]
$topicOptions['board'] = 127; //SHOP history forum  Mine is #98  You need to create this then use it's ID number
So if I don't add that code the item will still work perfectly fine?

Thanks a bunch, sorry for bugging you  :P
Title: Re: Insurance (Still needs work!)
Post by: TechnoDragon on February 24, 2007, 08:07:35 am
actually that line is already in each of those files you are/have downloaded you'll have to modify it to a different board id (unless you already have a board id of 127)  lol
Title: Re: Insurance (Still needs work!)
Post by: xfollowthereaperx on February 24, 2007, 08:18:09 am
Codes, meaning items? Okay, I'll edit it out  ::)


Thanks a lot
I'll make the first post have all of the information anyone would need to add this item to their forum
Title: Re: Insurance (Still needs work!)
Post by: Daniel15 on February 24, 2007, 08:52:34 am
Wow, great idea, I may implement something similar in a future version of SMFShop :).

Just a note, I'm very strict about the SMF Coding Guidelines now... it's best to make sure your code follows the coding guidelines (see http://custom.simplemachines.org/mods/guidelines.php) :)

Also, to whoever invented the SMFShop logging stuff:
Quote
Code: [Select]
require_once($sourcedir . '/Subs-Post.php');
$topicOptions['board'] = 127; //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 am a Thief {$user_info['username']}"; //Subject
$msgOptions['body'] = "{$user_info['username']} just used a sticky hand and stole {$steal_amount} from ".$_POST['stealfrom']; //Message area
  $msgOptions['icon'] = 'exclamation';
$posterOptions['id']=$ID_MEMBER; //Current user's ID
createPost(&$msgOptions, &$topicOptions, &$posterOptions); //create the post using the SMF posting function

SMFShop 3.0 has a Shop-Subs.php file... It may be worth creating a function called ShopLog() or similar, and placing the code in there. Then, reduce the code in the SMFShop item to a single function call :).
I may have logging in a future version, but unfortunately, school is taking up all my free time at the moment :(
Title: Re: Insurance (Still needs work!)
Post by: xfollowthereaperx on February 24, 2007, 09:20:11 am
Very nice so far, some improvements I'd like to see are these:

PM user when his/her insurance is completely gone
Somehow show how much insurance a certain user has
Title: Re: Insurance (Still needs work!)
Post by: TechnoDragon on February 24, 2007, 01:24:52 pm
Ya, those are the exact ideas i have for it as well....who knows...maybe I will have enough spare time this weekend to figure out how to do that!
Title: Re: Insurance (Still needs work!)
Post by: Kimojuno on February 25, 2007, 03:58:51 am
Very nice so far, some improvements I'd like to see are these:

PM user when his/her insurance is completely gone
Somehow show how much insurance a certain user has

I'm afraid I cannot be of much help, however how about having it so a user is PMed say five days before, a day before, and then right when it expires? This way they can keep track of it ahead of time, or if possible just add a counter to their profile so that someone can see someones insurance that way, and they can also find out manually that way. Being PMed five days before, a day before, and then right when it expires, would also help those who are just plain lazy.

Jeff.
Title: Re: Insurance (Still needs work!)
Post by: TechnoDragon on February 25, 2007, 11:55:03 am
well, the day timing won't work, because it sets a "counter" that degrades each time it is used...  I am working on something that would allow a user to see how many uses htey have left
Title: Re: Insurance (Still needs work!)
Post by: xfollowthereaperx on March 05, 2007, 10:37:08 am
The Rob the Bank item you uploaded isn't working for me :(
Title: Re: Insurance (Still needs work!)
Post by: TechnoDragon on March 05, 2007, 12:07:20 pm
it is generating any errors?
Title: Re: Insurance (Still needs work!)
Post by: xfollowthereaperx on March 08, 2007, 06:26:05 am
Yes, it is

If you want I can check which error, but I'm sure you know what error it is anyways :p
Title: Re: Insurance (Still needs work!)
Post by: TechnoDragon on March 08, 2007, 08:28:42 am
actually no...it seems to be working fine on my forum...let me attach my version and see if that fixes it for you...just remember to change the board number in the code for the item
Title: Re: Insurance (Still needs work!)
Post by: xfollowthereaperx on March 10, 2007, 08:46:18 pm
actually no...it seems to be working fine on my forum...let me attach my version and see if that fixes it for you...just remember to change the board number in the code for the item
Thanks so much
Title: Re: Insurance (Still needs work!)
Post by: TechnoDragon on March 10, 2007, 11:33:50 pm
You are very welcome!

Ok, I have added the tinsurance count so members can see how much they have left (This only show the particular member and noone else)
in shop.template.php find:
Code: [Select]
<b>',$txt['shop_money_in_pocket'],': </b>',$context['shop_money'],'<br />
',$context['shop_money_in_bank'],'<br />
add after:
Code: [Select]
';<b>',$txt['shop_money_in_pocket'],': </b>',$context['shop_money'],'<br />
',$context['shop_money_in_bank'],'<br />';
if ($context['shop_shieldleft'] > 5){
echo'
<b>',$txt['shop_insurance'],':</b> ',$context['shop_shieldleft'],'<br />';
}
elseif ($context['shop_shieldleft'] >1 && $context['shop_shieldleft'] < 5){
echo'
<font color="red">',$txt['shop_insurance_low'],'</font><br />
<b>',$txt['shop_insurance'],':</b> ',$context['shop_shieldleft'],'<b> ',$txt['shop_insurance_left'],'</b><br />';
}
else{
echo'
<font color="red">',$txt['shop_insurance_none'],'</font><br />
<b>',$txt['shop_insurance'],':</b> ',$context['shop_shieldleft'],'<b> ',$txt['shop_insurance_left'],'</b><br />';
}
echo'
in shop.php find:
Code: [Select]
// The current member's money
$result = db_query("SELECT money, moneyBank
add after:
Code: [Select]
, insurance
find:
Code: [Select]
$context['shop_money_bank'] = formatMoney($row['moneyBank']);
add after:
Code: [Select]
$context['shop_shieldleft'] = $row['insurance'];
add these strings to the shop.english.php
Code: [Select]
$txt['shop_insurance'] = "Dragon Shield";
$txt['shop_insurance_low'] = "Your Dragon Shield is getting low! You may want to stock up!";
$txt['shop_insurance_none'] = "You have no Dragon Shield...Be Warned, this makes you a target for those that like to steal!";
$txt['shop_insurance_left'] = "Remaining";

make sure to change them to reflect what you call the insurance on your forum.

this will display their current amount left as well as change what message displays based on how much they have left
Title: Re: Insurance (Still needs work!)
Post by: Lew_Cipher on March 15, 2007, 11:48:30 am
Wow. Interesting thread. Is there a complete version somewhere so I can try to add this item or is TechnoDrago's code just above this post the complete code so far?
Title: Re: Insurance (Still needs work!)
Post by: TechnoDragon on March 15, 2007, 11:55:17 am
well, there is no complete installpackage if that is what you mean...the zip file i have at my site should add the item and the database field, but the code above has to be manually installed to have the current shield count show up for the member in the shop
Title: Re: Insurance (Still needs work!)
Post by: xfollowthereaperx on March 15, 2007, 12:03:06 pm
Has anyone gotten one to work with Egg Avatar or Karma Bash?
Title: Re: Insurance (Still needs work!)
Post by: TechnoDragon on March 15, 2007, 02:23:58 pm
I haven't implemented it yet for either of those items, but I am sure it wouldn't be much harder than any of the other items
Title: Re: Insurance (Still needs work!)
Post by: CRONUS on March 16, 2007, 09:19:58 pm
Karmagedon would be nice ;)
Title: Re: Insurance (Still needs work!)
Post by: TechnoDragon on March 17, 2007, 12:23:09 am
i'll see what I can do...the items I already released were the ones I modified on my site....didn't want them to be protected from EVERYTHING! LOL
Title: Re: Insurance (Still needs work!)
Post by: xfollowthereaperx on March 20, 2007, 10:21:51 am
TechnoDragon, has anyone on your forums successfully used "robthebank" because it doesn't seem it let me successfully do it
Title: Re: Insurance (Still needs work!)
Post by: TechnoDragon on March 21, 2007, 03:26:53 pm
well if you mean it failed...that is because of the extremely low percentage chance of success...if you mean there is an error if there is success  Iwill look at my code and if there is an issue I will post up the corrected item
Title: Re: Insurance (Still needs work!)
Post by: perplexed on April 10, 2007, 10:38:26 pm
I would like protection against some items but is this item finalised?   I downloaded and installed it via package manager, but nothing shows in the add/edit/delete shop item page.  Does something have to be done manually?

Also does it tell you who the person stealing the money, the karma, etc is?  That would be good to know.
Title: Re: Insurance (Still needs work!)
Post by: TechnoDragon on April 11, 2007, 02:01:25 pm
it should show up in the items list so that you can add it to the shop to buy...if not try checking your server to make sure iot was uploaded.  I can't remember if I added a PM to these versions or not.  Most likely not, because it would require manual changes to the files for the board you want it posted to.
Title: Re: Insurance (Still needs work!)
Post by: ibexy on July 07, 2007, 07:35:24 am
I have the insurance working fine but I would like to display the insurance value in the message window just below the post count. Someone please. How can I show the insurace value in the message window just below the post count?

Title: Re: Insurance (Still needs work!)
Post by: Dr.Vista on August 12, 2007, 01:08:15 am
Where Do I Download The Pakage,or how do i install it :tickedoff:
Title: Re: Insurance (Still needs work!)
Post by: feildmaster on August 12, 2007, 02:38:27 am
ok, you can download an installable package HERE (http://dragontalk.net/index.php?action=tpmod;dl=item84)

This will do everything for you so all you'll have to do is add the item to your shop through the admin panel!

that answer your question vista?

I have the insurance working fine but I would like to display the insurance value in the message window just below the post count. Someone please. How can I show the insurace value in the message window just below the post count?
Well, you don't WANT other people to know how much insurance they have... Otherwise they wouldn't waste their items on the person. That is why i wont help you make it show. =)
Title: Re: Insurance (Still needs work!)
Post by: Str8up-Nate on October 10, 2007, 01:27:12 pm
You are very welcome!

Ok, I have added the tinsurance count so members can see how much they have left (This only show the particular member and noone else)
in shop.template.php find:
Code: [Select]
<b>',$txt['shop_money_in_pocket'],': </b>',$context['shop_money'],'<br />
',$context['shop_money_in_bank'],'<br />
add after:
Code: [Select]
';<b>',$txt['shop_money_in_pocket'],': </b>',$context['shop_money'],'<br />
',$context['shop_money_in_bank'],'<br />';
if ($context['shop_shieldleft'] > 5){
echo'
<b>',$txt['shop_insurance'],':</b> ',$context['shop_shieldleft'],'<br />';
}
elseif ($context['shop_shieldleft'] >1 && $context['shop_shieldleft'] < 5){
echo'
<font color="red">',$txt['shop_insurance_low'],'</font><br />
<b>',$txt['shop_insurance'],':</b> ',$context['shop_shieldleft'],'<b> ',$txt['shop_insurance_left'],'</b><br />';
}
else{
echo'
<font color="red">',$txt['shop_insurance_none'],'</font><br />
<b>',$txt['shop_insurance'],':</b> ',$context['shop_shieldleft'],'<b> ',$txt['shop_insurance_left'],'</b><br />';
}
echo'
in shop.php find:
Code: [Select]
// The current member's money
$result = db_query("SELECT money, moneyBank
add after:
Code: [Select]
, insurance
find:
Code: [Select]
$context['shop_money_bank'] = formatMoney($row['moneyBank']);
add after:
Code: [Select]
$context['shop_shieldleft'] = $row['insurance'];
add these strings to the shop.english.php
Code: [Select]
$txt['shop_insurance'] = "Dragon Shield";
$txt['shop_insurance_low'] = "Your Dragon Shield is getting low! You may want to stock up!";
$txt['shop_insurance_none'] = "You have no Dragon Shield...Be Warned, this makes you a target for those that like to steal!";
$txt['shop_insurance_left'] = "Remaining";

make sure to change them to reflect what you call the insurance on your forum.

this will display their current amount left as well as change what message displays based on how much they have left

What Version Is This For? I Need Help I Have SMF Shop 3.0 and SMF Version 1.1.3
Please Help Me Add This
Title: Re: Insurance (Still needs work!)
Post by: feildmaster on October 21, 2007, 08:05:40 am
use the link at my above post
Title: Re: Insurance (Still needs work!)
Post by: Str8up-Nate on October 22, 2007, 07:45:41 am
no i mean i cant find those parts in the files??? there not there??? (shop.php, and the shop.template.php) where you say look for these Parts and add after or before there on in the code at all  please help me :)
Title: 1.1.3 - 1.1.4 Insurance Meter.
Post by: Str8up-Nate on January 22, 2008, 01:07:53 pm
~!~Add a Meter On Your Shop Home Page To Tell You How Many Insurance's You Have Left.~!~

-All Credit Goes To Feildmaster - He Gave Me These Edits I'm Just Posting Them For Everyone Else.

These Codes Have been Tested By Me On SMF 3.0 Shop And These SMF Versions:
1. 1.1.3
2. 1.1.4

Here Are The Code Edits...



Open... Sources/Load.php



Find...
Code: [Select]
// Begin SMFShop MOD Version New Version
'money' => isset($user_settings['money']) ? $user_settings['money'] : '',
'moneyBank' => isset($user_settings['moneyBank']) ? $user_settings['moneyBank'] : '',
// End SMFShop MOD

Add After...
Code: [Select]
'insurance' => isset($user_settings['insurance']) ? $user_settings['insurance'] : '',



Find...
Code: [Select]
mem.buddy_list, mg.onlineColor AS member_group_color, IFNULL(mg.groupName, '') AS member_group,
pg.onlineColor AS post_group_color, IFNULL(pg.groupName, '') AS post_group, mem.is_activated, mem.shop_nameStyle, mem.money,

Add At End...
Code: [Select]
     
mem.insurance,



Find...
Code: [Select]
// Begin SMFShop MOD Version New Version
'money' => $profile['money'],
// End SMFShop MOD

Add After...
Code: [Select]
'insurance' => $profile['insurance'],



Find....
Code: [Select]
'money' => &$user_info['money'],

Add After...
Code: [Select]
'insurance' => &$user_info['insurance'],



Save Load.php...



Open Themes/default/shop.templete.php...



Find...
Code: [Select]
', sprintf($txt['shop_currently_have1'], formatMoney($context['user']['money'])), ($modSettings['shopBankEnabled'] ? sprintf($txt['shop_currently_have2'], formatMoney($context['user']['moneyBank'])) : ''), '
<br /><br />';

Add After...
Code: [Select]
echo 'Insurance Left: ', $context['user']['insurance'] > 5? $context['user']['insurance'] : ($context['user']['insurance'] > 0 ? '<font color="red">'.$context['user']['insurance'].', you might want to consider buying more.</font>' : '<font color="red">NONE! Buy more from the shop!</font>');



Save Themes/default/shop.templete.php...


Congrats On The New Meter
-All Credit Goes To Feildmaster - He Gave Me These Edits I'm Just Posting Them For Everyone Else.
Title: Re: Insurance (Still needs work!)
Post by: brianjw on May 19, 2008, 11:16:05 am
Does anyone have a copy of this mod that they could provide here? TechnoDragon shut down his website so the download link no longer works. He suspended his own site with his own hosting company because he didn't have any time to maintain it.

Thanks,
brianjw
Title: Re: Insurance (Still needs work!)
Post by: bfeo on August 25, 2008, 10:23:32 am
Wait so is

http://www.daniel15.com/forum/index.php/topic,620.msg7595.html#msg7595

The entire mod, or just the insurance meter?  Where can I find the latest codes together?  I'd like to install this one.
Title: Re: Insurance (Still needs work!)
Post by: bfeo on August 30, 2008, 01:54:43 am
I'm just gonna bump this.
Title: Re: Insurance (Still needs work!)
Post by: bfeo on September 06, 2008, 03:34:00 am
It's nice to see how often people post on this forum.   :'(
Title: Re: Insurance (Still needs work!)
Post by: Daisuke_aurora on September 09, 2008, 11:29:00 pm
Unfortunately, it's now often at all...