Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2019
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.74 KB | None | 0 0
  1. forward lotto_results(type_lotto);
  2. public lotto_results(type_lotto)
  3. {
  4. new rows;
  5. cache_get_row_count(rows);
  6. if(!rows) return 1;
  7. new temp_mysql_id,
  8. nickNameWin[MAX_PLAYER_NAME],
  9. playerid = INVALID_PLAYER_ID,
  10. money_win;
  11. cache_get_value_int(random(rows), "id", temp_mysql_id);
  12.  
  13. foreach(new i: Player)
  14. {
  15. if( p_info[i][lotto_billet_1] != 0 && type_lotto == 1)
  16. p_info[i][lotto_billet_1] = 0;
  17.  
  18. if( p_info[i][lotto_billet_2] != 0 && type_lotto == 2)
  19. p_info[i][lotto_billet_2] = 0;
  20.  
  21. if( p_info[i][lotto_billet_3] != 0 && type_lotto == 3)
  22. p_info[i][lotto_billet_3] = 0;
  23.  
  24. if(p_info[i][ID] == temp_mysql_id)
  25. {
  26. f(nickNameWin, "%s", get_name(i));
  27. playerid = i;
  28. }
  29. }
  30. if(playerid != INVALID_PLAYER_ID)
  31. {
  32. STRING_GLOBAL[0] = EOS;
  33. format(STRING_GLOBAL, sizeof(STRING_GLOBAL), "SELECT `name` FROM `accounts` WHERE `id` = %d LIMIT 1", temp_mysql_id);
  34. new Cache:result = mysql_query(con_bd, STRING_GLOBAL);
  35.  
  36. if(cache_num_rows() == 0)
  37. {
  38. cache_delete(result);
  39. return 1;
  40. }
  41. cache_get_value_name(0, "name", nickNameWin, MAX_PLAYER_NAME);
  42. cache_delete(result);
  43. }
  44.  
  45. switch(type_lotto)
  46. {
  47. case 1: {
  48. money_win = (rows*10000);
  49. mysql_pquery(con_bd, "UPDATE `accounts` SET `lotto_billet_1` = 0 WHERE `lotto_billet_1` > 0", "", "");
  50. }
  51. case 2: {
  52. money_win = (rows*30000);
  53. mysql_pquery(con_bd, "UPDATE `accounts` SET `lotto_billet_2` = 0 WHERE `lotto_billet_2` > 0", "", "");
  54. }
  55. case 3: {
  56. money_win = (rows*50000);
  57. mysql_pquery(con_bd, "UPDATE `accounts` SET `lotto_billet_3` = 0 WHERE `lotto_billet_3` > 0", "", "");
  58. }
  59. }
  60.  
  61. if(playerid != INVALID_PLAYER_ID){
  62. STRING_GLOBAL[0] = EOS;
  63. f(STRING_GLOBAL, ">> Победителем лотереи "A"№%d "I"становиться: "A"%s [Сумма выиграша: %d$]", type_lotto, get_name(playerid), money_win);
  64. set_money(playerid, (money_win/100)*90, "победа в лотерее");
  65. }
  66. else
  67. {
  68. STRING_GLOBAL[0] = EOS;
  69. f(STRING_GLOBAL, "UPDATE `accounts` SET `money` = `money` + %d WHERE `id` = %d", money_win, temp_mysql_id);
  70. mysql_pquery(con_bd, STRING_GLOBAL, "", "");
  71. STRING_GLOBAL[0] = EOS;
  72. f(STRING_GLOBAL, ">> Победителем лотереи "A"№%d "I"становиться: "A"%s [Сумма выиграша: %d$]", type_lotto, nickNameWin, money_win);
  73. }
  74. SendClientMessageToAll(info, STRING_GLOBAL);
  75. return 1;
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement