huh? -
Stereotype - 30.06.2014
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? :$
Re : huh? -
S4t3K - 30.06.2014
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(min, max)
{
if(min > max) return -1;
return min + random(max-min);
}
Re: huh? -
Stereotype - 30.06.2014
too lazy to make stock lel..
basicaly
pawn Код:
cash = GivePlayerMoney(playerid, random(500) + 1000);
should work?
Re : huh? -
S4t3K - 30.06.2014
Yes, it should.
Re: huh? -
Stereotype - 30.06.2014
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...
Re: huh? -
xo - 30.06.2014
pawn Код:
cash = random(500) + 1000;
GivePlayerMoney(playerid,cash);
Re : huh? -
S4t3K - 30.06.2014
@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.
Re: huh? -
xo - 30.06.2014
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..
Re : huh? -
S4t3K - 30.06.2014
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.
Re: Re : huh? -
Stereotype - 30.06.2014
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..