22.04.2014, 17:01
How can i do that to get the random amount of cash from all and give it to other the cash from players total cash and the max limit 3M (3000000)
new pmoney, randcash;
pmoney = GetPlayerMoney(playerid);
randcash = random(pmoney);
GivePlayerMoney(input, randcash); // please replace "input" with an appropiate ID other than playerid.
stock randomEx(min, max)
{
new rand = random(max-min)+min;
return rand;
}
Use:
for(new i=0; i<MAX_PLAYERS; i++)
{
new amount = randomEx(0, 3000000);
GivePlayerMoney(i, -amount);
GivePlayerMoney(playerwhowillgetmoney, 2*amount); // 2* is because he already lost 'amount' like everybody else, so he needs twice...
}
BTW code randomEx is not mine!
if(GameHour == 23 && GameMinute == 59)
{
for(new i = 0; i < GetMaxPlayers(); i++)
{
for(new playerid = 0; playerid < MAX_PLAYERS; playerid++)
{
if(IsPlayerConnected(i) && spawned[playerid] == 1)
{
pInfo[i][pDaysAlive] ++;
if(pInfo[i][pDaysAlive] == 365)
{
pInfo[playerid][pBirthdays] ++;
new pmoney, randcash;
pmoney = GetPlayerMoney(i);
randcash = random(pmoney);
GivePlayerMoney(playerid, randcash);
SCM(playerid,COLOR_RED,"BIRTHDAY TEST");
}
}
}
}
}
GivePlayerMoney(input, -randcash);