Advertisement
Guest User

Jogo do bicho - Vaca_Marinha

a guest
Oct 6th, 2022
448
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.50 KB | None | 0 0
  1. #include <a_samp>
  2. #include <ZCMD>
  3.  
  4. #define TempoJogoDoBicho 60000
  5. #define randomEx(%0,%1) (random(%1 - %0 + 1) + %0)
  6.  
  7. #define DialogJogoDoBichoMenu 600
  8. #define DialogJogoDoBichoTabela 601
  9. #define DialogJogoDoBichoTipoAposta 602
  10. #define DialogJogoDoBichoApostar 603
  11. #define DialogJogoDoBichoApostarValor 604
  12.  
  13. enum eBichos {
  14. Bicho[64],
  15. Dezenas[4]
  16. }
  17.  
  18. new TabelaBichos[][eBichos] = {
  19. {"Vazio", {0, 0, 0, 0}},
  20. {"AVESTRUZ", {1, 2, 3, 4}},
  21. {"ÁGUIA", {5, 6, 7, 8}},
  22. {"BURRO", {09, 10, 11, 12}},
  23. {"BORBOLETA", {13, 14, 15, 16}},
  24. {"CACHORRO", {17, 18, 19, 20}},
  25. {"CABRA", {21, 22, 23, 24}},
  26. {"CARNEIRO", {25, 26, 27, 28}},
  27. {"CAMELO", {29, 30, 31, 32}},
  28. {"COBRA", {33, 34, 35, 36}},
  29. {"COELHO", {37, 38, 39, 40}},
  30. {"CAVALO", {41, 42, 43, 44}},
  31. {"ELEFANTE", {45, 46, 47, 48}},
  32. {"GALO", {49, 50, 51, 52}},
  33. {"GATO", {53, 54, 55, 56}},
  34. {"JACARÉ", {57, 58, 59, 60}},
  35. {"LEÃO", {61, 62, 63, 64}},
  36. {"MACACO", {65, 66, 67, 68}},
  37. {"PORCO", {69, 70, 71, 72}},
  38. {"PAVÃO", {73, 74, 75, 76}},
  39. {"PERU", {77, 78, 79, 80}},
  40. {"TOURO", {81, 82, 83, 84}},
  41. {"TIGRE", {85, 86, 87, 88}},
  42. {"URSO", {89, 90, 91, 92}},
  43. {"VEADO", {93, 94, 95, 96}},
  44. {"VACA", {97, 98, 99, 100}}
  45. };
  46.  
  47. enum eApostador {
  48. Animal,
  49. TipoAposta,
  50. Aposta,
  51. bool:Apostando
  52. }
  53.  
  54. new Apostadores[MAX_PLAYERS][eApostador];
  55. new UltimoResultado;
  56. new bool:PodeApostarBicho = true;
  57.  
  58. public OnFilterScriptInit()
  59. {
  60. print("----------------------------------");
  61. print("----------------------------------");
  62. print("----------Jogo do Bicho-----------");
  63. print("---------Por Vaca_Marinha---------");
  64. print("----------------------------------");
  65. print("----------------------------------");
  66. SetTimerEx("ResultadoBicho", TempoJogoDoBicho, true, "");
  67. SetTimerEx("FecharBicho", (TempoJogoDoBicho-(TempoJogoDoBicho / 4)), false, "");
  68. return 1;
  69. }
  70.  
  71. CMD:apostar(playerid, const params[]) {
  72. MostrarMenuTipoAposta(playerid);
  73. return 1;
  74. }
  75. CMD:bichos(playerid, const params[]) {
  76. return MostrarMenuTabela(playerid);
  77. }
  78.  
  79. CMD:jogodobicho(playerid, const params[]) {
  80. return MostrarMenuBicho(playerid);
  81. }
  82.  
  83. CMD:testedinheiro(playerid) {
  84. GivePlayerMoney(playerid, 50000);
  85. return 1;
  86. }
  87.  
  88. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
  89. switch(dialogid) {
  90. case DialogJogoDoBichoMenu: {
  91. if(!response) return 1;
  92. switch(listitem) {
  93. case 0: cmd_apostar(playerid, "");
  94. case 1: cmd_bichos(playerid, "");
  95. case 2: SendClientMessage(playerid, -1, "Em breve...");
  96. }
  97. }
  98. case DialogJogoDoBichoTabela: {
  99. if(!response) return MostrarMenuBicho(playerid);
  100. }
  101. case DialogJogoDoBichoTipoAposta: {
  102. if(!response) return MostrarMenuBicho(playerid);
  103. new lista[2048];
  104. format(lista, sizeof(lista), "Grupo\tAnimal\tDezenas\n");
  105. for(new i = 1; i < sizeof(TabelaBichos);i++) {
  106. format(lista, sizeof(lista), "%s{FCB876}%i\t{a9c4e4}%s\t%i-%i-%i-%i\n", lista, i, TabelaBichos[i][Bicho], TabelaBichos[i][Dezenas][0], TabelaBichos[i][Dezenas][1], TabelaBichos[i][Dezenas][2], TabelaBichos[i][Dezenas][3]);
  107. }
  108. return ShowPlayerDialog(playerid, DialogJogoDoBichoApostar, DIALOG_STYLE_TABLIST_HEADERS, "{ffff00}#{ffffff}Bicho | Selecione um animal", lista, "OK", "Voltar");
  109. }
  110. case DialogJogoDoBichoApostar: {
  111. if(!response) return MostrarMenuTipoAposta(playerid);
  112. new animal = (listitem+1), string[1024];
  113. SetPVarInt(playerid, "apostando_bicho", animal);
  114. format(string, sizeof(string), "Você está apostando em:\n\n\
  115. Animal: %s\n\
  116. Grupo: %d\n\
  117. Dezenas: %i-%i-%i-%i\n\nDigite o valor que deseja apostar:\
  118. ", TabelaBichos[animal][Bicho], animal, TabelaBichos[animal][Dezenas][0], TabelaBichos[animal][Dezenas][1], TabelaBichos[animal][Dezenas][2], TabelaBichos[animal][Dezenas][3]);
  119. ShowPlayerDialog(playerid, DialogJogoDoBichoApostarValor, DIALOG_STYLE_INPUT, "{ffff00}#{ffffff}Bicho | Valor da aposta", string, "OK", "Voltar");
  120. return 1;
  121. }
  122. case DialogJogoDoBichoApostarValor: {
  123. if(!response) {
  124. new lista[2048];
  125. format(lista, sizeof(lista), "Grupo\tAnimal\tDezenas\n");
  126. for(new i = 1; i < sizeof(TabelaBichos);i++) {
  127. format(lista, sizeof(lista), "%s{FCB876}%i\t{a9c4e4}%s\t%i-%i-%i-%i\n", lista, i, TabelaBichos[i][Bicho], TabelaBichos[i][Dezenas][0], TabelaBichos[i][Dezenas][1], TabelaBichos[i][Dezenas][2], TabelaBichos[i][Dezenas][3]);
  128. }
  129. return ShowPlayerDialog(playerid, DialogJogoDoBichoApostar, DIALOG_STYLE_TABLIST_HEADERS, "{ffff00}#{ffffff}Bicho | Selecione um animal", lista, "OK", "Voltar");
  130. } else {
  131. new valor = strval(inputtext), animal = GetPVarInt(playerid, "apostando_bicho"), string[128];
  132. if(valor <= 0 || valor < 100) {
  133. if((GetPlayerMoney(playerid)-valor) > 0) {
  134. SendClientMessage(playerid, -1, "{FCB876}[Jogo Do Bicho] {a9c4e4}Você precisa apostar no mínimo R$100.");
  135. } else {
  136. SendClientMessage(playerid, -1, "{FCB876}[Jogo Do Bicho] {a9c4e4}Você não tem dinheiro suficiente para essa aposta, coloque um valor menor.");
  137. }
  138. format(string, sizeof(string), "Você está apostando em:\n\n\
  139. Animal: %s\n\
  140. Grupo: %d\n\
  141. Dezenas: %i-%i-%i-%i\n\nDigite o valor que deseja apostar:\
  142. ", TabelaBichos[animal][Bicho], animal, TabelaBichos[animal][Dezenas][0], TabelaBichos[animal][Dezenas][1], TabelaBichos[animal][Dezenas][2], TabelaBichos[animal][Dezenas][3]);
  143. return ShowPlayerDialog(playerid, DialogJogoDoBichoApostarValor, DIALOG_STYLE_INPUT, "{ffff00}#{ffffff}Bicho | Valor da aposta", string, "OK", "Voltar");
  144. }
  145. GivePlayerMoney(playerid, -valor);
  146. Apostadores[playerid][Animal] = animal;
  147. Apostadores[playerid][TipoAposta] = 0;
  148. Apostadores[playerid][Aposta] = valor;
  149. Apostadores[playerid][Apostando] = true;
  150. format(string, sizeof(string), "{FCB876}[Jogo Do Bicho] {a9c4e4}Você apostou R$%i no animal %s(Grupo %i)", valor, TabelaBichos[animal][Bicho], animal);
  151. return SendClientMessage(playerid, -1, string);
  152. }
  153. }
  154. }
  155. return 1;
  156. }
  157. forward ResultadoBicho();
  158. public ResultadoBicho() {
  159. new resultado_mil = randomEx(10,99),
  160. resultado_dez = randomEx(10,99),
  161. animal = PegarBicho(resultado_dez),
  162. ganhadores,
  163. string[256],
  164. Msg[256];
  165. format(Msg, sizeof(Msg), "{FCB876}[Jogo Do Bicho] {a9c4e4}O número sorteado foi: {ffffff}%i%i{a9c4e4}!", resultado_mil, resultado_dez);
  166. SendClientMessageToAll(0xffffffff, Msg);
  167. format(Msg, sizeof(Msg), "{FCB876}[Jogo Do Bicho] {a9c4e4}Animal: {ffffff}%s{a9c4e4}(Grupo {ffffff}%i{a9c4e4}) - Dezena {ffffff}%i{a9c4e4}!", TabelaBichos[animal][Bicho], animal, resultado_dez);
  168. SendClientMessageToAll(0xffffffff, Msg);
  169. printf("Número: %i%i | Animal: %s (dezena %i)", resultado_mil, resultado_dez, TabelaBichos[animal][Bicho], resultado_dez);
  170. for(new i;i < sizeof(Apostadores);i++) {
  171. if(Apostadores[i][Animal] == animal) {
  172. ganhadores++;
  173. GivePlayerMoney(i, (Apostadores[i][Aposta] * 14));
  174. format(string, sizeof(string), "{FCB876}[Jogo Do Bicho] Parabens! Você apostou no animal %s e ganhou 14x sua aposta de R$%i!", TabelaBichos[animal][Bicho], Apostadores[i][Aposta]);
  175. SendClientMessage(i, -1, string);
  176. }
  177. Apostadores[i][Animal] = 0;
  178. Apostadores[i][TipoAposta] = 0;
  179. Apostadores[i][Aposta] = 0;
  180. Apostadores[i][Apostando] = false;
  181. if(i == sizeof(Apostadores)-1) {
  182. format(Msg, sizeof(Msg), "{FCB876}[Jogo Do Bicho] {a9c4e4}Tivemos um total de %i vencedores!", ganhadores);
  183. SendClientMessageToAll(0xffffffff, Msg);
  184. break;
  185. }
  186. }
  187. UltimoResultado = gettime();
  188. PodeApostarBicho = true;
  189. SetTimerEx("FecharBicho", (TempoJogoDoBicho-(TempoJogoDoBicho / 4)), false, "");
  190. return 1;
  191. }
  192.  
  193. forward FecharBicho();
  194. public FecharBicho() {
  195. PodeApostarBicho = false;
  196. new Msg[512];
  197. format(Msg, sizeof(Msg), "{FCB876}[Jogo Do Bicho] {a9c4e4}O resultado irá sair daqui {ffffff}%i{a9c4e4} segundos! As apostas estão fechadas.", ((TempoJogoDoBicho / 4) / 1000));
  198. SendClientMessageToAll(0xffffffff, Msg);
  199. return 1;
  200. }
  201.  
  202. MostrarMenuBicho(playerid) {
  203. new lista[1024];
  204. format(lista, sizeof(lista), "{a9c4e4}Apostar\r\n{a9c4e4}Lista de bichos\r\n{FCB876}Como jogar?");
  205. return ShowPlayerDialog(playerid, DialogJogoDoBichoMenu, DIALOG_STYLE_LIST, "{FCB876}#{ffffff}Bicho | Menu", lista, "OK", "");
  206. }
  207.  
  208. MostrarMenuTipoAposta(playerid) {
  209. if(!PodeApostarBicho) return SendClientMessage(playerid, -1, "{FCB876}[Jogo Do Bicho] {a9c4e4}Falta pouco para sair o resultado do jogo do bicho, então as apostas estão fechadas.");
  210. if(Apostadores[playerid][Apostando]) return SendClientMessage(playerid, -1, "{FCB876}[Jogo Do Bicho] {a9c4e4}Você já fez uma aposta, aguarde o resultado.");
  211. new lista[1024];
  212. format(lista, sizeof(lista), "{a9c4e4}Aposta de Grupos\r\n");
  213. return ShowPlayerDialog(playerid, DialogJogoDoBichoTipoAposta, DIALOG_STYLE_LIST, "{FCB876}#{ffffff}Bicho | Apostar", lista, "OK", "Voltar");
  214. }
  215.  
  216. MostrarMenuTabela(playerid) {
  217. new lista[2048];
  218. format(lista, sizeof(lista), "Grupo\tAnimal\tDezenas\n");
  219. for(new i = 1; i < sizeof(TabelaBichos);i++) {
  220. format(lista, sizeof(lista), "%s{FCB876}%i\t{a9c4e4}%s\t%i-%i-%i-%i\n", lista, i, TabelaBichos[i][Bicho], TabelaBichos[i][Dezenas][0], TabelaBichos[i][Dezenas][1], TabelaBichos[i][Dezenas][2], TabelaBichos[i][Dezenas][3]);
  221. }
  222. return ShowPlayerDialog(playerid, DialogJogoDoBichoTabela, DIALOG_STYLE_TABLIST_HEADERS, "{ffff00}#{ffffff}Bicho | Lista de bichos", lista, "OK", "Voltar");
  223. }
  224.  
  225. PegarBicho(numero) {
  226. new animal;
  227. for(new i = 1; i < sizeof(TabelaBichos);i++) {
  228. for(new b; b < 4;b++) {
  229. if(TabelaBichos[i][Dezenas][b] == numero) {
  230. animal = i;
  231. break;
  232. }
  233. }
  234. }
  235. return animal;
  236. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement