[SOLVED] Random Money
#9

Quote:
Originally Posted by Amit B
Quote:
Originally Posted by ♣ ⓐⓢⓢ
Quote:
Originally Posted by Amit B
Try this:
pawn Код:
GivePlayerMoney(playerid,random(100000-50000)+50000);
if you can sub 50000 from 100000 than you see its 50000 and that would be the same as in my post, I just put +1 because he wanted 100000 included
Quote:
Originally Posted by ♣ ⓐⓢⓢ
pawn Код:
if(pickupid == your_pickup)
    {
        GivePlayerMoney(playerid, ([b]50_000[/b] + random([b]50_001[/b])));
    }
50_000?
I just use they to better read the numbers, or do you think 300000000000 is better readable as 300_000_000_000 ?

Quote:
Originally Posted by Kinetic
Quote:
Originally Posted by Pyrokid
This goes at the top of your script.
pawn Код:
#define MAX_CASH 100000
new randmoney;
Then put this in OnPlayerPickUpPickup.
pawn Код:
if(pickupid == your_pickup)
    {
    randmoney = random(MAX_CASH);
        GivePlayerMoney(playerid,randmoney);
    }
Close, but no cigar. It should be like this.

There is no need for this
#define MAX_CASH 100000
new randmoney;

OnPlayerPickUpPickup.
pawn Код:
if(pickupid == your_pickup)
  {
    new str[44];
    new randmoney = random(100001) - 50000;
    format(str, sizeof(str), " >> Player picked up %s and recieved $%d", your_pickup, randmoney);
    SendClientMessage(playerid, 0xffffffff, str);
    GivePlayerMoney(playerid, randmoney);
  }
Did you even looked my or Amit B's post ?, because they have the right answer not yours

Reason:
random(100001) will be a number from 0 till 100000 (0 and 100000 included)
and then you do "- 50000" also lets say the random returns 300 => 300 - 50000 = -40700 :S

I hate this kinds of topics, the right solution got posted in one of the first posts (the 4th in this topic) and gets one page big
Reply


Messages In This Thread
[SOLVED] Random Money - by Alec24 - 21.03.2009, 20:11
Re: Random Money - by Pyrokid - 21.03.2009, 20:50
Re: Random Money - by Alec24 - 21.03.2009, 21:01
Re: Random Money - by Nero_3D - 21.03.2009, 21:11
Re: Random Money - by Amit_B - 21.03.2009, 22:20
Re: Random Money - by Nero_3D - 21.03.2009, 22:39
Re: Random Money - by Amit_B - 22.03.2009, 06:22
Re: Random Money - by Kinetic - 22.03.2009, 07:18
Re: Random Money - by Nero_3D - 22.03.2009, 11:47
Re: Random Money - by Alec24 - 22.03.2009, 18:39

Forum Jump:


Users browsing this thread: 1 Guest(s)