Random money - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Random money (
/showthread.php?tid=574444)
Random money -
GTLS - 17.05.2015
Quote:
Originally Posted by sansk
You could also do something like:
Код:
new cash = random(40-100);
GivePlayerMoney(playerid, cash);
|
what does this do?
and yes how do i make it that random money comes between 8000 and 40000 when a player enters a check point?
i also want while doing a job delivery pickup you get random amount of materials loaded between 0(yes 0 also) and 15?
(I am making a trucking delivery job so when a player enters first CP he gets rand mats and then 2nd cp upto 4 and at last when he enters last cp he gets rand money as i stated above and rand mats to player file between 500 and 3000 ||| after that total mats also added to mats bank(the total mats that collects[rand mats] in job x 1000 mats get added) so that when players come in mats bank to buy mats the have some limits.. if some mats get left (ie unpurchased by players) then it wil also be saved.)
Thanks if you can solve me! i will REP+ you with real respect.
Re: Random money -
VishvaJeet - 17.05.2015
Ye you can: Simple!
Код:
new cash = random(32001);
GivePlayerMoney(playerid, cash+8000);
This code will give player money between 8000-40000 cash.
Re: Random money -
Konstantinos - 17.05.2015
The above (from your quote) would return some weird value as the input must be 0 to max-1.
pawn Код:
RandomEx(min, max) // By ******
{
return random(max - min) + min;
}
EDIT: usage:
pawn Код:
new cash = RandomEx(8000, 40001);
cash is a value between 8000 and 40000.
Re: Random money -
GTLS - 17.05.2015
Quote:
Originally Posted by Konstantinos
The above would return some weird value as the input must be 0 to max-1.
pawn Код:
RandomEx(min, max) // By ****** { return random(max - min) + min; }
|
sorry but i dont understand what should i do with them?
Re: Random money -
GTLS - 17.05.2015
semara456 dont worry i get it what were you telling me thaks!
Re: Random money -
VishvaJeet - 17.05.2015
Quote:
Originally Posted by VishvaJeet
Ye you can: Simple!
Код:
new cash = random(32000);
GivePlayerMoney(playerid, cash+8000);
This code will give player money between 8000-40000 cash.
|
GTLS use my code.
Re: Random money -
GTLS - 17.05.2015
Quote:
Originally Posted by VishvaJeet
GTLS use my code.
|
LOL thanks i will use both codes i probably will merge 2 codes and will use it thanks!!
Re: Random money -
Konstantinos - 17.05.2015
Quote:
Originally Posted by GTLS
sorry but i dont understand what should i do with them?
|
I was editing my post the time you posted it but you probably didn't see that.
usage:
pawn Код:
new cash = RandomEx(8000, 40001);
cash is a value between 8000 and 40000.
It's just that RandomEx is easier to be used:
RandomEx(min_number, max_number + 1)
@VishvaJeet: Your code will generate a value between 8000-39999.
Re: Random money -
GTLS - 17.05.2015
Quote:
Originally Posted by Konstantinos
I was editing my post the time you posted it but you probably didn't see that.
usage:
pawn Код:
new cash = RandomEx(8000, 40001);
cash is a value between 8000 and 40000.
It's just that RandomEx is easier to be used: RandomEx(min_number, max_number + 1)
@VishvaJeet: Your code will generate a value between 8000-39999.
|
Thanks to solve problem....
Re: Random money -
VishvaJeet - 17.05.2015
Quote:
Originally Posted by VishvaJeet
Ye you can: Simple!
Код:
new cash = random(32001);
GivePlayerMoney(playerid, cash+8000);
This code will give player money between 8000-40000 cash.
|
Fixed