How Can i Do random between two 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: How Can i Do random between two money (
/showthread.php?tid=621217)
How Can i Do random between two money -
TYDS - 08.11.2016
like the title i want onplayerentercheckpoint it's will random a money is 5000 and 6500
and random some sendclientmessege
Re: How Can i Do random between two money -
Tass007 - 08.11.2016
Basically you need this function created by Y_Less.
Code:
randomEx(minnum = cellmin, maxnum = cellmax) return random(maxnum - minnum + 1) + minnum; // Credits to Y_Less (Add this anywhere in your script)
Then you call the function since you want it in OnPlayerEnterCheckpoint do it there.
PHP Code:
public OnPlayerEnterCheckpoint(playerid)
{
new rand, string[128];
rand = randomEx(5000, 6500); //Creates a random number between 5000, and 6500
GivePlayerMoney(playerid, rand); //Gives the player the random number generated
format(string,sizeof(string), "You have been given $%d.", rand); //Formats the message that will be displayed to the player
SendClientMessage(playerid, COLOR_WHITE, string); //Prints the message
return 1;
}
This hasn't been tested. Also it's best that if you're going to be using multiple checkpoints to use a streamer and use CreateDynamicCP because defaulty using SetPlayerCheckpoint you can only have 1 in your server. This may cause issues and it's also a good idea to give each checkpoint an ID so that if you have several different checkpoints doing different things that each checkpoint is doing what they are meant to be doing. I hope this helps you.
Also just letting you know that if you are going to continue to request scripts you should be doing it on this topic.
https://sampforum.blast.hk/showthread.php?tid=447813
Because requesting scripting and not giving it a go is not supposed to be posted in this section.
Re: How Can i Do random between two money -
Killa[DGZ] - 08.11.2016
I knocked this up real quick for ya, should do the job.
PHP Code:
}
stock DualValueRandomEx(min, max)
{
new rand = random(max-min)+min;
return rand;
}