SA-MP Forums Archive
Job 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: Job money (/showthread.php?tid=618482)



Job money - fireriper2 - 06.10.2016

if(randfish == 4)
{
new fish[128];
new price = 1800 + random(500);

What means that random(500) ?
I want to change the job's payment.


Re: Job money - Jayse - 06.10.2016

random(500) will return a random value between 0 and 499.

1, 2, 3, 4, 5, ..., 498, 499.


Re: Job money - fireriper2 - 06.10.2016

Oh, and if I'll use random(5000) will return something between 0 and 4999?


Re: Job money - Vince - 06.10.2016

Yes, the random function returns a random number between 0 (inclusive) and the upper bound you supplied (exclusive).

Quote:

random
[ran-duh m]

adjective
1.
proceeding, made, or occurring without definite aim, reason, or pattern:
the random selection of numbers.



Re: Job money - lackmail - 06.10.2016

Quote:
Originally Posted by fireriper2
Посмотреть сообщение
Oh, and if I'll use random(5000) will return something between 0 and 4999?
yes but if you want to change the payment you have to change the 1800 in this line aswell :

Код:
new price = 1800 + random(500);
1800 is the fixed price that you will get no matter what but + random(500) is maybe a bonus? means when you done the job you will get 1800 + random amount between 0 and 500


Re: Job money - fireriper2 - 06.10.2016

And I can do something like excluding that random like everywhere using random(0) and just editing that new price = 1800 to make it like new price = 5000 + random(0) ?


Re: Job money - lackmail - 06.10.2016

Quote:
Originally Posted by fireriper2
Посмотреть сообщение
And I can do something like excluding that random like everywhere using random(0) and just editing that new price = 1800 to make it like new price = 5000 + random(0) ?
if you want to give fixed amount of money then do it without the random or the variable just GivePlayerMoney(playerid, payment);