orayon

Basic Shop v1.0

May 20th, 2020 (edited)
1,946
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.99 KB | None | 0 0
  1. /* Plugin generated by AMXX-Studio */
  2.  
  3. #include <amxmodx>
  4. #include <fakemeta_util>
  5.  
  6. native get_user_cash(id)
  7. native set_user_cash(id,amount)
  8.    
  9. enum _: ItemData
  10. {
  11.     g_iDisplay[30],
  12.     g_iAmount,
  13.     g_item[40]
  14. }
  15.  
  16. new MenuPrefix[] = "\w[\rPrefix\w]", szChatPrefix[] = "^3[^1Prefix^3]^1";
  17.  
  18. new const GrenadesInfo[][ItemData] =
  19. {
  20.     {"Explosive Grenade", 1000, "weapon_hegrenade"},
  21.     {"Flashbang", 2000, "weapon_flashbang"},
  22.     {"Smoke Grenade", 3000, "weapon_smokegrenade"}
  23. }
  24.  
  25. new const WeaponInfo[][ItemData] =
  26. {
  27.     {"M4A1", 1000, "weapon_m4a1"},
  28.     {"AK-47", 2000, "weapon_ak47"},
  29.     {"Glock", 3000, "weapon_glock"}
  30. }
  31.  
  32. new const HealthInfo[][ItemData] =
  33. {
  34.     {"10 Health", 1000, "10"},
  35.     {"20 Health", 2000, "20"},
  36.     {"30 Health", 3000, "30"}
  37. }
  38.  
  39. new const ArmorInfo[][ItemData] =
  40. {
  41.     {"10 Armor", 1000, "10"},
  42.     {"20 Armor", 2000, "20"},
  43.     {"30 Armor", 3000, "30"}
  44. }
  45.  
  46.  
  47.  
  48. public plugin_init()
  49. {
  50.     register_plugin("Basic Shop", "1.0", "orayon")
  51.     register_clcmd("say /shop", "cmdshopmenu")
  52. }
  53.  
  54. public cmdshopmenu(id)
  55. {
  56.     new String[50]
  57.     formatex(String, charsmax(String), "%s \wShop Menu v1.0", MenuPrefix)
  58.     new menu = menu_create(String, "shopmenu_handler")
  59.    
  60.     menu_additem(menu, "Grenades menu")
  61.    
  62.     menu_additem(menu, "Weapon menu")
  63.    
  64.     menu_additem(menu, "Health menu")
  65.    
  66.     menu_additem(menu, "Armor menu")
  67.    
  68.     menu_setprop(menu, MPROP_EXIT, MEXIT_ALL );
  69.     menu_setprop(menu, MPROP_EXITNAME, "\rExit" )
  70.    
  71.     menu_display(id, menu)
  72. }
  73.  
  74. public shopmenu_handler(id, menu, item)
  75. {
  76.     if (item == MENU_EXIT)
  77.     {
  78.         menu_destroy(menu)
  79.         return;
  80.     }
  81.    
  82.     switch (item)
  83.     {
  84.         case 0: GrenadesMenu(id)
  85.        
  86.         case 1: WeaponMenu(id)
  87.        
  88.         case 2: HealthMenu(id)
  89.        
  90.         case 3: ArmorMenu(id)
  91.     }
  92. }
  93.  
  94. public GrenadesMenu(id)
  95. {
  96.     new Format[70]
  97.     formatex(Format, charsmax(Format), "%s Grenades Menu", MenuPrefix)
  98.     new menu = menu_create(Format, "grenade_handler")
  99.    
  100.     for (new i; i < sizeof(GrenadesInfo); i++)
  101.     {
  102.         formatex(Format, charsmax(Format), "%s - %i Cash", GrenadesInfo[i][g_iDisplay], GrenadesInfo[i][g_iAmount])
  103.         menu_additem(menu, Format)
  104.     }
  105.    
  106.     menu_setprop(menu, MPROP_EXIT, MEXIT_ALL );
  107.     menu_setprop(menu, MPROP_EXITNAME, "\wBack" )
  108.    
  109.     menu_display(id, menu)
  110. }
  111.  
  112. public grenade_handler(id, menu, item)
  113. {
  114.     if (item == MENU_EXIT)
  115.     {
  116.         cmdshopmenu(id)
  117.     }
  118.  
  119.     if( get_user_cash( id ) < GrenadesInfo[ item ][ g_iAmount ] )
  120.         return ColorPrint( id,"You are missing ^3%i ^1Cash To purchase the ^3%s^1.", GrenadesInfo[ item ][ g_iAmount ] - get_user_cash( id ), GrenadesInfo[ item ][ g_iDisplay ] );
  121.    
  122.     new szName[60];
  123.     get_user_name(id, szName, charsmax(szName))
  124.    
  125.     ColorPrint(0, "%s have Bought %s", szName, GrenadesInfo[ item ][ g_iDisplay ]) 
  126.     ColorPrint(id, "You have Bought %s",GrenadesInfo[ item ][ g_iDisplay ])
  127.     fm_give_item(id,GrenadesInfo[ item ][g_item])
  128.     set_user_cash(id, get_user_cash(id) - GrenadesInfo[ item ][g_iAmount]) 
  129.     return 1;
  130. }
  131.  
  132. public WeaponMenu(id)
  133. {
  134.     new Format[70]
  135.     formatex(Format, charsmax(Format), "%s Weapons Menu", MenuPrefix)
  136.     new menu = menu_create(Format, "weapon_handler")
  137.    
  138.     for (new i; i < sizeof(WeaponInfo); i++)
  139.     {
  140.         formatex(Format, charsmax(Format), "%s - %i Cash", WeaponInfo[i][g_iDisplay], WeaponInfo[i][g_iAmount])
  141.         menu_additem(menu, Format)
  142.     }
  143.    
  144.     menu_setprop(menu, MPROP_EXIT, MEXIT_ALL );
  145.     menu_setprop(menu, MPROP_EXITNAME, "\wBack" )
  146.    
  147.     menu_display(id, menu)
  148. }
  149.  
  150. public weapon_handler(id, menu, item)
  151. {
  152.     if (item == MENU_EXIT)
  153.     {
  154.         cmdshopmenu(id)
  155.     }
  156.    
  157.     if( get_user_cash( id ) < WeaponInfo[ item ][ g_iAmount ] )
  158.         return ColorPrint( id,"You are missing ^3%i ^1Cash To purchase the ^3%s^1.", WeaponInfo[ item ][ g_iAmount ] - get_user_cash( id ), WeaponInfo[ item ][ g_iDisplay ] );
  159.    
  160.     new szName[60];
  161.     get_user_name(id, szName, charsmax(szName))
  162.    
  163.     ColorPrint(id, "You have Bought %s",WeaponInfo[ item ][ g_iDisplay ])  
  164.     ColorPrint(0, "%s have Bought %s", szName, WeaponInfo[ item ][ g_iDisplay ])   
  165.     fm_give_item(id,WeaponInfo[ item ][g_item])
  166.     set_user_cash(id, get_user_cash(id) - WeaponInfo[ item ][g_iAmount])       
  167.     return 1;
  168. }
  169.  
  170.  
  171. public HealthMenu(id)
  172. {
  173.     new Format[70]
  174.     formatex(Format, charsmax(Format), "%s Health Menu", MenuPrefix)
  175.     new menu = menu_create(Format, "health_handler")
  176.    
  177.     for (new i; i < sizeof(HealthInfo); i++)
  178.     {
  179.         formatex(Format, charsmax(Format), "%s - %i Cash", HealthInfo[i][g_iDisplay], HealthInfo[i][g_iAmount])
  180.         menu_additem(menu, Format)
  181.     }
  182.    
  183.     menu_setprop(menu, MPROP_EXIT, MEXIT_ALL );
  184.     menu_setprop(menu, MPROP_EXITNAME, "\wBack" )
  185.    
  186.     menu_display(id, menu)
  187. }
  188.  
  189. public health_handler(id, menu, item)
  190. {
  191.     if (item == MENU_EXIT)
  192.     {
  193.         cmdshopmenu(id)
  194.     }
  195.    
  196.     if( get_user_cash( id ) < HealthInfo[ item ][ g_iAmount ] )
  197.         return ColorPrint( id,"You are missing ^3%i ^1Cash To purchase the ^3%s^1.", HealthInfo[ item ][ g_iAmount ] - get_user_cash( id ), HealthInfo[ item ][ g_iDisplay ] );
  198.    
  199.     new szName[60];
  200.     get_user_name(id, szName, charsmax(szName))
  201.    
  202.     ColorPrint(id, "You have Bought %s",HealthInfo[ item ][ g_iDisplay ])  
  203.     ColorPrint(0, "%s have Bought %s", szName, HealthInfo[ item ][ g_iDisplay ])   
  204.     fm_set_user_health( id, get_user_health( id ) + HealthInfo[ item ][g_item]);
  205.     set_user_cash(id, get_user_cash(id) - HealthInfo[ item ][g_iAmount])       
  206.     return 1;
  207. }
  208.  
  209.  
  210. public ArmorMenu(id)
  211. {
  212.     new Format[70]
  213.     formatex(Format, charsmax(Format), "%s Armor Menu", MenuPrefix)
  214.     new menu = menu_create(Format, "armor_handler")
  215.    
  216.     for (new i; i < sizeof(ArmorInfo); i++)
  217.     {
  218.         formatex(Format, charsmax(Format), "%s - %i Cash", ArmorInfo[i][g_iDisplay], ArmorInfo[i][g_iAmount])
  219.         menu_additem(menu, Format)
  220.     }
  221.    
  222.     menu_setprop(menu, MPROP_EXIT, MEXIT_ALL );
  223.     menu_setprop(menu, MPROP_EXITNAME, "\wBack" )
  224.     menu_display(id, menu)
  225. }
  226.  
  227. public armor_handler(id, menu, item)
  228. {
  229.     if (item == MENU_EXIT)
  230.     {
  231.         cmdshopmenu(id)
  232.     }
  233.    
  234.     if( get_user_cash( id ) < ArmorInfo[ item ][ g_iAmount ] )
  235.         return ColorPrint( id,"You are missing ^3%i ^1Cash To purchase the ^3%s^1.", ArmorInfo[ item ][ g_iAmount ] - get_user_cash( id ), ArmorInfo[ item ][ g_iDisplay ] );
  236.  
  237.     new szName[60];
  238.     get_user_name(id, szName, charsmax(szName))
  239.    
  240.     ColorPrint(0, "%s have Bought %s", szName, ArmorInfo[ item ][ g_iDisplay ])
  241.     ColorPrint(id, "You have Bought %s",ArmorInfo[ item ][ g_iDisplay ])   
  242.     fm_set_user_armor( id, get_user_armor( id ) + ArmorInfo[ item ][g_item]);
  243.     set_user_cash(id, get_user_cash(id) - ArmorInfo[ item ][g_iAmount])    
  244.     return 1;
  245. }
  246.  
  247.  
  248. //STOCKS
  249.  
  250.  
  251.  
  252. stock ColorPrint( const index, const string[], any:... )
  253. {
  254.     new szMsg[ 191 ], Players[ 32 ], PNum = 1;
  255.    
  256.     static iLen; iLen = formatex( szMsg, charsmax( szMsg ), "%s^1 ", szChatPrefix );
  257.    
  258.     vformat( szMsg[ iLen ], charsmax( szMsg ) - iLen, string, 3 );
  259.    
  260.     if ( index )
  261.         Players[ 0 ] = index;
  262.    
  263.     else
  264.         get_players( Players, PNum, "ch" );
  265.    
  266.     for ( new i; i < PNum; i++ )
  267.     {
  268.         if( is_user_connected( Players[ i ] ) )
  269.         {
  270.             message_begin( MSG_ONE_UNRELIABLE, get_user_msgid( "SayText" ), _, Players[ i ] );
  271.            
  272.             write_byte( Players[ i ] );
  273.            
  274.             write_string( szMsg );
  275.            
  276.             message_end( );
  277.         }
  278.     }
  279.    
  280.     return 1;
  281. }
Add Comment
Please, Sign In to add comment