News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

ST Shop

Started by Diego Andrés, June 13, 2009, 06:06:35 AM

Previous topic - Next topic

SA™

change $context['member']['cash'] to $message['member']['cash'] that should work
http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

lelkins

Sorted! Thank you very much, and thanks for being so quick.

SA™

your welcome iif im here ill anser the post asap
http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

Bob Perry of Web Presence Consulting

Have a minor little problem with the "Steal credits" item, it looks like when it attempts to do a successful steal we get the following database error



Unsuccessful steals works fine... I recently upgraded from SMF 1.1.11 to 2.0 RC2
Best Regards,
Bob Perry



"The world is moving so fast these days that the man who says it can't be done is generally interrupted by someone doing it." Elbert Hubbard

SA™

hmm untested but try
sources/shop2/items/steal.php

find

$result = $smcFunc['db_query']('', '
SELECT cash
FROM {db_prefix}members
WHERE member_name = '.$user.'');


replace with

$result = $smcFunc['db_query']('', '
SELECT cash
FROM {db_prefix}members
WHERE member_name = {string:name}',
array(
'name' => $user,
)
);
http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

Bob Perry of Web Presence Consulting

Quote from: Sleepy Arcade on December 17, 2009, 01:05:58 PM
hmm untested but try
sources/shop2/items/steal.php

find

$result = $smcFunc['db_query']('', '
SELECT cash
FROM {db_prefix}members
WHERE member_name = '.$user.'');


replace with

$result = $smcFunc['db_query']('', '
SELECT cash
FROM {db_prefix}members
WHERE member_name = {string:name}',
array(
'name' => $user,
)
);


Nope, doing that causes this error



Best Regards,
Bob Perry



"The world is moving so fast these days that the man who says it can't be done is generally interrupted by someone doing it." Elbert Hubbard

SA™

this one seems to work for me

<?php
/**********************************************************************************
* SMFShop item                                                                    *
***********************************************************************************
* SMFShop: Shop MOD for Simple Machines Forum                                     *
* =============================================================================== *
* Software Version:           SMFShop 3.0 (Build 12)                              *
* $Date:: 2007-08-04 11:56:24 +0200 (za, 04 aug 2007)                           $ *
* $Id:: Steal.php 125 2007-08-04 09:56:24Z 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...');

class 
item_Steal extends itemTemplate
{
function getItemDetails()
{
$this->authorName 'Daniel15';
$this->authorWeb 'http://www.dansoftaustralia.net/';
$this->authorEmail '[email protected]';

$this->name 'Steal Credits';
$this->desc 'Try to steal credits from another member!';
$this->price 50;

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

function getAddInput()
{
global $item_info;
if ($item_info[1] == 0$item_info[1] = 40;
return 'For steal, user <b>does NOT need to, and shouldn\'t</b> know the probability! It\'s more fun this way :-)<br />Probability of successful steal: <input type="text" name="info1" value="' $item_info[1]  . '" />%';
}

function getUseInput()
{
global $context$scripturl$settings$txt;
return 'Steal From: <input type="text" name="stealfrom" size="50" />
<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$context$user_info$item_info$smcFunc;

// Check some inputs
if (!isset($_POST['stealfrom']) || $_POST['stealfrom'] == '') die('ERROR: Please enter a username to steal from!');

// This code from PersonalMessage.php5. It trims the " characters off the membername posted, 
// and then puts all names into an array
$_POST['stealfrom'] = strtr($_POST['stealfrom'], array('\\"' => '"'));
preg_match_all('~"([^"]+)"~'$_POST['stealfrom'], $matches);
$userArray array_unique(array_merge($matches[1], explode(','preg_replace('~"([^"]+)"~'''$_POST['stealfrom']))));

// We only want the first memberName found
$user $userArray[0];

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

// If successful
if ($try $item_info[1])
{
// Get stealee's (person we're stealing from) money count
$result $smcFunc['db_query']('''
SELECT cash
FROM {db_prefix}members
WHERE real_name = {string:name}'
,
array(
'name' => $user,
)
);

// If user doesn't exist
if ($smcFunc['db_num_rows']($result) == 0)
die('ERROR: The specified user doesn\'t exist!');

$row $smcFunc['db_fetch_assoc']($result);

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

// Take this money away from stealee...
$final_value1 =  $steal_amount $row['cash'];
        
//updateMemberData($user, array('cash' => $final_value1));

//...and give to stealer (robber)
$final_value1 =  $steal_amount $user_info['cash'];
        
updateMemberData($context['user']['id'], array('cash' => $final_value1));


if ($steal_amount 50)
return 'Steal successful, although you only stole ' $steal_amount '!';
else
return 'Successfully stole ' $steal_amount ' from ' $user '! It\'s their fault they don\'t have their money in the bank!';
}
else
{
// If reducing Karma doesn't work, replace
// 'karma_bad = karma_bad + 10' with 'karma_good = karma_good - 10'

updateMemberData($context['user']['id'], array('karma_bad' => (int) 10));

   return 'Steal <b>unsuccessful!</b> Your Karma is now reduced by 10!';
}
}
}

?>

http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

Bob Perry of Web Presence Consulting

Quote from: Sleepy Arcade on December 18, 2009, 06:09:21 PM
this one seems to work for me

        //updateMemberData($user, array('cash' => $final_value1));
         


OK dude, yes that version works to a certain degree... HOWEVER, I left the part of the code you quoted me above that still is a problem, the commented statement will allow the rest of the code to function properly BUT will not decrease the stealee's credits appropriately, so what's the point in stealing their credits if it doesn't decrement the person you are stealing from? AND, if you uncomment that statement it causes the error previously stated by me in this thread. Sure would be nice to have this item function PROPERLY, not jury rigged.
Best Regards,
Bob Perry



"The world is moving so fast these days that the man who says it can't be done is generally interrupted by someone doing it." Elbert Hubbard

SA™

bperry921 im sry thats my own fault doing so many things at once


i commented to it see it that was the problem only i coulda sware that i fixed the problem and uncommented that

illtake another look tommorow for you again sry bout that
http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

Bob Perry of Web Presence Consulting

Quote from: Sleepy Arcade on December 19, 2009, 12:31:30 PM
bperry921 im sry thats my own fault doing so many things at once


i commented to it see it that was the problem only i coulda sware that i fixed the problem and uncommented that

illtake another look tommorow for you again sry bout that

Any progress Sleepy?
Best Regards,
Bob Perry



"The world is moving so fast these days that the man who says it can't be done is generally interrupted by someone doing it." Elbert Hubbard

SA™

no not yet sry all this snow has bought me plenty of overtime i should be home at about 3:30 in the morning  if im not too tired ill do it then :)
http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

SA™

here you go i forgot updatemember() function only expects integers and i was trying to pass a string threw it
http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

Bob Perry of Web Presence Consulting

Quote from: Sleepy Arcade on December 23, 2009, 02:40:52 PM
here you go i forgot updatemember() function only expects integers and i was trying to pass a string threw it

Thanks, seems to work as expected now... I have some things for you to fix in the Battle mod too, but will get to that later, must sleep now and will post that in the right thread too, have a merry christmas dude
Best Regards,
Bob Perry



"The world is moving so fast these days that the man who says it can't be done is generally interrupted by someone doing it." Elbert Hubbard

SA™

your welcome and have a good christmas
http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

Bob Perry of Web Presence Consulting

#94
Quote from: bperry921 on December 24, 2009, 12:35:15 AM
Quote from: Sleepy Arcade on December 23, 2009, 02:40:52 PM
here you go i forgot updatemember() function only expects integers and i was trying to pass a string threw it

Thanks, seems to work as expected now... I have some things for you to fix in the Battle mod too, but will get to that later, must sleep now and will post that in the right thread too, have a merry christmas dude

Update, a very minor problem I think, doesn't seem to interfere with functionality, not positive about that though... I'm getting the following error message in the SMF error log at every successful steal... I double checked and that field and index do exist in the smf_members database table





Merry Christmas dude
Best Regards,
Bob Perry



"The world is moving so fast these days that the man who says it can't be done is generally interrupted by someone doing it." Elbert Hubbard

Nvb

#95
I see this is a great follow up for the SMF Shop mod.
So i will use this in the future.

But what i like to see is the credits below the poster icon in the posts.
something simple like "Current Amount: xxx credits"
Where do i need to add that code?

EDIT: Sorry that solution is on top of this page...  :-\

Change this ../Themes/Default/Display.template.php :
// Show how many posts they have made.
if (!isset($context['disabled_fields']['posts']))
echo '
<li class="postcount">', $txt['member_postcount'], ': ', $message['member']['posts'],'</li>';


Into this:
// Show how many posts they have made.
if (!isset($context['disabled_fields']['posts']))
echo '
<li class="postcount">', $txt['member_postcount'], ': ', $message['member']['posts'],'</li>';
echo '
<li class="postcount">',$txt['shop_procredit'],': ', $message['member']['cash'], '</li>';



Nvb

#96
Me again :)

I want to add a AddMembergroup item to the shop.
So i found this code:

<?php
//File: AddMembergroup.php
//      Item

class item_AddMembergroup extends itemTemplate {
    function 
getItemDetails() {
   
        
$this->name "Add Membergroup";
        
$this->desc "Allows you to add yourself to a membergroup!";
        
$this->price 1;

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

    function 
getAddInput() {
   global 
$db_prefix;

   
$selectBox '<select name="info1">';

   
// Get all non post-based membergroups
   
$result db_query("SELECT ID_GROUP, groupName
                     FROM 
{$db_prefix}membergroups
                     WHERE minPosts = -1"
,
                  
__FILE____LINE__);
   
   
// For each membergroup, add it to the list
   
while ($row mysql_fetch_assoc($result)) {
      
$selectBox .= "<option value='{$row['ID_GROUP']}'>{$row['groupName']}</option>";
   }

   
$selectBox .= "</select>";
        return 
"Membergroup: ".$selectBox;
    }
       

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

$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'].",".$item_info[1];
} else {
   
$additionalGroups['additionalGroups'] = $item_info[1];
}   

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

        return 
"You have joined new membergroup {$item_info[1]}!!";
    }
}
?>


The only problem is that i get a blank screen (white page) when i push the "Next" button.
What is wrong??


SA™

that item wont work cos it needs updating use the one in this post

http://sa-mods.ath.cx/battle2/index.php?topic=152.msg903#msg903
http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

SA™

Quote from: bperry921 on December 25, 2009, 05:00:26 AM
Quote from: bperry921 on December 24, 2009, 12:35:15 AM
Quote from: Sleepy Arcade on December 23, 2009, 02:40:52 PM
here you go i forgot updatemember() function only expects integers and i was trying to pass a string threw it

Thanks, seems to work as expected now... I have some things for you to fix in the Battle mod too, but will get to that later, must sleep now and will post that in the right thread too, have a merry christmas dude

Update, a very minor problem I think, doesn't seem to interfere with functionality, not positive about that though... I'm getting the following error message in the SMF error log at every successful steal... I double checked and that field and index do exist in the smf_members database table





Merry Christmas dude

hmm ok ill look ito this next week :)
http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

Bob Perry of Web Presence Consulting

Quote from: Sleepy Arcade on December 25, 2009, 07:58:37 PM
that item wont work cos it needs updating use the one in this post

http://sa-mods.ath.cx/battle2/index.php?topic=152.msg903#msg903

Is there an update for "Increase Karma" item? it's not functioning right on my system either but no errors in log though...
Best Regards,
Bob Perry



"The world is moving so fast these days that the man who says it can't be done is generally interrupted by someone doing it." Elbert Hubbard

Advertisement: