Author Topic: Role Play stats Item (needs work)  (Read 6650 times)

Offline Daisuke_aurora

Role Play stats Item (needs work)
« on: August 19, 2008, 03:58:17 am »
Ok. I run a forun where members can RP using a stat system (the custom profile field mod). Basically, members have a set atk power, def power, etc, displayed by the CP field mod. I recently took the Add to post count item and tweaked it to add to the CP fields, and got this:

Quote
<?php
/**********************************************************************************
* SMFShop item                                                                    *
***********************************************************************************
* SMFShop: Shop MOD for Simple Machines Forum                                     *
* =============================================================================== *
* Software Version:           SMFShop 3.0 (Build 12)                              *
* $Date:: 2008-08-18 14:30:00 +1100 (Mon, 18 Aug 2008)                          $ *
* $Id:: IncreaseHP.php 79 2008-08-18 12:30:00Z Daisuke_aurora                   $ *
* Software by:                Daisuke (http://www.daisukesdojo.heliohost.org/)    *
* Copyright 2005-2007 by:     Daisuke (http://www.daisukesdojo.heliohost.org/)    *
* Support, News, Updates at:  http://www.daisukesdojop.heliohost.org/             *
*                                                                                 *
* 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...');

class item_IncreaseHP extends itemTemplate
{
   function getItemDetails()
   {
      $this->authorName = 'Daisuke';
      $this->authorWeb = 'http://www.daisukesdojo.heliohost.org/';
      $this->authorEmail = 'Daisuke_aurora@hotmail.com';

      $this->name = 'Increase HP by xxx';
      $this->desc = 'Increase your HP by xxx';
      $this->price = 1000;

      $this->require_input = false;
      $this->can_use_item = true;
      $this->addInput_editable = true;
   }
   
   // See 'AddToPostCount.php' for info on how this works
   function getAddInput()
   {
      global $user_info;
      if ($item_info[1] == 0) $item_info[1] = 10;
      return 'Amount to increase HP by: <input type="text" name="info1" value="' . $item_info[1] . '" />';
   }

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

      db_query("
         UPDATE {$db_prefix}themes
         SET value = value + {$item_info[1]}
         WHERE ID_MEMBER = {$ID_MEMBER}", __FILE__, __LINE__);
      return 'Successfully increased your HP by ' . $item_info[1] . '!';
   }

}

?>

However, there is one problem: The item cannot tell the difference between the 8 CP fields, so it increases ALL of them by 10, not just one. Can anyone tell me how to make it target only one of these fields?

Offline Katzujari

Re: Role Play stats Item (needs work)
« Reply #1 on: February 02, 2011, 01:02:09 pm »
No soy exactamente un experto en PHP, pero me parece que el problema es sencillo. $item_info no tiene un valor realmente fijado, es decir, lo mismo vale un HP que un SP (por ejemplo) y todos los item se incrementan porque $item_info[1] == 0

No estoy seguro, epro me parece el problema
_____________________________________________

I'm not exactly an expert in PHP, but I think the problem is simple. $ item_info really has no value set, ie, the same holds an HP that a SP (eg) and all item are increased because $ item_info [1] == 0

Not sure, but I think the problem

Sorry for the English, use the google translate

Offline umarsahb

Re: Role Play stats Item (needs work)
« Reply #2 on: April 01, 2015, 09:23:31 pm »
Ok. I run a forun where members can RP using a stat system (the custom profile field mod). Basically, members have a set atk power, def power, etc, displayed by the CP field mod. I recently took the Add to post count item and tweaked it to add to the CP fields, and got this:

Offline code

Re: Role Play stats Item (needs work)
« Reply #3 on: October 09, 2016, 12:50:08 am »
Your advices are very useful, I appreciate your knowledge