SA-MP Forums Archive
Lotto system - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Lotto system (/showthread.php?tid=311415)



Lotto system - BGMike - 16.01.2012

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


Re: Lotto system - thimo - 16.01.2012

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


Re: Lotto system - Sascha - 16.01.2012

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.


Re: Lotto system - BGMike - 17.01.2012

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


Re: Lotto system - viper_viper - 17.01.2012

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);
}



Re: Lotto system - BGMike - 17.01.2012

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 !


Re: Lotto system - cs_waller - 30.01.2012

BUMP by BGMIKE


Re: Lotto system - Sascha - 03.02.2012

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