Advertisement
Sugisaki

[AMXX] Loteria

Oct 10th, 2015
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.12 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <engine>
  3. #include <psystem>
  4. #include <cstrike>
  5.  
  6. #define PLUGIN "Nuevo Plugin"
  7. #define VERSION "1.0"
  8. #define AUTHOR "Sugisaki"
  9.  
  10. new numero[33], cantidad[33], start[33], sorted[33][3], money[33]
  11. new Float:wait[33]
  12.  
  13. public plugin_init()
  14. {
  15.     register_plugin(PLUGIN, VERSION, AUTHOR)
  16.     register_clcmd("say /loteria", "pfn_lotery")
  17.     register_clcmd("numero", "pfn_numero")
  18.     register_clcmd("cantidad", "pfn_cantidad")
  19. }
  20. public pfn_lotery(id)
  21. {
  22.    
  23.     if(start[id])
  24.     {
  25.         client_print(id, print_chat, "[LOTERIA] Hay un sorteo en curso debes esperar hasta que termine")
  26.         return PLUGIN_HANDLED
  27.     }
  28.    
  29.     static temp[88], menu
  30.     menu = menu_create("\rLoteria", "mh_loteria")
  31.    
  32.     if(numero[id] > 0 )
  33.     {
  34.         formatex(temp, charsmax(temp), "Apostar a un numero: \r%i", numero[id])
  35.         menu_additem(menu, temp)
  36.     }
  37.    
  38.     else
  39.         menu_additem(menu, "Apostar a un numero")
  40.     if(cantidad[id] > 0)
  41.     {
  42.        
  43.         formatex(temp, charsmax(temp), "Cantidad que desea recibir: \r%i\ypts ^n\wDinero apostado: \r%i\y$", cantidad[id], money[id])
  44.         menu_additem(menu, temp)
  45.  
  46.     }
  47.    
  48.     else
  49.     {
  50.         menu_additem(menu, "Cantidad que desea recibir")
  51.        
  52.     }
  53.     menu_addblank(menu, 3)
  54.    
  55.     menu_additem(menu, "Loteria")
  56.    
  57.     menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
  58.    
  59.     menu_display(id, menu)
  60.     return PLUGIN_HANDLED
  61. }
  62.  
  63. public mh_loteria(id, m, item)
  64. {
  65.     if(item == MENU_EXIT)
  66.     {
  67.         menu_destroy(m)
  68.         return PLUGIN_HANDLED
  69.     }
  70.     switch(item)
  71.     {
  72.         case 0 : client_cmd(id, "messagemode numero")
  73.         case 1 : client_cmd(id, "messagemode cantidad")
  74.         case 2 :
  75.         {
  76.             if(numero[id] <= 0)
  77.             {
  78.                 client_print(id, print_chat, "[LOTERIA] No has apostado a ningun numero")
  79.                 pfn_lotery(id)
  80.                 return PLUGIN_HANDLED
  81.             }
  82.             else if(cantidad[id] <= 0)
  83.             {
  84.                 client_print(id, print_chat, "[LOTERIA] No has apostado billete")
  85.                 pfn_lotery(id)
  86.                 return PLUGIN_HANDLED
  87.             }
  88.             cs_set_user_money(id, cs_get_user_money(id) - money[id])
  89.             start[id] = true
  90.             wait[id] = halflife_time() + 5.0
  91.         }
  92.     }
  93.     menu_destroy(m)
  94.     return PLUGIN_HANDLED
  95. }
  96. public pfn_numero (id)
  97. {
  98.     static out[3]
  99.     read_argv(1, out, 3)
  100.    
  101.     numero[id] = str_to_num(out)
  102.    
  103.     pfn_lotery(id)
  104.     return PLUGIN_HANDLED
  105. }
  106. public pfn_cantidad(id)
  107. {
  108.     static out[3], num
  109.     read_argv(1, out, 3)
  110.    
  111.     num = str_to_num(out)
  112.    
  113.     if(cs_get_user_money(id) < num * 100)
  114.     {
  115.         client_print(id, print_chat, "[LOTERIA] No tienes dinero suficiente para apostar")
  116.         pfn_lotery(id)
  117.         return PLUGIN_HANDLED
  118.     }
  119.    
  120.     cantidad[id] = num
  121.     money[id] = num * 100
  122.    
  123.     pfn_lotery(id)
  124.     return PLUGIN_HANDLED
  125. }
  126. public client_PostThink(id)
  127. {
  128.     if(!start[id]) return PLUGIN_CONTINUE
  129.    
  130.     if(sorted[id][0] <= 0 && sorted[id][1] <= 0 && sorted[id][2] <= 0)
  131.         client_print(id, print_center, "%i%i%i", random_num(0, 9), random_num(0, 9), random_num(0, 9))
  132.     else if(sorted[id][0] > 0 && sorted[id][1] <= 0 && sorted[id][2] <= 0)
  133.         client_print(id, print_center, "%i%i%i", sorted[id][0], random_num(0, 9), random_num(0, 9))
  134.     else if(sorted[id][0] > 0 && sorted[id][1] > 0 && sorted[id][2] <= 0)
  135.         client_print(id, print_center, "%i%i%i", sorted[id][0],  sorted[id][1], random_num(0, 9))
  136.     return PLUGIN_CONTINUE
  137. }
  138. public client_PreThink(id)
  139. {
  140.     if(!start[id]) return PLUGIN_CONTINUE
  141.    
  142.     if(halflife_time() >= wait[id])
  143.     {
  144.         if(sorted[id][0] <= 0 && sorted[id][1] <= 0 && sorted[id][2] <= 0)
  145.             sorted[id][0] = random_num(1, 9)
  146.         else if(sorted[id][0] > 0 && sorted[id][1] <= 0 && sorted[id][2] <= 0)
  147.             sorted[id][1] = random_num(1, 9)
  148.         else if(sorted[id][0] > 0 && sorted[id][1] > 0 && sorted[id][2] <= 0)
  149.         {
  150.             sorted[id][2] = random_num(1, 9)
  151.             client_print(id, print_center, "%i%i%i", sorted[id][0],  sorted[id][1], sorted[id][2])
  152.             start[id] = false
  153.            
  154.             if(numero[id] == str_to_num(sorted[id]))
  155.             {
  156.                 client_print(id, print_chat, "[LOTERIA] Felicidades!!!, Le pegaste a la loteria")
  157.                 set_user_points(id, get_user_points(id) + cantidad[id])
  158.             }
  159.             else
  160.                 client_print(id, print_chat, "[LOTERIA] Sigue intentado")
  161.            
  162.             sorted[id][0] = 0
  163.             sorted[id][1] = 0
  164.             sorted[id][2] = 0
  165.            
  166.             return PLUGIN_CONTINUE
  167.         }
  168.         wait[id] = halflife_time() + 5.0
  169.     }
  170.     return PLUGIN_CONTINUE
  171. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement