Mysidia Adoptables Support Forum

Mysidia Adoptables Support Forum (http://www.mysidiaadoptables.com/forum/index.php)
-   Mys v1.2.x Mods (http://www.mysidiaadoptables.com/forum/forumdisplay.php?f=38)
-   -   slotmachine.php, the slotmachine from the levelup, but for the arcade! (http://www.mysidiaadoptables.com/forum/showthread.php?t=2140)

mapleblade 05-04-2011 12:40 PM

slotmachine.php, the slotmachine from the levelup, but for the arcade!
 
2 Attachment(s)
Hiya there as u may have seen, ive made a slotmachine script for when u level and adoptable, that u have a chance to win prices!

Now ive made it that its an new .php file wich includes:

-Unspammable (users can only use it once a day)
-Easy customizable price gold amount



First of all, you will need to run a MYSQL Query
PHP Code:

CREATE TABLE IF NOT EXISTS `adopts_slotmachine_used` (
  `
datevarchar(30) DEFAULT NULL,
  `
usernamevarchar(50) DEFAULT NULL,
  `
ipvarchar(50) DEFAULT NULL
ENGINE=MyISAM DEFAULT CHARSET=latin1

Second: Download the slotmachine map for the images (if you dont already have it from the levelup script)

Third: Download slotmachine.php

And your done :D

EXTRA!
Now the prices seem pretty low, 20,30,50 for once a day, but here i will explain how to edit the prices.

in slotmachine.php find:
PHP Code:

if($slot1 == && $slot2 == && $slot3 == 1){ 

You will see this line under it, this is if all slots are pointed at 1
PHP Code:

$reward 20

Change that value to whatever you like to get as prize when someone gets all 1's

Example:
PHP Code:

$reward 300

Do that the same for 2 and 3, those are precisely the same as the above, and should be under this first code.

Hoep i helped :)

Solistia 05-04-2011 01:15 PM

This is really awesome. I do find 1 problem though. If a user lines up 2 numbers, but they're in slot 2 & 3, they don't get the match 2 prize, only match 1. Is there any way to change that?

mapleblade 05-04-2011 01:20 PM

u have to have all 3 numbers to get a prize, that was meant to be

well, my base is coded like if slot1 =2 and slot2=2 and slot3=2 , then u will get a price, its easy to change tough. as u see this code
PHP Code:

if($slot1 == && $slot2 == && $slot3 == 1){
    
$reward 20;
    } 

You could in example change it to your likings i.e
PHP Code:

if($slot2 == && $slot3 == 1){
    
$reward 20;
    } 

this gives 20 coins when slot 2 and 3 are 1, try messing around with it, its easy :)

Solistia 05-04-2011 01:27 PM

ah, I see, I'll try adding some new prize numbers then :3
Thank you!

mapleblade 05-04-2011 01:28 PM

No Problem :)

Solistia 05-04-2011 01:34 PM

Just in case others would like there to be a match 2 secondary prize (and just change the rewards to match your taste)
Code:

    if($slot1 == 1 && $slot2 == 1 && $slot3 == 1){
    $reward = 30;
    }elseif($slot1 == 2 && $slot2 == 2 && $slot3 == 2){
    $reward = 30;
    }elseif($slot1 == 3 && $slot2 == 3 && $slot3 == 3){
    $reward = 30;
    }elseif($slot1 == 1 && $slot2 == 1 && $slot3 == 2){
    $reward = 10;
    }elseif($slot1 == 1 && $slot2 == 1 && $slot3 == 3){
    $reward = 10;
    }elseif($slot1 == 2 && $slot2 == 1 && $slot3 == 1){
    $reward = 10;
    }elseif($slot1 == 3 && $slot2 == 1 && $slot3 == 1){
    $reward = 10;
    }elseif($slot1 == 2 && $slot2 == 2 && $slot3 == 1){
    $reward = 10;
    }elseif($slot1 == 2 && $slot2 == 2 && $slot3 == 3){
    $reward = 10;
    }elseif($slot1 == 1 && $slot2 == 2 && $slot3 == 2){
    $reward = 10;
    }elseif($slot1 == 3 && $slot2 == 2 && $slot3 == 2){
    $reward = 10;
    }elseif($slot1 == 3 && $slot2 == 3 && $slot3 == 1){
    $reward = 10;
    }elseif($slot1 == 3 && $slot2 == 3 && $slot3 == 2){
    $reward = 10;
    }elseif($slot1 == 1 && $slot2 == 3 && $slot3 == 3){
    $reward = 10;
    }elseif($slot1 == 2 && $slot2 == 3 && $slot3 == 3){
    $reward = 10;
    }else{
    $reward = 1;
    }

It's the long way I'm sure, but I'm no coder |D;;

mapleblade 05-04-2011 01:54 PM

i am not a VERY good coder myself too, but i manage to do stuff, it looks good :)

fadillzzz 05-05-2011 12:56 AM

Quote:

Originally Posted by Solistia (Post 16567)
Just in case others would like there to be a match 2 secondary prize (and just change the rewards to match your taste)
Code:

    if($slot1 == 1 && $slot2 == 1 && $slot3 == 1){
    $reward = 30;
    }elseif($slot1 == 2 && $slot2 == 2 && $slot3 == 2){
    $reward = 30;
    }elseif($slot1 == 3 && $slot2 == 3 && $slot3 == 3){
    $reward = 30;
    }elseif($slot1 == 1 && $slot2 == 1 && $slot3 == 2){
    $reward = 10;
    }elseif($slot1 == 1 && $slot2 == 1 && $slot3 == 3){
    $reward = 10;
    }elseif($slot1 == 2 && $slot2 == 1 && $slot3 == 1){
    $reward = 10;
    }elseif($slot1 == 3 && $slot2 == 1 && $slot3 == 1){
    $reward = 10;
    }elseif($slot1 == 2 && $slot2 == 2 && $slot3 == 1){
    $reward = 10;
    }elseif($slot1 == 2 && $slot2 == 2 && $slot3 == 3){
    $reward = 10;
    }elseif($slot1 == 1 && $slot2 == 2 && $slot3 == 2){
    $reward = 10;
    }elseif($slot1 == 3 && $slot2 == 2 && $slot3 == 2){
    $reward = 10;
    }elseif($slot1 == 3 && $slot2 == 3 && $slot3 == 1){
    $reward = 10;
    }elseif($slot1 == 3 && $slot2 == 3 && $slot3 == 2){
    $reward = 10;
    }elseif($slot1 == 1 && $slot2 == 3 && $slot3 == 3){
    $reward = 10;
    }elseif($slot1 == 2 && $slot2 == 3 && $slot3 == 3){
    $reward = 10;
    }else{
    $reward = 1;
    }

It's the long way I'm sure, but I'm no coder |D;;

Instead of writing super long if statements like a longcat, I suggest you take advantage of array.
This is just a small example:
PHP Code:

$slot = array(1=>mt_rand(1,3), 2=>mt_rand(1,3), 3=>mt_rand(1,3));

$match count(array_unique($slot));

if (
$match === 3)
{
    
// No match. 
}
elseif (
$match === 2)
{
    
// 2 Slots match each other.
}
elseif (
$match === 1)
{
    
// All slots match each other. (i.e. jackpot! :D)



mapleblade 05-05-2011 01:15 AM

thanks, im not that good with array, i saw some examples, but if all 3 match would be good for me xD

fadillzzz 05-05-2011 04:46 AM

Mapleblade, instead of comparing the variable to a number why not just compare it to each other?
PHP Code:

if($slot1 == && $slot2 == && $slot3 == 1){
    
$reward 20;
    } 


should be
PHP Code:

if($slot1 === $slot2 && $slot2 === $slot3){
    
$reward 20;
    } 

That way, you don't need to create another if statement to compare the variable to another number like 2 or 3.


All times are GMT -5. The time now is 12:46 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.