How Can i Do random between two money
#1

like the title i want onplayerentercheckpoint it's will random a money is 5000 and 6500
and random some sendclientmessege
Reply
#2

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 
randstring[128];
    
rand randomEx(50006500); //Creates a random number between 5000, and 6500
    
GivePlayerMoney(playeridrand); //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(playeridCOLOR_WHITEstring); //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.
Reply
#3

I knocked this up real quick for ya, should do the job.
PHP Code:
}

stock DualValueRandomEx(minmax)
{
    new 
rand random(max-min)+min;
    return 
rand;

Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)