Advertisement
legodude

legodude

Aug 26th, 2010
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.60 KB | None | 0 0
  1. public Lotto()
  2. {
  3.     new winner = random(100);
  4.     for(new i=0;i<MAX_PLAYERS;i++)
  5.     {
  6.         if(pInfo[i][LotteryNumber] == winner)
  7.         {
  8.             new PlayerName[MAX_PLAYER_NAME], string[256];
  9.             GetPlayerName(i, PlayerName, MAX_PLAYER_NAME);
  10.             format(string,sizeof(string),"%s won the lottery with number %d! He'll receive $50000,-",PlayerName, winner);
  11.             SendClientMessageToAll(COLOR_GOLD, " ");
  12.             SendClientMessageToAll(COLOR_GOLD, "<<<!!!!And we have a winner!!!!>>>");
  13.             SendClientMessageToAll(COLOR_SILVER, string);
  14.             SendClientMessageToAll(COLOR_GOLD, "<<<!!!!Congratulations!!!!>>>");
  15.             SendClientMessageToAll(COLOR_GOLD, " ");
  16.             print(string);
  17.             GivePlayerMoney(i, 50000);
  18.             pInfo[i][LotteryNumber] = 0;
  19.             return 1;
  20.         }
  21.         new string[256];
  22.         format(string,sizeof(string),"The winning number was %d, to bad nobody picked it.", winner);
  23.         SendClientMessageToAll(COLOR_GOLD, " ");
  24.         SendClientMessageToAll(COLOR_GOLD, "<<<!!!!Lotto: No winner>>>");
  25.         SendClientMessageToAll(COLOR_SILVER, string);
  26.         print(string);
  27.         SendClientMessageToAll(COLOR_GOLD, "<<<!!!!Better luck next time!!!!>>>");
  28.         SendClientMessageToAll(COLOR_GOLD, " ");
  29.         pInfo[i][LotteryNumber] = -1;
  30.         return 1;
  31.     }
  32. }
  33. dcmd_lotto(playerid, params[])
  34. {
  35.         if(pInfo[playerid][LotteryNumber] >= 0)
  36.         {
  37.             SendClientMessage(playerid, COLOR_RED, "You already picked a lottery number, try again in the next round.");
  38.             return 1;
  39.         }
  40.         if(!strlen(params))
  41.         {
  42.             SendClientMessage(playerid, COLOR_RED, "USAGE: /lotto [number]");
  43.             return 1;
  44.         }
  45.         if(!IsNumeric(params))
  46.         {
  47.             SendClientMessage(playerid, COLOR_RED, "USAGE: /lotto [number]");
  48.             return 1;
  49.         }
  50.         if(strval(params) < 1 || strval(params) > 100)
  51.         {
  52.             SendClientMessage(playerid, COLOR_RED, "USAGE: /lotto [number] [1-100]");
  53.             return 1;
  54.         }
  55.         print("1-1");
  56.         for(new i=0;i<MAX_PLAYERS;i++)
  57.         {
  58.             if(pInfo[i][LotteryNumber] == strval(params))
  59.             {
  60.             print("1-3");
  61.             SendClientMessage(playerid, COLOR_RED, "This number has already been chosen, please pick another one.");
  62.             print("1-4");
  63.             return 1;
  64.             }
  65.         }
  66.         print("0");
  67.         pInfo[playerid][LotteryNumber] = strval(params);
  68.         print("1");
  69.         new string[256];
  70.         print("2");
  71.         format(string, sizeof(string), "You chose %d as your lottery number, the winning number will be revealed every 15 minutes.", strval(params));
  72.         print("3");
  73.         SendClientMessage(playerid, COLOR_GOLD, string);
  74.         return 1;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement