Lotto system
#1

Hello, my question is how to make my lotto system to division the jackpot when the winners are more than one ?
Reply
#2

Search for lotto system and get ideas for how to make it...
http://lmgtfy.com/?q=sa-mp+lotto+system
https://sampforum.blast.hk/showthread.php?tid=160025
https://sampforum.blast.hk/showthread.php?tid=139091
https://sampforum.blast.hk/showthread.php?tid=35631
https://sampforum.blast.hk/showthread.php?tid=100085
Reply
#3

pawn Код:
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!");
    }
  }
}
something like that.. you will have to edit it to make it fit to your system ofc.
Reply
#4

Thanks to Sascha !
Another simple question:
How to make when the winners are more than one to write their names in 1 line ?
Reply
#5

I just threw this together quickly :O

pawn Код:
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);
}
Reply
#6

viper_viper this not working any other ideas ?

I mean when we have 3 winners to show their names in the chat with SendClientMessageToAll in 1 line !
Reply
#7

BUMP by BGMIKE
Reply
#8

pawn Код:
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);
  }
}
if you still need it, this should work
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)