#1

Just created one job, and i set new cash = random(1000-1500);


pawn Код:
if(RidingThroughtCoronas[playerid] == 21)
    {
        new cash = random(1000-1500);
    GivePlayerMoney(playerid, cash);
        new string[128];
        format(string, sizeof(string), "[JOB] You just finished your job and earned: $%d", cash);
        SendClientMessage(playerid, 0x10F441AA, string);
        DisablePlayerRaceCheckpoint(playerid);
        RidingThroughtCoronas[playerid] = 0;
    }
and somehow i earned instead of 1000-1500.. Explanations? :$
Reply
#2

First, "random" generates a number between 0 and the number.
Random doesn't work with negative numbers.
And please, tell me what's the result of 1000-1500 ? It's -500.

Try this function to generate a random number contained in a range

PHP код:

stock randomEx
(minmax)
{
      if(
min max) return -1;
      return 
min random(max-min);

Reply
#3

too lazy to make stock lel..

basicaly
pawn Код:
cash = GivePlayerMoney(playerid, random(500) + 1000);
should work?
Reply
#4

Yes, it should.
Reply
#5

I've got randomized money

but it does not says that..

pawn Код:
format(string, sizeof(string), "[JOB] You just finished your job and earned: $%d", cash);
i tried using %i integer instead of %d, same thing...
Reply
#6

pawn Код:
cash = random(500) + 1000;
 GivePlayerMoney(playerid,cash);
Reply
#7

@XO : The give money works, it's the message which doesn't work.

@Stereotype : I keep thinking about that but I noticed your signature message and you can disable it using /audiomsgoff InGame.
Reply
#8

he used
pawn Код:
cash = GivePlayerMoney(playerid, random(500) + 1000);
So cash will return 0/1 according to https://sampwiki.blast.hk/wiki/Function:GivePlayerMoney
1: The function executed successfully.
0: The function failed to execute. This means the player is not connected.
So you have to make cash=value of the random... and use cash then..
Reply
#9

Very well observed.
That's effectively the source of the problem, and I haven't noticed it myself.

+rep for you, even if I'm not related at all to the problem.
Reply
#10

Quote:
Originally Posted by S4t3K
Посмотреть сообщение
@Stereotype : I keep thinking about that but I noticed your signature message and you can disable it using /audiomsgoff InGame.
That audio message is not related to this problem, thanks for supporting, doing this 16 hours litteraly.. so tired man

@XO Thanks, i am too tired to notice all the things..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)