Auto Select a free number from 1 - 30
#4

Quote:
Originally Posted by AroseKhanNiazi
Посмотреть сообщение
Lottery number between 1 - 30
What i want to do it that it selects any number that is free for the player
here
PlayerInfo[i][pLottoNumber] this stores players lotto number

I can't really make the logic for it tired of thinking how it will work.
pawn Код:
for(new b=1; b < 30; b++)
                {
                    number = b;
                    for(new i=0,j=GetPlayerPoolSize(); i <= j; i++)
                    {
                        if(IsPlayerConnected(i))
                        {
                            if(PlayerInfo[i][pLottoNumber] == number)
                            {
                                numbertaken=true;
                                continue;
                            }
                            else
                            {
                                numbertaken=false;
                                break;
                            }
                        }
                    }
                    if(!numbertaken) break;
                }
                if(numbertaken)
                {
                    SendClientMessage(playerid,COLOR_ERROR,"Sorry All Lottery Numbers Haven Been Booked Already.");
                }
                else
                {
                    PlayerInfo[playerid][pLottoNumber] = number;
                    format(string,sizeof(string),"You Have Successfully Taken Number "YELLOW"%d"WHITE", For Daily "GREEN"Lottery"WHITE" Draw At "YELLOW"18:00",number);
                    SendClientMessage(playerid,COLOR_WHITE,string);
                    GivePlayerCash(playerid,-500);
                }
Quote:
Originally Posted by AroseKhanNiazi
Посмотреть сообщение
No that's not what i am trying to do i have a lottery system with a draw at certain time we need to buy tickets for it. There are 3 options to buy tickets 1 select number our own self, 2 get a random number and 3 get a number that is free starting from 1 - 30 in sequence.
So the part i can't figure out is 3rd one i tried that code i posted up
Oh well,
I have one!

PHP код:
public OnPlayerCommandText(playeridcmdtext[])
{
 if (
strcmp("/lotto"cmdtexttrue) == 0)
    {
   new 
tmp[256];
    new   
Ergebniss;
    
GivePlayerMoney(playerid, -2000);
    
Jackpot Jackpot 2000;
      
tmp strtok(cmdtextidx);
   if(!
strlen(tmp))
      {
         
SendClientMessage(playeridCOLOR_WHITE"Benutzung: /lotto [Choose a number 1-99]");
         return 
1;
      }
    if (
GetPlayerMoney(playerid)>=&& GetPlayerMoney(playerid)<=100000)
      {
         
Ergebniss 9;
         
Lottozahl Lottozahl Ergebniss;
         if(
Lottozahl >=100)
            {
               
Lottozahl Ergebniss;
            }
      }
    if (
GetPlayerMoney(playerid)>=100000 && GetPlayerMoney(playerid)<=1000000)
      {
         
Ergebniss 8;
         
Lottozahl Lottozahl Ergebniss;
         if(
Lottozahl >=100)
            {
               
Lottozahl Ergebniss;
            }
      }
    if (
GetPlayerMoney(playerid)>=1000000 && GetPlayerMoney(playerid)<=999999999)
      {
         
Ergebniss 7;
         
Lottozahl Lottozahl Ergebniss;
         if(
Lottozahl >=100)
            {
               
Lottozahl Ergebniss;
            }
      }
   if(
strval(tmp) == Lottozahl)
      {
      
GivePlayerMoney(playeridJackpot);
      }
   return 
1;
   }
return 
0;

PS: Here is also a tutorial https://sampforum.blast.hk/showthread.php?tid=160025
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)