16.01.2012, 14:54
Hello, my question is how to make my lotto system to division the jackpot when the winners are more than one ?
new price = 123, Float:dif; //change to your price amount
new count = 0;
for(new i=0; i<GetMaxPlayers(); i++)
{
if(IsPlayerConnected(i) && Winner[i] == 1)
{
count++;
}
}
if(count > 0)
{
dif = price / count;
price = floatround(dif, floatround_round);
for(new i=0; i<GetMaxPlayers(); i++)
{
if(IsPlayerConnected(i) && Winner[i] == 1)
{
GivePlayerMoney(i, price);
SendClientMessage(i, 0x99999AA, "You won!");
}
}
}
new price = 123, Float:dif; //change to your price amount
new count = 0;
new winmsg[70];
new pName[24];
new string[24];
strcat(winmsg, "Today's lotto winners: ", sizeof(winmsg));
for(new i=0; i<GetMaxPlayers(); i++)
{
if(IsPlayerConnected(i) && Winner[i] == 1)
{
count++;
}
}
if(count > 0)
{
dif = price / count;
price = floatround(dif, floatround_round);
for(new i=0; i<GetMaxPlayers(); i++)
{
if(IsPlayerConnected(i) && Winner[i] == 1)
{
GivePlayerMoney(i, price);
SendClientMessage(i, 0x99999AA, "You won!");
GetPlayerName(i, pName, 24);
format(string,sizeof(string), "%s ",pName);
strcat(winmsg, string, sizeof(winmsg));
}
}
SendClientMessageToAll(playerid, 0x99999AA ,winmsg);
}
new price = 123, Float:dif; //change to your price amount
new count = 0;
new winstring[150], name[MAX_PLAYER_NAME];
for(new i=0; i<GetMaxPlayers(); i++)
{
if(IsPlayerConnected(i) && Winner[i] == 1)
{
count++;
}
}
if(count > 0)
{
format(winstring, sizeof(winstring), "Winners:");
dif = price / count;
price = floatround(dif, floatround_round);
for(new i=0; i<GetMaxPlayers(); i++)
{
if(IsPlayerConnected(i) && Winner[i] == 1)
{
GivePlayerMoney(i, price);
SendClientMessage(i, 0x99999AA, "You won!");
GetPlayerName(playerid, name, sizeof(name));
format(winstring, sizeof(winstring), "%s %s", winstring, name);
}
SendClientMessageToAll(0x999999AA, winstring);
}
}