SA-MP Forums Archive
Random tips on checkpoint - 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 tips on checkpoint (/showthread.php?tid=554387)



Random tips on checkpoint - cyberlord - 03.01.2015

Hello can some1 help my to do like random tips , i am doing pizza boy job everything set , just need to make random tips when delivery pizza i just need a sample how to make it random value of some variable so i can use that variable when giving money to player


Re: Random tips on checkpoint - Neos07 - 03.01.2015

I didn't understand, tip = advice or tip for money?


Re: Random tips on checkpoint - PaulDinam - 03.01.2015

Use that:

pawn Код:
stock randomNum(min, max)
{    
    new rand = random(max-min)+min;    
    return rand;
}



Re: Random tips on checkpoint - DavidBilla - 03.01.2015

new Var=random(2000)+1;

This will assign the Var with any value between 0-1999 and add 1 to it.


Just an example of how to assign random values


AW: Random tips on checkpoint - CutX - 03.01.2015

Quote:
Originally Posted by cyberlord
Посмотреть сообщение
Hello can some1 help my to do like random tips , i am doing pizza boy job everything set , just need to make random tips when delivery pizza i just need a sample how to make it random value of some variable so i can use that variable when giving money to player
so a random tip?
pawn Код:
GivePlayerMoney(playerid,random(501)+10);
this will give the pizza guy a random tip from minimum 10 to maximum 510


Re: Random tips on checkpoint - cyberlord - 03.01.2015

tnx u everytone another question is this code works :

Код:
GivePlayerMoney(playerid,random(20)+0);
			if(GivePlayerMoney(playerid,random(20)+0) ==0)
			{
                GameTextForPlayer(playerid,"~r~Fucking greedy old man",3000,3);
			}
			else
			{
                GameTextForPlayer(playerid,"~g~You got %d tip",3000,3,random());
			}
if not please tell my what i did wrong


AW: Re: Random tips on checkpoint - CutX - 03.01.2015

Quote:
Originally Posted by cyberlord
Посмотреть сообщение
tnx u everytone another question is this code works :

Код:
GivePlayerMoney(playerid,random(20)+0);
			if(GivePlayerMoney(playerid,random(20)+0) ==0)
			{
                GameTextForPlayer(playerid,"~r~Fucking greedy old man",3000,3);
			}
			else
			{
                GameTextForPlayer(playerid,"~g~You got %d tip",3000,3,random());
			}
if not please tell my what i did wrong
partially
you would have to format the message
pawn Код:
new cash = random(20);//don't need 0 it's from 0 to 19 but 0 happens rarely
    GivePlayerMoney(playerid,cash);
    if(!cash)//if its 0, we invert it so that the control statement euqals true to get our message displayed
    {
        GameTextForPlayer(playerid,"~r~Fucking greedy old man",3000,3);
    }
    else//anything besides 0
    {
        new str[18];
        format(str,sizeof str,"~g~You got %d tip",cash);
        GameTextForPlayer(playerid,str,3000,3);
    }



Re: Random tips on checkpoint - cyberlord - 03.01.2015

works tnx u