Percent in PHP

Discussion in 'PHP' started by CuBz, Nov 22, 2007.

  1. #1
    how do i do percent in php?

    i have a mafia game and when someone kills someone i want the killer to get between 25 - 75 % of the user they kill's money


    EG/ If the user 'CuBz' was to kill the user 'Danny' then 'CuBz' should get between 25% - 75% of Danny's Money

    How would i do this?

    Cheers

    Cheers
     
    CuBz, Nov 22, 2007 IP
  2. whitewhidow

    whitewhidow Peon

    Messages:
    160
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    why dont u use

    something along lines of

    $p1Money = winning player his money;
    $p2money = losing player 2 his money;
    $temp = rand(25, 75);
    $temp2 = $p2money/100;
    $moneytoadd = $temp2*$temp2;

    then just use function to round the numbers
    and then add $moneytoadd to $p1Money
    make any sense ?
     
    whitewhidow, Nov 22, 2007 IP
  3. CuBz

    CuBz Peon

    Messages:
    117
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3

    Yep made a lot of sence but i worked it out bfore you answered lol

    Cheers anyway ;)
     
    CuBz, Nov 22, 2007 IP
  4. whitewhidow

    whitewhidow Peon

    Messages:
    160
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    np, let me know when your its finished ...
     
    whitewhidow, Nov 22, 2007 IP
  5. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #5
    $takes = max(0.25, lcg_value() * 0.75) * $dead_players_cash;
    Code (markup):
     
    joebert, Nov 22, 2007 IP