how can i do a gamble type script ?

Discussion in 'PHP' started by Shimurai, Feb 6, 2012.

  1. #1
    hey guys,

    I am trying to do a gable system in php for one of my mmo websites but I'm kinda stuck and would appreciate if you could help me out with this.

    So basically what I need is a script that will tell me if the user wins or looses.

    I already have the winning percentage value, I get this depending on how many credits the user is going to gamble, but that part is already done.

    so for example, lets say my user wants to gamble with 500 credits, and he will get 12% chance of winning. My question is, how can I make a code that will use that 12% chance of winning to decide if the user is a winner or not?

    any help will be greatly appreciated !
     
    Shimurai, Feb 6, 2012 IP
  2. dany3l89

    dany3l89 Active Member

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    96
    #2
    $chance=12;
    $rand=rand(1,100);
    if($chance>=$rand){
        echo "You win";
    }else{
        echo "You lose";
    }
    PHP:
     
    dany3l89, Feb 7, 2012 IP