Random money problem
#1

Hello guys i made a robbery dialog and when i rob something
i get alot of money for the reason that i puted random money
so the player gets a random amount of money
but it gives to much can you guys help me make it like the minimum is 5000 and the maximum is 1000
so i wont get a large amount of money here is my code that i am using:

pawn Код:
@Robbing(playerid);
@Robbing(playerid)
{
    new mrand =random(GetPlayerMoney(playerid));
    new string[120];
    new Time = GetPVarInt(playerid, "Robbing24/7Shop");
    if(!IsPlayerConnected(playerid))
        return 0;

    if(Time < 1)
    {
      SetPVarInt(playerid, "Robbing24/7Shop", 0);
      SetTimer("ShopRobAgain", 360000, 0);
      GivePlayerMoney(playerid,mrand);
      IncreaseScore(playerid,1);
      format(string,sizeof(string),"You have succesfully robbed $%d",mrand,playerid);
      return SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
    }

    new str[30];
    format(str, sizeof(str), "Robbery time left: %d", Time);
    GameTextForPlayer(playerid, str, 2500, 3);

    SetPVarInt(playerid, "Robbing24/7Shop", Time - 1);
    SetTimerEx("@Robbing", 1000, false, "i", playerid);
    return 1;
}
Reply
#2

Use search in pawno ctrl+f and find "mrand" there you will see seted price and just edit ammount of money
Reply
#3

There is no setted price it was set like that
pawn Код:
new mrand =random(GetPlayerMoney(playerid));
it is auto set to random so but i dont know how to set it to a diffrent price
Reply
#4

This isn't my code, but it should work. Credits to Fj0ritzFredde and ******
pawn Код:
stock randomEx(min, max)
{
new rand = random(5000, 10000)+5000;
return rand;
}
So this is the code, you don't have to rename any of the variables.
pawn Код:
new mrand = randomEx(5000,10000);
Reply
#5

Thanks alot it really helped
Reply
#6

Quote:
Originally Posted by DarkLored
Посмотреть сообщение
Thanks alot it really helped
No problem.
Reply
#7

Another problem happend
when i add what idd you said
this warnings showed up
Код:
C:\Program Files (x86)\Microsoft Power\GTA San Andreas\TeamDeathMatch\gamemodes\CNR.pwn(2451) : warning 202: number of arguments does not match definition
C:\Program Files (x86)\Microsoft Power\GTA San Andreas\TeamDeathMatch\gamemodes\CNR.pwn(2449) : warning 203: symbol is never used: "max"
C:\Program Files (x86)\Microsoft Power\GTA San Andreas\TeamDeathMatch\gamemodes\CNR.pwn(2449) : warning 203: symbol is never used: "min"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Warnings.
Can someone give me a code that works for this??
Reply
#8

pawn Код:
stock randomEx(min, max)
{
new rand = random(max)+min;
return rand;
}
Reply
#9

pawn Код:
new mrand = random(10000)(GetPlayerMoney(playerid))
I get this error after setting it up
Код:
C:\Program Files (x86)\Microsoft Power\GTA San Andreas\TeamDeathMatch\gamemodes\CNR.pwn(1948) : error 017: undefined symbol "randomEX"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Reply
#10

try
Код:
new randomEX[MAX_PLAYERS]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)