Rejack

JailBreak Shop (v1.2)

Dec 19th, 2012 (edited)
2,748
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 24.49 KB | None | 0 0
  1. #include < amxmodx >
  2. #include < amxmisc >
  3. #include < cstrike >
  4. #include < fun >
  5. #include < hamsandwich >
  6. #include < fvault >
  7.  
  8. #define gPlugin "JailBreak Shop"
  9. #define gVersion "1.2"
  10. #define gAuthor "Rejack"
  11.  
  12. new
  13.     gCash[ 33 ],
  14.     gConnected[ 33 ],
  15.     gTitle[ 128 ],
  16.     p_Saveway,
  17.    
  18.     p_Prefix,
  19.     p_ShopEnabled,
  20.    
  21.     p_Explosive,
  22.     p_Flashbang,
  23.     p_Smokegrenade,
  24.    
  25.     p_Health,
  26.     p_Armor,
  27.    
  28.     p_Godmode,
  29.     p_Gravity,
  30.     p_Stealth,
  31.    
  32.     p_SwitchTeams,
  33.     p_RoundFreeday,
  34.    
  35.     kill_cash,
  36.     kill_hs_cash,
  37.    
  38.     p_TaxRate;
  39.  
  40. new g_GrenadesNames[ ][ ] = { "Explosive", "Flashbang", "Smoke" }
  41. new g_GrenadesClass[ ][ ] = { "weapon_hegrenade", "weapon_flashbang", "weapon_smokegrenade" }
  42. new g_GrenadesCSW[ ] = { CSW_HEGRENADE, CSW_FLASHBANG, CSW_SMOKEGRENADE }
  43.  
  44. new g_PowersNames[ ][ ] = { "Godmode 8", "Gravity 10", "Stealth 10" }
  45. new g_MiscStuffNames[ ][ ] = { "Switch Teams", "Freeday - One Round" }
  46.  
  47.  
  48. new
  49.     bool:d_Godmode[ 33 ] = false,
  50.     bool:d_Gravity[ 33 ] = false,
  51.     bool:d_Stealth[ 33 ] = false;
  52.  
  53. public plugin_init( )
  54. {
  55.     register_plugin(gPlugin, gVersion, gAuthor);
  56.    
  57.     register_clcmd( "say /shop", "cmdShop" );
  58.     register_clcmd( "say", "cmdSay" );
  59.    
  60.     register_clcmd( "shop_add_cash", "cmdAddCash" );
  61.     register_clcmd( "shop_remove_cash", "cmdRemoveCash" );
  62.    
  63.     register_clcmd( "_health_", "subHealth" );
  64.     register_clcmd( "_armor_", "subArmor" );
  65.    
  66.     p_ShopEnabled   = register_cvar( "shop_enabled", "1" );
  67.     p_Prefix    = register_cvar( "shop_prefix", "JailBreak" );
  68.     p_Saveway   = register_cvar( "shop_save", "2" );
  69.    
  70.     p_Explosive = register_cvar( "shop_cost_explosive", "2500" );
  71.     p_Flashbang = register_cvar( "shop_cost_flash", "1000" );
  72.     p_Smokegrenade  = register_cvar( "shop_cost_smoke", "1500" );
  73.    
  74.     p_Health    = register_cvar( "shop_cost_health", "25" );
  75.     p_Armor     = register_cvar( "shop_cost_armor", "12" );
  76.    
  77.     p_Godmode   = register_cvar( "shop_cost_godmode", "4500" );
  78.     p_Gravity   = register_cvar( "shop_cost_gravity", "2500" );
  79.     p_Stealth   = register_cvar( "shop_cost_stealth", "3500" );
  80.    
  81.     p_SwitchTeams   = register_cvar( "shop_cost_switch", "25000" );
  82.     p_RoundFreeday  = register_cvar( "shop_cost_freeday", "8500" );
  83.    
  84.     kill_cash   = register_cvar( "kill_cash", "100" );
  85.     kill_hs_cash    = register_cvar( "kill_hs_cash", "150" );
  86.    
  87.     p_TaxRate   = register_cvar( "shop_tax_rate", "7" );
  88.    
  89.     RegisterHam( Ham_Spawn, "player", "HamSpawn", 1 );
  90.     register_event( "DeathMsg", "Event_DeathMsg", "a" );
  91. }
  92.  
  93. public plugin_natives()
  94. {
  95.     register_library("jail_cash");
  96.     register_native("get_user_cash", "_get_cash");
  97.     register_native("set_user_cash", "_set_cash");
  98. }
  99.  
  100. public _get_cash( plugin, params )
  101. {
  102.     return gCash[ get_param( 1 ) ];
  103. }
  104.  
  105. public _set_cash( plugin, params )
  106. {
  107.     new id = get_param( 1 );
  108.     gCash[ id ] = max( 0, get_param( 2 ) );
  109.     cmdSave( id );
  110.     return gCash[ id ];
  111. }
  112. public cmdAddCash( id )
  113. {
  114.     if ( !(get_user_flags( id ) & ADMIN_IMMUNITY ) )
  115.         return PLUGIN_HANDLED;
  116.        
  117.     new szTarget[ 32 ], szAmount[ 21 ];
  118.     read_argv( 1, szTarget, 31 );
  119.     read_argv( 2, szAmount, 20 );
  120.    
  121.     new gPlayer = cmd_target( id, szTarget, 8 );
  122.    
  123.     if ( !gPlayer )
  124.     {
  125.         return PLUGIN_HANDLED;
  126.     }
  127.    
  128.     new szName[ 32 ], szPName[ 32 ];
  129.     get_user_name( id, szName, 31 );
  130.     get_user_name( gPlayer, szPName, 31 );
  131.    
  132.     new CashNum = str_to_num( szAmount );
  133.     gCash[ gPlayer ] += CashNum;
  134.    
  135.     switch ( get_cvar_num( "amx_show_activity" ) )
  136.     {
  137.         case 1:
  138.         {
  139.             ColorChat( id, "^3ADMIN:^1 added^4 %i^1 cash to the player:^4 %s^1. (^4 %d Cash ^1)", CashNum, szPName, gCash[ gPlayer ] );
  140.         }
  141.         case 2:
  142.         {
  143.             ColorChat( id, "^3ADMIN:^4 %s^1 added^4 %i^1 cash to the player:^4 %s^1. (^4 %d Cash ^1)", szName, CashNum, szPName, gCash[ gPlayer ] );
  144.         }
  145.     }
  146.     ColorChat( gPlayer, "You were added^4 %i^1 cash by the^3 ADMIN:^4 %s", CashNum, szName );
  147.     cmdSave( id );
  148.     return PLUGIN_HANDLED;
  149. }
  150. public cmdRemoveCash( id )
  151. {
  152.     if ( !(get_user_flags( id ) & ADMIN_IMMUNITY ) )
  153.         return PLUGIN_HANDLED;
  154.        
  155.     new szTarget[ 32 ], szAmount[ 21 ];
  156.     read_argv( 1, szTarget, 31 );
  157.     read_argv( 2, szAmount, 20 );
  158.    
  159.     new gPlayer = cmd_target( id, szTarget, 8 );
  160.    
  161.     if ( !gPlayer )
  162.     {
  163.         return PLUGIN_HANDLED;
  164.     }
  165.  
  166.     new szName[ 32 ], szPName[ 32 ];
  167.     get_user_name( id, szName, 31 );
  168.     get_user_name( gPlayer, szPName, 31 );
  169.    
  170.     new CashNum = str_to_num( szAmount );
  171.     gCash[ gPlayer ] -= CashNum;
  172.    
  173.     switch ( get_cvar_num( "amx_show_activity" ) )
  174.     {
  175.         case 1:
  176.         {
  177.             ColorChat( id, "^3ADMIN:^1 removed^4 %i^1 cash from the player:^4 %s^1. (^4 %d Cash ^1)", CashNum, szPName, gCash[ gPlayer ] );
  178.         }
  179.         case 2:
  180.         {
  181.             ColorChat( id, "^3ADMIN:^4 %s^1 removed^4 %i^1 cash from the player:^4 %s^1. (^4 %d Cash ^1)", szName, CashNum, szPName, gCash[ gPlayer ] );
  182.         }
  183.     }
  184.     ColorChat( gPlayer, "You were removed^4 %i^1 cash by the^3 ADMIN:^4 %s", CashNum, szName );
  185.     cmdSave( id );
  186.     return PLUGIN_HANDLED;
  187. }
  188.  
  189. public cmdSay( id )
  190. {
  191.     if ( !(get_pcvar_num( p_ShopEnabled ) ) )
  192.         return PLUGIN_HANDLED;
  193.        
  194.     new szMsg[ 192 ], Arg[ 38 ], Arg2[ 38 ], Arg3[ 32 ];
  195.     read_argv( 1, szMsg, charsmax( szMsg ) );
  196.     parse( szMsg, Arg, charsmax( Arg ), Arg2, charsmax( Arg2 ), Arg3, charsmax( Arg3 ) );
  197.     if( equal( Arg, "/cash" ) )
  198.     {
  199.         new gPlayer;
  200.         gPlayer = cmd_target( id, Arg2, 8 );
  201.        
  202.         new szName[ 32 ], szPlayerName[ 32 ];
  203.         get_user_name( gPlayer, szName, 31 );
  204.         get_user_name( id, szPlayerName, 31 );
  205.        
  206.         if ( !str_to_num( Arg2 ) )
  207.         {
  208.             ColorChat( id, "The player ^3^"^4%s^3^"^1 have^3 %d^1 cash.", szPlayerName, gCash[ id ] );
  209.             return PLUGIN_HANDLED;
  210.         }
  211.         if( !gPlayer )
  212.         {
  213.             ColorChat( id, "The player ^3^"^4%s^3^"^1 was not found.", Arg2 );
  214.             return PLUGIN_HANDLED;
  215.         }
  216.        
  217.         ColorChat( id, "The player ^3^"^4%s^3^"^1 have^3 %d^1 cash.", szName, gCash[ gPlayer ] );
  218.         return PLUGIN_CONTINUE;
  219.     }
  220.     if( equal( Arg, "/transfer" ) )
  221.     {
  222.         new gPlayer;
  223.         gPlayer = cmd_target( id, Arg2, 8 );
  224.        
  225.         if( !gPlayer )
  226.         {
  227.             ColorChat( id, "^3Player^1 was not found!" );
  228.             return PLUGIN_HANDLED;
  229.         }
  230.         if ( id == gPlayer )
  231.         {
  232.             ColorChat( id, "You can't transfer cash to yourself." );
  233.             return PLUGIN_HANDLED;
  234.         }
  235.         if( !is_str_num( Arg3 ) )
  236.         {
  237.             ColorChat( id, "You must type vaild numbers only." );  
  238.             return PLUGIN_HANDLED;
  239.         }
  240.         new gAmount = str_to_num( Arg3 );
  241.        
  242.         if( gAmount < 300 )
  243.         {
  244.             ColorChat( id, "The minimum amount of cash you can transfer is^3 300^1 cash." );
  245.             return 1;
  246.         }
  247.         if( gCash[ id ] < gAmount )
  248.         {
  249.             ColorChat( id, "You don't have this amount of cash." ) 
  250.             return PLUGIN_HANDLED;
  251.         }
  252.         new g_TaxRate = get_pcvar_num( p_TaxRate );
  253.        
  254.         new Tax = gAmount / 100 * g_TaxRate
  255.  
  256.         gCash[ id ] -= gAmount;
  257.         gCash[ gPlayer ] += gAmount / 100 * ( 100 - g_TaxRate );
  258.        
  259.         new szName[ 32 ], szPName[ 32 ]
  260.        
  261.         get_user_name( gPlayer, szName, 31 );
  262.         get_user_name( id, szPName, 31 );
  263.        
  264.         ColorChat( 0, "^4%s^1 transfered^3 %i^1 cash to^4 %s^1.^3 Tax: %d^1", szPName, gAmount, szName, Tax );
  265.         return PLUGIN_HANDLED;
  266.     }
  267.     if( equal( Arg, "/gamble" ) )
  268.     {
  269.         if( !is_str_num( Arg2 ) )
  270.         {
  271.             ColorChat(id, "^3USAGE:^4 /^1Gamble ^4<^1 Amount ^4>")
  272.             return PLUGIN_HANDLED;
  273.         }
  274.         new gAmount = str_to_num( Arg2 );
  275.        
  276.         if ( gAmount < 300 )
  277.         {
  278.             ColorChat(id, "The minimum amount to gamble on is^3 300^1 cash.")
  279.             return PLUGIN_HANDLED;
  280.         }
  281.         if ( gAmount > gCash[ id ] )
  282.         {
  283.             ColorChat(id, "You don't have this amount of cash.")
  284.             return PLUGIN_HANDLED;
  285.         }
  286.        
  287.         new szName[ 32 ];
  288.         get_user_name(id, szName, 31);
  289.        
  290.         switch( random_num( 1, 100 ) )
  291.         {
  292.             case 1..50:
  293.             {
  294.                 ColorChat( 0, "^4%s^1 just gambled on^3 %d^1 cash and^4 won!", szName, gAmount );
  295.                 gCash[ id ] += gAmount
  296.             }
  297.             case 51..100:
  298.             {
  299.                 ColorChat( 0, "^4%s^1 just gambled on^3 %d^1 cash and^4 lose!", szName, gAmount );
  300.                 gCash[ id ] -= gAmount
  301.             }
  302.         }
  303.         return PLUGIN_HANDLED;
  304.     }
  305.     return PLUGIN_CONTINUE;
  306. }
  307.  
  308. public Event_DeathMsg( )
  309. {
  310.     if ( !(get_pcvar_num( p_ShopEnabled ) ) )
  311.         return PLUGIN_HANDLED;
  312.    
  313.     new gAttacker   = read_data( 1 );
  314.     new gVictim     = read_data( 2 );
  315.     new gHeadshot   = read_data( 3 );
  316.    
  317.     if ( cs_get_user_team( gAttacker ) != CS_TEAM_T )
  318.         return PLUGIN_HANDLED;
  319.    
  320.     if ( cs_get_user_team( gVictim ) != CS_TEAM_CT )
  321.         return PLUGIN_HANDLED;
  322.    
  323.     if ( !is_user_connected( gAttacker ) )
  324.         return PLUGIN_HANDLED;
  325.    
  326.     if ( !is_user_connected( gVictim ) )
  327.         return PLUGIN_HANDLED;
  328.    
  329.     if ( gAttacker == gVictim )
  330.         return PLUGIN_HANDLED;
  331.    
  332.     new gHSCash = get_pcvar_num( kill_hs_cash );
  333.     new gKillCash = get_pcvar_num( kill_cash );
  334.    
  335.     if( gHeadshot ) {
  336.         ColorChat( gAttacker, "You received^3 %i Cash^1 for killing a^4 Guard^1.", gHSCash );
  337.         gCash[ gAttacker ] += gHSCash;
  338.         cmdSave( gAttacker );
  339.         return PLUGIN_HANDLED;
  340.     }
  341.     ColorChat( gAttacker, "You received^3 %i Cash^1 for killing a^4 Guard^1.", gKillCash );
  342.     gCash[ gAttacker ] += gKillCash;
  343.     cmdSave( gAttacker );
  344.     return PLUGIN_HANDLED;
  345. }
  346. public client_putinserver( id )
  347. {
  348.     if ( !(get_pcvar_num( p_ShopEnabled ) ) )
  349.         return PLUGIN_HANDLED;
  350.    
  351.     cmdLoad( id );
  352.    
  353.     if ( gConnected[ id ] == 0 )
  354.     {
  355.         gCash[ id ] += 3000;
  356.         gConnected[ id ] = 1;
  357.     }
  358.     return PLUGIN_CONTINUE;
  359. }
  360. public client_disconnect( id )
  361. {
  362.     if ( !(get_pcvar_num( p_ShopEnabled ) ) )
  363.         return PLUGIN_HANDLED;
  364.        
  365.     cmdSave( id );
  366.     d_Godmode[ id ] = false;
  367.     d_Gravity[ id ] = false;
  368.     d_Stealth[ id ] = false;
  369.     return PLUGIN_CONTINUE;
  370. }
  371. public cmdLoad( id )
  372. {
  373.     if ( !(get_pcvar_num( p_ShopEnabled ) ) )
  374.         return PLUGIN_HANDLED;
  375.    
  376.     new szSaveway[ 35 ];
  377.    
  378.     if ( get_pcvar_num( p_Saveway ) >= 2 )
  379.     {
  380.         get_user_authid( id, szSaveway, sizeof( szSaveway ) - 1 );
  381.     }
  382.     if ( get_pcvar_num( p_Saveway ) == 1 )
  383.     {
  384.         get_user_name( id, szSaveway, sizeof( szSaveway ) - 1 );
  385.     }
  386.     if ( get_pcvar_num( p_Saveway ) == 0 )
  387.     {
  388.         get_user_ip( id, szSaveway, sizeof( szSaveway ) - 1 );
  389.     }
  390.    
  391.     new szData[ 16 ];
  392.     if( fvault_get_data( "ShopCash", szSaveway, szData, sizeof( szData ) - 1 ) )
  393.     {
  394.         gCash[ id ] = str_to_num( szData );
  395.         gConnected[ id ] = str_to_num( szData );
  396.     }
  397.    
  398.     return PLUGIN_CONTINUE;
  399. }
  400.  
  401. public cmdSave( id )
  402. {
  403.     if ( !(get_pcvar_num( p_ShopEnabled ) ) )
  404.         return PLUGIN_HANDLED;
  405.        
  406.     new szSaveway[ 35 ];
  407.    
  408.     if ( get_pcvar_num( p_Saveway ) >= 2 )
  409.     {
  410.         get_user_authid( id, szSaveway, sizeof( szSaveway ) - 1 );
  411.     }
  412.     if ( get_pcvar_num( p_Saveway ) == 1 )
  413.     {
  414.         get_user_name( id, szSaveway, sizeof( szSaveway ) - 1 );
  415.     }
  416.     if ( get_pcvar_num( p_Saveway ) == 0 )
  417.     {
  418.         get_user_ip( id, szSaveway, sizeof( szSaveway ) - 1 );
  419.     }
  420.    
  421.     new szData[ 16 ];
  422.     formatex( szData, charsmax( szData ), "%d %d", gCash[ id ], gConnected[ id ] );
  423.     fvault_set_data("ShopCash", szSaveway, szData );
  424.    
  425.     return PLUGIN_CONTINUE;
  426. }
  427. public HamSpawn( id )
  428. {
  429.     if ( !(get_pcvar_num( p_ShopEnabled ) ) )
  430.         return PLUGIN_HANDLED;
  431.        
  432.     set_task( 1.5, "SetCashAsMoney", id );
  433.     return PLUGIN_CONTINUE;
  434. }
  435. public SetCashAsMoney( id )
  436. {
  437.     if ( !(get_pcvar_num( p_ShopEnabled ) ) )
  438.         return PLUGIN_HANDLED;
  439.        
  440.     cs_set_user_money( id, gCash[ id ] );
  441.     return PLUGIN_CONTINUE;
  442. }
  443. public cmdShop( id )
  444. {
  445.     if ( !(get_pcvar_num( p_ShopEnabled ) ) )
  446.     {
  447.         ColorChat(id, "The shop is currently^3 disabled^1." );
  448.         return PLUGIN_HANDLED;
  449.     }
  450.     new gPrefix[ 16 ], Health[ 64 ], Armor[ 64 ];
  451.     get_pcvar_string( p_Prefix, gPrefix, 15 );
  452.    
  453.    
  454.     formatex( gTitle, charsmax( gTitle ), "[\d %s \y]\w Shop Menu^n\rJB Cash:\d %d^n\yby\r %s", gPrefix, gCash[ id ], gAuthor )
  455.    
  456.     formatex( Health, 63, "Purchase Health\d %i Cash per health", get_pcvar_num( p_Health ) );
  457.    
  458.     formatex( Armor, 63, "Purchase Armor\d %i Cash per armor^n", get_pcvar_num( p_Armor ) );
  459.    
  460.    
  461.     new gMenu = menu_create( gTitle, "subShop" );
  462.    
  463.     menu_additem( gMenu, "Purchase Grenades^n", "0", 0 );
  464.     menu_additem( gMenu, Health, "1", 0 );
  465.     menu_additem( gMenu, Armor, "2", 0 );
  466.     menu_additem( gMenu, "Purchase Powers", "3", 0 );
  467.     menu_additem( gMenu, "Purchase Misc Items", "4", 0 );
  468.    
  469.     menu_display( id, gMenu );
  470.    
  471.     return PLUGIN_HANDLED;
  472. }
  473. public subShop( id, gMenu, gItem )
  474. {
  475.     if ( !(get_pcvar_num( p_ShopEnabled ) ) )
  476.     {
  477.         ColorChat(id, "The shop is currently^3 disabled^1." );
  478.         return PLUGIN_HANDLED;
  479.     }
  480.     if ( gItem == MENU_EXIT )
  481.     {
  482.         menu_destroy( gMenu );
  483.         return PLUGIN_HANDLED;
  484.     }
  485.     new gPrefix[ 16 ];
  486.     get_pcvar_string( p_Prefix, gPrefix, 15 );
  487.     switch ( gItem )
  488.     {
  489.         case 0:
  490.         {
  491.             new Explosive[ 64 ], Flashbang[ 64 ], Smokegrenade[ 64 ];
  492.            
  493.            
  494.             formatex( gTitle, charsmax( gTitle ), "[\d %s \y]\w Grenades Shop^n\rJB Cash:\d %d^n\yby\r %s", gPrefix, gCash[ id ], gAuthor );
  495.            
  496.             formatex( Explosive, 63, "Explosive\d - %i Cash", get_pcvar_num( p_Explosive ) );
  497.            
  498.             formatex( Flashbang, 63, "Flashbang\d - %i Cash", get_pcvar_num( p_Flashbang ) );
  499.            
  500.             formatex( Smokegrenade, 63, "Smokegrenade\d - %i Cash", get_pcvar_num( p_Smokegrenade ) );
  501.            
  502.            
  503.             new gMenu = menu_create( gTitle, "subGrenades" );
  504.            
  505.             menu_additem( gMenu, Explosive, "0", 0 );
  506.             menu_additem( gMenu, Flashbang, "1", 0 );
  507.             menu_additem( gMenu, Smokegrenade, "2", 0 );
  508.            
  509.             menu_display( id, gMenu );
  510.         }
  511.         case 1:     client_cmd( id, "messagemode _health_" );
  512.         case 2:     client_cmd( id, "messagemode _armor_" );
  513.         case 3:
  514.         {
  515.             new Godmode[ 64 ], Gravity[ 64 ], Stealth[ 64 ];
  516.            
  517.            
  518.             formatex( gTitle, charsmax( gTitle ), "[\d %s \y]\w Powers Shop^n\rJB Cash:\d %d^n\yby\r %s", gPrefix, gCash[ id ], gAuthor );
  519.            
  520.             formatex( Godmode, 63, "Godmode -\y 8 Seconds\d - %i Cash", get_pcvar_num( p_Godmode ) );
  521.            
  522.             formatex( Gravity, 63, "Gravity -\y 10 Seconds\d - %i Cash", get_pcvar_num( p_Gravity ) );
  523.            
  524.             formatex( Stealth, 63, "Stealth -\y 10 Seconds\d - %i Cash", get_pcvar_num( p_Stealth ) );
  525.            
  526.            
  527.             new gMenu = menu_create( gTitle, "subPowers" );
  528.            
  529.             menu_additem( gMenu, Godmode, "0", 0 );
  530.             menu_additem( gMenu, Gravity, "1", 0 );
  531.             menu_additem( gMenu, Stealth, "2", 0 );
  532.            
  533.             menu_display( id, gMenu );
  534.         }
  535.         case 4:
  536.         {
  537.             new SwitchTeams[ 64 ], RoundFreeday[ 64 ];
  538.            
  539.            
  540.             formatex( gTitle, charsmax( gTitle ), "[\d %s \y]\w Misc Stuff Shop^n\rJB Cash:\d %d^n\yby\r %s", gPrefix, gCash[ id ], gAuthor );
  541.            
  542.             formatex( SwitchTeams, 63, "Switch Teams\d - %i Cash", get_pcvar_num( p_SwitchTeams ) );
  543.            
  544.             formatex( RoundFreeday, 63, "Freeday -\y One Round\d - %i Cash", get_pcvar_num( p_RoundFreeday ) );
  545.            
  546.            
  547.             new gMenu = menu_create( gTitle, "subMisc" );
  548.            
  549.             menu_additem( gMenu, SwitchTeams, "0", 0 );
  550.             menu_additem( gMenu, RoundFreeday, "1", 0 );
  551.            
  552.             menu_display( id, gMenu );
  553.         }
  554.     }
  555.     menu_destroy( gMenu );
  556.     return PLUGIN_HANDLED;
  557. }
  558.  
  559. public subGrenades( id, gMenu, gItem )
  560. {
  561.     if ( !(get_pcvar_num( p_ShopEnabled ) ) )
  562.     {
  563.         ColorChat(id, "The shop is currently^3 disabled^1." );
  564.         return PLUGIN_HANDLED;
  565.     }
  566.     if ( gItem == MENU_EXIT )
  567.     {
  568.         menu_destroy( gMenu );
  569.         return PLUGIN_HANDLED;
  570.     }
  571.     if ( !is_user_alive( id ) )
  572.     {
  573.         ColorChat( id, "You need to be ^3 Alive^1 in order to purchase^4 Grenades^1 from the shop." );
  574.         return PLUGIN_HANDLED;
  575.     }
  576.     if ( cs_get_user_team( id ) != CS_TEAM_T )
  577.     {
  578.         ColorChat( id, "You need to be a^3 Prisoner^1 in order to purchase^4 Grenades^1 from the shop." );
  579.         return PLUGIN_HANDLED;
  580.     }
  581.     if ( user_has_weapon( id, g_GrenadesCSW[ gItem ] ) )
  582.     {
  583.         ColorChat( id, "You already own this item." );
  584.         return PLUGIN_HANDLED;
  585.     }
  586.     new gExplosive = get_pcvar_num( p_Explosive );
  587.     new gFlashbang = get_pcvar_num( p_Flashbang );
  588.     new gSmokegrenade = get_pcvar_num( p_Smokegrenade );
  589.    
  590.     switch ( gItem )
  591.     {
  592.         case 0:
  593.         {
  594.             if ( gCash[ id ] < gExplosive )
  595.             {
  596.                 ColorChat( id, "Your missing^3 %i Cash^1 in order to purchase this item from the shop.", gExplosive - gCash[ id ] );
  597.                 return PLUGIN_HANDLED;
  598.             }
  599.             gCash[ id ] -= gExplosive
  600.         }
  601.         case 1:
  602.         {
  603.             if ( gCash[ id ] < gFlashbang )
  604.             {
  605.                 ColorChat( id, "Your missing^3 %i Cash^1 in order to purchase this item from the shop.", gFlashbang - gCash[ id ] );
  606.                 return PLUGIN_HANDLED;
  607.             }
  608.             gCash[ id ] -= gFlashbang
  609.         }
  610.         case 2:
  611.         {
  612.             if ( gCash[ id ] < gSmokegrenade )
  613.             {
  614.                 ColorChat( id, "Your missing^3 %i Cash^1 in order to purchase this item from the shop.", gSmokegrenade - gCash[ id ] );
  615.                 return PLUGIN_HANDLED;
  616.             }
  617.             gCash[ id ] -= gSmokegrenade
  618.         }
  619.     }
  620.     ColorChat( id, "You have purchased the item^4 %s Grenade^1 from the shop.", g_GrenadesNames[ gItem ] );
  621.     give_item( id, g_GrenadesClass[ gItem ] );
  622.     SetCashAsMoney( id );
  623.     menu_destroy( gMenu );
  624.     return PLUGIN_HANDLED;
  625. }
  626. public subHealth( id )
  627. {
  628.     if ( !(get_pcvar_num( p_ShopEnabled ) ) )
  629.     {
  630.         ColorChat(id, "The shop is currently^3 disabled^1." );
  631.         return PLUGIN_HANDLED;
  632.     }
  633.     new Arg[ 128 ];
  634.     read_args( Arg, charsmax(Arg) );
  635.     remove_quotes( Arg );
  636.    
  637.     new gHealth = get_pcvar_num( p_Health )
  638.    
  639.     new g_Nums[ 2 ];
  640.     g_Nums[ 0 ] = str_to_num( Arg );
  641.     g_Nums[ 1 ] = str_to_num( Arg ) * gHealth;
  642.    
  643.     if ( !is_user_alive(id) )
  644.     {
  645.         ColorChat( id, "You need to be ^3 Alive^1 in order to purchase^4 Health^1 from the shop." );
  646.         return PLUGIN_HANDLED;
  647.     }
  648.     if (  !is_str_num( Arg ) )
  649.         return PLUGIN_HANDLED;
  650.     if ( g_Nums[ 0 ] < 1 )
  651.     {
  652.         ColorChat( id, "The value of^3 health^1 must be greater than^4 0" );
  653.         client_cmd(id, "messagemode _health_");
  654.         return PLUGIN_HANDLED;
  655.     }
  656.     if ( g_Nums[ 0 ] > 300 )
  657.     {
  658.         ColorChat( id, "The value of^3 health^1 must be smaller than^4 300" );
  659.         client_cmd(id, "messagemode _health_");
  660.         return PLUGIN_HANDLED;
  661.     }
  662.     if( gCash[ id ] < g_Nums[ 1 ] )
  663.     {
  664.         ColorChat( id, "Your missing^3 %i Cash^1 in order to purchase^4 health^1 from the shop.", g_Nums[ 1 ] - gCash[ id ] );
  665.         client_cmd(id, "messagemode _health_");
  666.         return PLUGIN_HANDLED;
  667.     }
  668.     ColorChat( id, "You have purchased^3 %i Health^1 for^4 %i Cash^1 from the shop.", g_Nums[ 0 ], g_Nums[ 1 ] );
  669.     set_user_health( id, get_user_health( id ) + g_Nums[ 0 ] )
  670.     gCash[ id ] -= g_Nums[ 1 ];
  671.     SetCashAsMoney( id );
  672.     return PLUGIN_HANDLED;
  673. }
  674. public subArmor( id )
  675. {
  676.     if ( !(get_pcvar_num( p_ShopEnabled ) ) )
  677.     {
  678.         ColorChat(id, "The shop is currently^3 disabled^1." );
  679.         return PLUGIN_HANDLED;
  680.     }
  681.     new Arg[ 128 ];
  682.     read_args( Arg, charsmax(Arg) );
  683.     remove_quotes( Arg );
  684.    
  685.     new gArmor = get_pcvar_num( p_Armor )
  686.    
  687.     new g_Nums[ 2 ];
  688.     g_Nums[ 0 ] = str_to_num( Arg );
  689.     g_Nums[ 1 ] = str_to_num( Arg ) * gArmor;
  690.    
  691.     if ( !is_user_alive(id) )
  692.     {
  693.         ColorChat( id, "You need to be ^3 Alive^1 in order to purchase^4 Armor^1 from the shop." );
  694.         return PLUGIN_HANDLED;
  695.     }
  696.     if (  !is_str_num( Arg ) )
  697.         return PLUGIN_HANDLED;
  698.     if ( g_Nums[ 0 ] < 1 )
  699.     {
  700.         ColorChat( id, "The value of^3 armor^1 must be greater than^4 0" );
  701.         client_cmd(id, "messagemode _armor_");
  702.         return PLUGIN_HANDLED;
  703.     }
  704.     if ( g_Nums[ 0 ] > 300 )
  705.     {
  706.         ColorChat( id, "The value of^3 armor^1 must be smaller than^4 300" );
  707.         client_cmd(id, "messagemode _armor_");
  708.         return PLUGIN_HANDLED;
  709.     }
  710.     if( gCash[ id ] < g_Nums[ 1 ] )
  711.     {
  712.         ColorChat( id, "Your missing^3 %i Cash^1 in order to purchase^4 armor^1 from the shop.", g_Nums[ 1 ] - gCash[ id ] );
  713.         client_cmd(id, "messagemode _armor_");
  714.         return PLUGIN_HANDLED;
  715.     }
  716.     ColorChat( id, "You have purchased^3 %i Armor^1 for^4 %i Cash^1 from the shop.", g_Nums[ 0 ], g_Nums[ 1 ] );
  717.     set_user_armor( id, get_user_armor( id ) + g_Nums[ 0 ] )
  718.     gCash[ id ] -= g_Nums[ 1 ];
  719.     SetCashAsMoney( id );
  720.     return PLUGIN_HANDLED;
  721. }
  722. public subPowers( id, gMenu, gItem )
  723. {
  724.     if ( !(get_pcvar_num( p_ShopEnabled ) ) )
  725.     {
  726.         ColorChat(id, "The shop is currently^3 disabled^1." );
  727.         return PLUGIN_HANDLED;
  728.     }
  729.     if ( gItem == MENU_EXIT )
  730.     {
  731.         menu_destroy( gMenu );
  732.         return PLUGIN_HANDLED;
  733.     }
  734.     if ( !is_user_alive( id ) )
  735.     {
  736.         ColorChat( id, "You need to be ^3 Alive^1 in order to purchase^4 Powers^1 from the shop." );
  737.         return PLUGIN_HANDLED;
  738.     }
  739.     if ( cs_get_user_team( id ) != CS_TEAM_T )
  740.     {
  741.         ColorChat( id, "You need to be a^3 Prisoner^1 in order to purchase^4 Powers^1 from the shop." );
  742.         return PLUGIN_HANDLED;
  743.     }
  744.     new gGodmode = get_pcvar_num( p_Godmode );
  745.     new gGravity = get_pcvar_num( p_Gravity );
  746.     new gStealth = get_pcvar_num( p_Stealth );
  747.    
  748.     switch ( gItem )
  749.     {
  750.         case 0:
  751.         {
  752.             if ( gCash[ id ] < gGodmode )
  753.             {
  754.                 ColorChat( id, "Your missing^3 %i Cash^1 in order to purchase this item from the shop.", gGodmode - gCash[ id ] );
  755.                 return PLUGIN_HANDLED;
  756.             }
  757.             if ( d_Godmode[ id ] )
  758.             {
  759.                 ColorChat( id, "Your currently using this power." );
  760.                 return PLUGIN_HANDLED;
  761.             }
  762.             gCash[ id ] -= gGodmode;
  763.             d_Godmode[ id ] = true;
  764.             set_user_godmode( id, 1 );
  765.             set_task( 8.0, "RemoveGodmode", id );
  766.         }
  767.         case 1:
  768.         {
  769.             if ( gCash[ id ] < gGravity )
  770.             {
  771.                 ColorChat( id, "Your missing^3 %i Cash^1 in order to purchase this item from the shop.", gGravity - gCash[ id ] );
  772.                 return PLUGIN_HANDLED;
  773.             }
  774.             if ( d_Gravity[ id ] )
  775.             {
  776.                 ColorChat( id, "Your currently using this power." );
  777.                 return PLUGIN_HANDLED;
  778.             }
  779.             gCash[ id ] -= gGravity;
  780.             d_Gravity[ id ] = true;
  781.             set_user_gravity( id, 0.5 );
  782.             set_task( 10.0, "RemoveGravity", id );
  783.         }
  784.         case 2:
  785.         {
  786.             if ( gCash[ id ] < gStealth )
  787.             {
  788.                 ColorChat( id, "Your missing^3 %i Cash^1 in order to purchase this item from the shop.", gStealth - gCash[ id ] );
  789.                 return PLUGIN_HANDLED;
  790.             }
  791.             if ( d_Stealth[ id ] )
  792.             {
  793.                 ColorChat( id, "Your currently using this power." );
  794.                 return PLUGIN_HANDLED;
  795.             }
  796.             gCash[ id ] -= gStealth;
  797.             d_Stealth[ id ] = true;
  798.             set_user_rendering( id, kRenderFxGlowShell, 0, 0, 0, kRenderTransAlpha, 0 );
  799.             set_task( 10.0, "RemoveStealth", id );
  800.         }
  801.     }
  802.     ColorChat( id, "You have purchased the item^4 %s Seconds^1 from the shop.", g_PowersNames[ gItem ] );
  803.     SetCashAsMoney( id );
  804.     menu_destroy( gMenu );
  805.     return PLUGIN_HANDLED;
  806. }
  807.  
  808.  
  809. public RemoveGodmode( id )
  810. {
  811.     if ( !(get_pcvar_num( p_ShopEnabled ) ) )
  812.         return PLUGIN_HANDLED;
  813.        
  814.     if ( d_Godmode[ id ] )
  815.     {
  816.         set_user_godmode( id, 0 );
  817.         d_Godmode[ id ] = false;
  818.     }
  819.     return PLUGIN_CONTINUE;
  820. }
  821. public RemoveGravity( id )
  822. {
  823.     if ( !(get_pcvar_num( p_ShopEnabled ) ) )
  824.         return PLUGIN_HANDLED;
  825.        
  826.     if ( d_Gravity[ id ] )
  827.     {
  828.         set_user_gravity( id, 1.0 );
  829.         d_Gravity[ id ] = false;
  830.     }
  831.     return PLUGIN_CONTINUE;
  832. }
  833. public RemoveStealth( id )
  834. {
  835.     if ( !(get_pcvar_num( p_ShopEnabled ) ) )
  836.         return PLUGIN_HANDLED;
  837.        
  838.     if ( d_Stealth[ id ] )
  839.     {
  840.         set_user_rendering( id, kRenderFxGlowShell, 0, 0, 0, kRenderTransAlpha, 255 );
  841.         d_Stealth[ id ] = false;
  842.     }
  843.     return PLUGIN_CONTINUE;
  844. }
  845. public subMisc( id, gMenu, gItem )
  846. {
  847.     if ( !(get_pcvar_num( p_ShopEnabled ) ) )
  848.     {
  849.         ColorChat(id, "The shop is currently^3 disabled^1." );
  850.         return PLUGIN_HANDLED;
  851.     }
  852.     if ( gItem == MENU_EXIT )
  853.     {
  854.         menu_destroy( gMenu );
  855.         return PLUGIN_HANDLED;
  856.     }
  857.     if ( !is_user_alive( id ) )
  858.     {
  859.         ColorChat( id, "You need to be ^3 Alive^1 in order to purchase^4 Misc^1 from the shop." );
  860.         return PLUGIN_HANDLED;
  861.     }
  862.     if ( cs_get_user_team( id ) != CS_TEAM_T )
  863.     {
  864.         ColorChat( id, "You need to be a^3 Prisoner^1 in order to purchase^4 Misc^1 from the shop." );
  865.         return PLUGIN_HANDLED;
  866.     }
  867.     new gSwitchTeams = get_pcvar_num( p_SwitchTeams );
  868.     new gRoundFreeday = get_pcvar_num( p_RoundFreeday );
  869.     switch ( gItem )
  870.     {
  871.         case 0:
  872.         {
  873.             if ( gCash[ id ] < gSwitchTeams )
  874.             {
  875.                 ColorChat( id, "Your missing^3 %i Cash^1 in order to purchase this item from the shop.", gSwitchTeams - gCash[ id ] );
  876.                 return PLUGIN_HANDLED;
  877.             }
  878.             gCash[ id ] -= gSwitchTeams;
  879.             cs_set_user_team( id, CS_TEAM_CT );
  880.             ExecuteHamB( Ham_CS_RoundRespawn, id )
  881.         }
  882.         case 1:
  883.         {
  884.             if ( gCash[ id ] < gRoundFreeday )
  885.             {
  886.                 ColorChat( id, "Your missing^3 %i Cash^1 in order to purchase this item from the shop.", gRoundFreeday - gCash[ id ] );
  887.                 return PLUGIN_HANDLED;
  888.             }
  889.             gCash[ id ] -= gRoundFreeday;
  890.             set_user_rendering( id, kRenderFxGlowShell, 0, 250, 0, kRenderNormal, 255 )
  891.         }
  892.     }
  893.     new szName[ 32 ]; get_user_name( id, szName, 31 );
  894.     ColorChat( 0, "^4%s^1 have purchased the item^4 %s^1 from the shop.", szName, g_MiscStuffNames[ gItem ] );
  895.     set_hudmessage( 0, 160, 0, 0.1, 0.55, 1, 6.0, 6.0 );
  896.     show_hudmessage( 0, "%s have purchased the item^n%s from the shop.", szName, g_MiscStuffNames[ gItem ] );
  897.     SetCashAsMoney( id );
  898.     menu_destroy( gMenu );
  899.     return PLUGIN_HANDLED;
  900.    
  901.    
  902. }
  903. stock ColorChat( const id, const string[], any:... )
  904. {
  905.     new msg[ 191 ], players[ 32 ], count = 1, gPrefix[ 16 ];
  906.     get_pcvar_string( p_Prefix, gPrefix, 15 );
  907.    
  908.     static len; len = formatex( msg, charsmax( msg ), "^3[^4 %s ^3]^1 ", gPrefix );
  909.     vformat( msg[ len ], charsmax( msg ) - len, string, 3 );
  910.    
  911.     if( id )  players[ 0 ] = id;
  912.    
  913.     else    get_players( players,count,"ch" );
  914.    
  915.     for ( new i = 0; i < count; i++ )
  916.     {
  917.         if( is_user_connected( players[ i ] ) )
  918.         {
  919.             message_begin( MSG_ONE_UNRELIABLE, get_user_msgid( "SayText" ), _, players[ i ] );
  920.             write_byte( players[ i ] );
  921.             write_string( msg );
  922.             message_end( );
  923.         }
  924.     }
  925. }
Advertisement
Add Comment
Please, Sign In to add comment