Random money
#1

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.
Reply
#2

Ye you can: Simple!
Код:
new cash = random(32001);
GivePlayerMoney(playerid, cash+8000);
This code will give player money between 8000-40000 cash.
Reply
#3

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.
Reply
#4

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?
Reply
#5

semara456 dont worry i get it what were you telling me thaks!
Reply
#6

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.
Reply
#7

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!!
Reply
#8

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.
Reply
#9

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....
Reply
#10

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
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)