Random - 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 (
/showthread.php?tid=503125)
Random -
Ananisiki - 27.03.2014
pawn Код:
randmoney = random(50000 - 1000) + 1000;
Could anyone plz explain this to me
Re: Random -
Jefff - 27.03.2014
random moneys from 1000 to 50000
Re: Random -
SkilledMaster - 28.03.2014
This is for a player to pick up
OnPlayerPickUpPickup.
Код:
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);
}
Or if you want to give people cash
OnPlayerSpawn
Код:
GivePlayerMoney(playerid,random(100000-50000)+50000);
Re: Random -
arakuta - 28.03.2014
pawn Код:
randmoney = random(50000 - 1000) + 1000;
// randmoney is a variable. It can store a value.
//random is a function that generate a random number between 0 and it params, for example:
//random(1000) will return a number between 0 and 999.
//+ 1000 always will add 1000 to the random value;
//For example, random return 515. 515 + 1000 = 515, so randmoney = 515.
Re: Random -
newbie scripter - 28.03.2014
Quote:
Originally Posted by arakuta
pawn Код:
randmoney = random(50000 - 1000) + 1000; // randmoney is a variable. It can store a value. //random is a function that generate a random number between 0 and it params, for example:
//random(1000) will return a number between 0 and 999.
//+ 1000 always will add 1000 to the random value; //For example, random return 515. 515 + 1000 = 515, so randmoney = 515.
|
515 + 1000 = 1515 not 515
Re: Random -
Ananisiki - 29.03.2014
The random money sets to 1000 sometimes, how can i change this to a price of between 40k and 100k?
Re: Random -
Vince - 29.03.2014
Код:
40000 + random(60000)
It's not rocket science.
Re: Random -
Ananisiki - 29.03.2014
So from
pawn Код:
randmoney = random(50000 - 1000) + 1000;
to
pawn Код:
randmoney = random(40000 + 60000) + 1000;
What does the +1000 mean?
Re: Random -
Konstantinos - 29.03.2014
No, the above will generate a number between 1000 and 100999. If you confuse and you can't understand what you should do, then use a function ****** wrote:
pawn Код:
stock RandomEx(min, max)
{
return random(max - min) + min;
}
and usage:
pawn Код:
randmoney = RandomEx(40000, 100000);