Guest User

[FS] Loteria loototto

a guest
Mar 25th, 2012
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 8.56 KB | None | 0 0
  1. #include <a_samp>
  2. #define MAX_NO 1000 //Max numeros da loteria
  3. #define LOTTO_PRICE 1000 //Valor para aposta
  4. #define HOW_LONG 270 //Tempo da loteria
  5. #define MAX_JACKPOT 100000 //Maximo pagamento.
  6. #define MIN_JACKPOT 10000 //Minimo pagamento.
  7. #define GetPlayerGrana GetPlayerMoney
  8. #define GivePlayerGrana GivePlayerMoney
  9.  
  10. new Lottery;
  11. new LottoEnabled;
  12.  
  13.  
  14. forward lottery();
  15. new string[256];
  16. new playername[MAX_PLAYER_NAME];
  17. new wonlotto[MAX_PLAYERS],donelotto[MAX_PLAYERS];
  18. new jackpot,lotto,lotto2,lotto3,lotto4,lotto5,lotto6;
  19. new price = LOTTO_PRICE;
  20. new time = HOW_LONG;
  21. #define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  22. #define COLOR_GREEN 0x33AA33AA
  23. #define COLOR_RED 0xAA3333AA
  24. #define COLOR_WHITE 0xFFFFFFAA
  25. #define COLOR_ORANGE 0xFF8040FF
  26. #define PURPLE 0x7E00FDFF
  27. #define RED 0xFF0000FF
  28. #define GREEN 0x008000FF
  29. //================================================================================
  30. public OnPlayerCommandText(playerid, cmdtext[])
  31. {
  32.     dcmd(lotto,5, cmdtext);
  33.     dcmd(lottohelp,9, cmdtext);
  34.     dcmd(lottoon,7, cmdtext);
  35.     dcmd(lottooff,8, cmdtext);
  36.     dcmd(lottoprice,10, cmdtext);
  37.     dcmd(lottery,7, cmdtext);
  38.     dcmd(winlotto,8, cmdtext);
  39.     dcmd(lottotime,9, cmdtext);
  40.     return 0;
  41. }
  42. //================================================================================
  43. public OnFilterScriptInit()
  44. {
  45.         return 1;
  46. }
  47.  
  48. public lottery()
  49. {
  50.     for(new i=0;i<MAX_PLAYERS;i++)
  51.     {
  52.         format(string, sizeof(string),"Loterias Servidor BRASIL: Numeros da Sorteados: %d, %d, %d, %d, %d, %d!",lotto,lotto2,lotto3,lotto4,lotto5,lotto6);
  53.         SendClientMessage(i,PURPLE,string);
  54.         SendClientMessage(i,COLOR_GREEN,"Quer jogar na loteria? escolha um numero e digite /lotto [NUMERO]!");
  55.         jackpot = JackpotTotal();
  56.         lotto = random(MAX_NO+1);
  57.         lotto2 = random(MAX_NO+1);
  58.         lotto3 = random(MAX_NO+1);
  59.         lotto4 = random(MAX_NO+1);
  60.         lotto5 = random(MAX_NO+1);
  61.         lotto6 = random(MAX_NO+1);
  62.         #if defined STATIC_JACKPOT
  63.             format(string, sizeof(string),"Loterias Servidor BRASIL: O premio é de %d para quem acertar!",STATIC_JACKPOT_WINNINGS);
  64.             SendClientMessage(i,COLOR_GREEN,string);
  65.         #else
  66.             format(string, sizeof(string),"Loterias Servidor BRASIL: O premio de hoje é $%d!",jackpot);
  67.             SendClientMessage(i,COLOR_GREEN,string);
  68.         #endif
  69.  
  70.         if (wonlotto[i] ==1)
  71.         {
  72.  
  73.             #if defined STATIC_JACKPOT
  74.                 GetPlayerName(i, playername, MAX_PLAYER_NAME);
  75.                 format(string, sizeof(string),"Loterias Servidor BRASIL: %s (ID:%d) Ganhou o premio da loteria de $%d!",playername,i,STATIC_JACKPOT_WINNINGS);
  76.                 SendClientMessageToAll(COLOR_ORANGE,string);
  77.                 GivePlayerGrana(i,STATIC_JACKPOT_WINNINGS);
  78.                 GameTextForPlayer(i,"~g~$$$ !!!! Ganhador !!!! $$$",5000,5);
  79.             #else
  80.                 GetPlayerName(i, playername, MAX_PLAYER_NAME);
  81.                 format(string, sizeof(string),"Loterias Servidor BRASIL: %s (ID:%d) Ganhou a loteria!uma aposta de $%d",playername,i,jackpot);
  82.                 SendClientMessageToAll(COLOR_ORANGE,string);
  83.                 GameTextForPlayer(i,"~g~$$$ !!!! Ganhador !!!! $$$",5000,5);
  84.             #endif
  85.  
  86.             GivePlayerGrana(i,jackpot);
  87.             donelotto[i] =0;
  88.             wonlotto[i] =0;
  89.             return 1;
  90.         }
  91.  
  92.         if(wonlotto[i] == 0 && donelotto[i] == 1)
  93.         {
  94.             SendClientMessage(i,COLOR_RED,"Loterias Servidor BRASIL: Você não ganhou! tente outra vez!");
  95.             donelotto[i] =0;
  96.             wonlotto[i] =0;
  97.             return 1;
  98.         }
  99.     }
  100.     return 1;
  101. }
  102.  
  103.  
  104.  
  105. dcmd_lotto(playerid, params[])
  106. {
  107.     new cmd[256];
  108.     new idx;
  109.     cmd = strtok(params, idx);
  110.     if(!strlen(params)) return SendClientMessage(playerid,COLOR_WHITE,"Use: /lotto [numero]");
  111.     if(!LottoEnabled) return SendClientMessage(playerid,RED,"Nenhuma loteria foi aberta!");
  112.     new number = strval(params);
  113.  
  114.     if(number > MAX_NO)
  115.     {
  116.         format(string, sizeof(string),"Você não pode escolher um numero mais alto que %d!",MAX_NO);
  117.         SendClientMessage(playerid,COLOR_RED,string);
  118.         return 1;
  119.     }
  120.  
  121.     if(GetPlayerGrana(playerid) < price )
  122.     {
  123.         format(string, sizeof(string),"Você não tem dinheiro para a aposta você precisa pelo menos $%d",price);
  124.         SendClientMessage(playerid,COLOR_RED,string);
  125.         SendClientMessage(playerid,COLOR_RED,"Comprar um bilhete de lotto!");
  126.         return 1;
  127.     }
  128.  
  129.     if(donelotto[playerid]) return SendClientMessage(playerid,RED,"A loto tem que estar on!");
  130.     if(number == lotto || number == lotto2 || number == lotto3 || number == lotto4 || number == lotto5 || number == lotto6)
  131.     {
  132.         wonlotto[playerid] =1;
  133.         format(string, sizeof(string),"Você escolheu um numero com sucesso %d on.",number);
  134.         SendClientMessage(playerid,GREEN,string);
  135.         donelotto[playerid] =1;
  136.         GivePlayerGrana(playerid,-price);
  137.     }else{
  138.         format(string, sizeof(string),"Você escolheu um numero com sucesso %d on.",number);
  139.         SendClientMessage(playerid,GREEN,string);
  140.         donelotto[playerid] =1;
  141.         GivePlayerGrana(playerid,-price);
  142.     }
  143.     return 1;
  144. }
  145.  
  146. dcmd_lottohelp(playerid, params[])
  147. {
  148.     SendClientMessage(playerid,GREEN,"O lotto é um jogo que você ganha, Dinheiro");
  149.     SendClientMessage(playerid,GREEN,"Jogue e se divirta.");
  150.     SendClientMessage(playerid,GREEN,"Os resultados são divulgados e etc...");
  151.     SendClientMessage(playerid,GREEN,"O premio sempre muda.");
  152.     format(string, sizeof(string),"Para apostar na lotto custa $%d!",price);
  153.     SendClientMessage(playerid,COLOR_RED,string);
  154.     format(string, sizeof(string),"E você deve escolhe um número entre 0 e %d.",MAX_NO);
  155.     SendClientMessage(playerid,COLOR_RED,string);
  156.     #pragma unused params
  157.     return 1;
  158. }
  159.  
  160. dcmd_lottoon(playerid, params[])
  161. {
  162.     if(!IsPlayerAdmin(playerid)) return false;
  163.     if(LottoEnabled) return SendClientMessage(playerid,RED,"Loteria ligada!");
  164.     SendClientMessageToAll(COLOR_ORANGE,"Loteria foi ativada.");
  165.     Lottery = SetTimer("lottery",time*1000, 1);
  166.     SendClientMessage(playerid,GREEN,"Loteria ativa com sucesso.");
  167.     LottoEnabled = 1;
  168.     #pragma unused params
  169.     return 1;
  170. }
  171.  
  172. dcmd_lottooff(playerid, params[])
  173. {
  174.     if(!IsPlayerAdmin(playerid)) return false;
  175.     if(!LottoEnabled) return SendClientMessage(playerid,RED,"Loteria desligada!");
  176.     SendClientMessageToAll(COLOR_ORANGE,"Loteria desabilitada!");
  177.     KillTimer(Lottery);
  178.     SendClientMessage(playerid,GREEN,"Loteria desativada com sucesso.");
  179.     LottoEnabled = 0;
  180.     #pragma unused params
  181.     return 1;
  182. }
  183.  
  184. dcmd_lottoprice(playerid, params[])
  185. {
  186.     if(!IsPlayerAdmin(playerid)) return false;
  187.     new no = strval(params);
  188.     if(!strlen(params)) return SendClientMessage(playerid,COLOR_WHITE,"Use: /lottoprice [preço]");
  189.     if(no == price) return SendClientMessage(playerid,RED,"Os bilhetes ja estão com este preço!");
  190.     price = no;
  191.     format(string,256,"Bilhete agora custa $%d para comprar um bilhete da lotto.",price);
  192.     SendClientMessageToAll(COLOR_ORANGE,string);
  193.     return 1;
  194. }
  195.  
  196. dcmd_lottery(playerid, params[])
  197. {
  198.     if(!IsPlayerAdmin(playerid)) return false;
  199.     lottery();
  200.     SendClientMessage(playerid,GREEN,"Você esta na loteria.");
  201.     #pragma unused params
  202.     return 1;
  203. }
  204. dcmd_winlotto(playerid, params[])
  205. {
  206.     if(!strlen(params)) return SendClientMessage(playerid,COLOR_WHITE,"Use: /winlotto [id]");
  207.     new endid = strval(params);
  208.     if(!IsPlayerConnected(endid)) return SendClientMessage(playerid,RED,"Jogador Invalido!");
  209.     if(!IsPlayerAdmin(playerid)) return false;
  210.     new name[MAX_PLAYER_NAME];
  211.     GetPlayerName(endid, name, MAX_PLAYER_NAME);
  212.     format(string,256,"Você forço %s (ID: %d) a ganhar a proxima loteria!",name,endid);
  213.     SendClientMessage(playerid,COLOR_GREEN,string);
  214.     wonlotto[endid] =1;
  215.     donelotto[endid] =1;
  216.     return 1;
  217. }
  218.  
  219. dcmd_lottotime(playerid, params[])
  220. {
  221.     if(!IsPlayerAdmin(playerid)) return false;
  222.     new newtime = strval(params);
  223.     if(!strlen(params)) return SendClientMessage(playerid,COLOR_WHITE,"Use: /lottotime [segundos]");
  224.     if(newtime == time) return SendClientMessage(playerid,RED,"The Lottery already Draws that Often!");
  225.     time = newtime;
  226.     format(string,256,"The Lotto will now be drawn every %d Seconds!",time);
  227.     SendClientMessageToAll(COLOR_ORANGE,string);
  228.     KillTimer(Lottery);
  229.     Lottery = SetTimer("lottery",time*1000, 1);
  230.     return true;
  231. }
  232.  
  233.  
  234. public OnPlayerConnect(playerid)
  235. {
  236.     donelotto[playerid] =0;
  237.     wonlotto[playerid] =0;
  238.     return 1;
  239. }
  240.  
  241.  
  242. stock JackpotTotal()
  243. {
  244.     new randnum = random(MAX_JACKPOT-MIN_JACKPOT);
  245.     return randnum+MIN_JACKPOT;
  246. }
  247.  
  248. strtok(const str1[], &index)
  249. {
  250.     new length = strlen(str1);
  251.     while ((index < length) && (str1[index] <= ' '))
  252.     {
  253.         index++;
  254.     }
  255.  
  256.     new offset = index;
  257.     new result[20];
  258.     while ((index < length) && (str1[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  259.     {
  260.         result[index - offset] = str1[index];
  261.         index++;
  262.     }
  263.     result[index - offset] = EOS;
  264.     return result;
  265. }
Advertisement
Add Comment
Please, Sign In to add comment