Author Topic: SMFShop and SMF Arcade  (Read 14817 times)

Offline matkins70

SMFShop and SMF Arcade
« on: September 04, 2006, 08:52:06 am »
I was wondering whether anyone had looked into the possibility, or even created a script for giving a user credits if they acheive a highscore in the arcade.

I don't want to make anything complicated, such as retaining the score for certain amount of time or anything.  I just wanted to have a script, where if a user gets a highscore in one of the games, they get, say 50 credits, and a little message saying so.

If anyone has any leads to acheiving this, i thank you now, as i would like to implement it with my forum.

Am very new to SMF Boards, and SMFShop, so please forgive my nievity

Thanks

P.s.  SMFShop rules!

Offline Basil Beard

Re: SMFShop and SMF Arcade
« Reply #1 on: September 04, 2006, 09:46:46 am »
This has been talked about before and is probably possible; the problem is that none of us have experience with the SMF Arcade code to know how exactly to accomplish this.
Arrrrr!

Offline matkins70

Re: SMFShop and SMF Arcade
« Reply #2 on: September 04, 2006, 10:13:54 am »
Ok.
Do you think that anyone else over at SMF forum might have experience.

I haven't actually looked at the coding for the various items yet, but was also wondering whether a scratch card item might be easily feasible.  Would work on a basis of 40% chance you win nothing, 20% chance you get money back, so on, until 1% chance you win 100 credits.
If this is easily feasible, is there an item you would recommend for changing the code to make this as easily as possible.

Thanks basil.

P.s..  Was looking at the shop details, and you lot of got tens of thousands in the bank!  is that through posting alone, or interest, items?

Offline Basil Beard

Re: SMFShop and SMF Arcade
« Reply #3 on: September 05, 2006, 09:59:14 am »
Using a steal money on daniel15? Interest has done the rest I guess

A scratch card like that would be very doable. Actually scratching would be tricky, but you can just use $value = mt_rand(lowerbound,upperbound) and then if statments to do a random item like that.
« Last Edit: September 05, 2006, 10:01:14 am by Basil Beard »
Arrrrr!

Offline TechnoDragon

Re: SMFShop and SMF Arcade
« Reply #4 on: September 05, 2006, 11:15:44 am »
Just use the random money item and rename it to something else for your shop
Don't tell me to get into shape...I have a shape...It is round!


Offline matkins70

Re: SMFShop and SMF Arcade
« Reply #5 on: September 05, 2006, 11:30:41 am »
Really hoping someone is online here, as im gonna go to bed soon.  Before i started on other things, i decided to try and make something basic.  Its a multiplier, that multiplies someones pocket by between -50% and +50%.
I edited one of the existing item scripts...(random money, i think).

When finished, i shoved the file in the items folder, and went to try it out, but when i click on 'add items' i get this error:

Quote
Parse error: parse error, unexpected '(' in //forums/Sources/shop/items/Multiplier.php on line 49

Err, i dont know if its my code, or whether i have to do something to the file to 'install' it. (just to note, i changed it to 777, as all the other items were that).

Just in case, here is the code:

Code: [Select]
<?php

/**********************************************\

|         For the SMFShop Mod                  |

|         (c) 2006 Matkins70                   |

|       http://www.matkins70.com/              |

\**********************************************/



//File: Multiplier.php

//      Item



//VERSION: 2.1 (Build 9)

//DATE: 05th September 2006

// $Id: Multiplier.php 17 2006-09-05 03:05:12Z Matkins70 $



class item_Multiplier extends itemTemplate {

    function 
getItemDetails() {

        
$this->name "Multiplier";

        
$this->desc "Multiply your money in your pocket between -50% and +50%";

        
$this->price 500;

        

        
$this->require_input false;

        
$this->can_use_item true;

    }



    
//See AddToPostCount.php for more information

    
function getAddInput() {

        return 
"Minimum percentage: <input type='text' name='info1' value='50'><br>

                Maximum percentage: <input type='text' name='info2' value='150'>"
;

    }



    function 
onUse() {

        global 
$db_prefix$ID_MEMBER$item_info;

        

        
//simple fix for the 'number expected' errors

        
if (!isset($item_info[1]) || $item_info[1] == "")

            
$item_info[1] = 50;



        if (!isset(
$item_info[2]) || $item_info[2] == "")

            
$item_info[2] = 150;



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



if ($amount 0) {



$result db_query("UPDATE {$db_prefix}members

SET money = money * (
{$amount} / 100)

WHERE ID_MEMBER = 
{$ID_MEMBER}",

__FILE____LINE__);

return "You got a percentage of "($amount)".  Multiplied with your money in your pocket, you now have ".formatMoney($row['money'])."!";

}

    }



}



?>



Thanks for any help

Offline Daniel15

Re: SMFShop and SMF Arcade
« Reply #6 on: September 08, 2006, 09:14:06 pm »
matkins70, there's a problem with your code, on the last 'return' line.
Replace:
Code: [Select]
return "You got a percentage of "($amount)".  Multiplied with your money in your pocket, you now have ".formatMoney($row['money'])."!";With:
Code: [Select]
return("You got a percentage of {$amount}.  Multiplied with your money in your pocket, you now have ".formatMoney($row['money'])."!");Or:
Code: [Select]
return("You got a percentage of ".$amount.".  Multiplied with your money in your pocket, you now have ".formatMoney($row['money'])."!");

Offline matkins70

Re: SMFShop and SMF Arcade
« Reply #7 on: September 09, 2006, 03:22:41 am »
Thanks daniel.  Basil had just beaten you to it with a personal message :P

Been updating a few things with the shop, quite a fun little project.  I now have it set up so if someone gets a new highscore in the arcade, then they get given 50 credits.  My multiplier is up, though im not completely happy with it, but all in due course.

My next task is to make a scratchcard.  I think i mentioned it before.   Im trying to think of the best way to get the weighted results, so that basically, there is a 40% chance of 0, 20% of 100 credits, 5% of X credits, and so on.  My only idea at the moment is to use the rand feature to generate a number between 1 - 100, and then that correspondes to the percentage.  So 1-40 is 0 returns, 41-60 is 100 credits, etc, all the way to 100.

Anyone think of a better solution, as im not very trusting of the random thing, as my results see a little strnage...

Offline Basil Beard

Re: SMFShop and SMF Arcade
« Reply #8 on: September 09, 2006, 04:15:59 am »
Yes. That is how you do random things. Although if you are doing that you could just use the rand feature to get a number between 1 and 10 and do

1-4: 0; 4-6; 100 etc...
Arrrrr!

Offline matkins70

Re: SMFShop and SMF Arcade
« Reply #9 on: September 09, 2006, 07:38:12 am »
Yeah, but then doing 5% and 1% wont be possible, as it selects an integer, and between 1-10, 1% would be 0.1

Offline Daniel15

Re: SMFShop and SMF Arcade
« Reply #10 on: September 10, 2006, 04:45:51 pm »
Quote
  My only idea at the moment is to use the rand feature to generate a number between 1 - 100, and then that correspondes to the percentage.  So 1-40 is 0 returns, 41-60 is 100 credits, etc, all the way to 100.
Yeah, that's probably the best way to get weighed results... Something like


$rand 
mt_rand(0100);
if (
$rand 40) {
	
$number 0;
} elseif (
41 $rand && $rand 60) {
	
$number 100;
// and so on
}

Offline matkins70

Re: SMFShop and SMF Arcade
« Reply #11 on: September 10, 2006, 11:08:20 pm »
I thought i was doing so well... :'(

I made the code, uploaded it, put it in the shop,  bought item, but when i used it, i just left a blank item.  Just had the "go back to inventory" link.  Not sure whats wrong.  The code is:

Code: [Select]
<?php

/**********************************************\

|         For the SMFShop Mod                  |

|         (c) 2006 Matkins70                   |

|       http://www.matkins70.com/              |

\**********************************************/



//File: Scratchcard.php

//      Item



//VERSION: 2.1 (Build 9)

//DATE: 10th September 2006

// $Id: Scratchcard.php 17 2006-09-10 14:54:12Z Matkins70 $

class item_Scratchcard extends itemTemplate {

    function 
getItemDetails() {

        
$this->name "MatkinsScratchcard";

        
$this->desc "MatkinsLotto presents the MatkinsScratchcard";

        
$this->price 150;

        

        
$this->require_input false;

        
$this->can_use_item true;

    }



   



    function 
onUse() {

        global 
$db_prefix$ID_MEMBER$item_info;

        

        



        
$rand mt_rand(0,100);
if ($rand 46) {
$winnings 0;
} elseif (45 $rand && $rand 66) {
$winnings 100;

} elseif (65 $rand && $rand 81) {
$winnings 200;
} elseif (80 $rand && $rand 91) {
$winnings 400;
} elseif (90 $rand && $rand 96) {
$winnings 1000;
} elseif (95 $rand && $rand 100) {
$winnings 2000;
} elseif ($rand 100) {
$winnings 4000;
}



if ($winnings 0) {



$result db_query("UPDATE {$db_prefix}members

SET money = money + {&winnings} WHERE ID_MEMBER = 
{$ID_MEMBER}",

__FILE____LINE__);

return "You find a grubby looking coin in your pocket.  You eagerly scratch off the silver foil to reveal your winnings.  You won ".formatmoney($winnings).".  You go back to the shop and collect your winnings and shove them in your back pocket.   Remember kids, gambling can be bad for your health.  If you feel it's taking over your life, walk away.";

} elseif ($winnings 0) {
return "You find a grubby looking coin in your pocket.  You eagerly scratch off the silver foil to reveal your winnings. Sadly you won 0 credits.  You curse under your breath and shake your fist in anger towards the sky.  Remember kids, gambling can be bad for your health.  If you feel it's taking over your life, walk away.";
}


    }



}



?>




Offline Basil Beard

Re: SMFShop and SMF Arcade
« Reply #12 on: September 11, 2006, 05:20:15 am »
For one, your logic is wrong. Instead of $winnings = 100 and $winnings = 0; you should use a double equals. I don't think that should cause the problem though, but you can start there and see if it gets fixed.
Arrrrr!

Offline matkins70

Re: SMFShop and SMF Arcade
« Reply #13 on: September 11, 2006, 06:15:57 am »
So like this?
Code: [Select]
$rand = mt_rand(0,100);
if ($rand < 46) {
$winnings == 0;
} elseif (45 < $rand && $rand < 66) {
$winnings == 100;

} elseif (65 < $rand && $rand < 81) {
$winnings == 200;

Cos it still doesnt work...:(
I thought it was gonna be fine:'(

Offline Basil Beard

Re: SMFShop and SMF Arcade
« Reply #14 on: September 11, 2006, 07:17:00 am »
Erm no, like this

Code: [Select]
  } elseif ($rand == 100) {
$winnings = 4000;
}
...
 } elseif ($winnings == 0) {
return "You find a grubby looking coin in your pocket.  You eagerly scratch off the silver foil to reveal your winnings. Sadly you won 0 credits.  You curse under your breath and shake your fist in anger towards the sky.  Remember kids, gambling can be bad for your health.  If you feel it's taking over your life, walk away.";
}
Arrrrr!