Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include < amxmodx >
- #include < amxmisc >
- #include < cstrike >
- #include < fun >
- #include < hamsandwich >
- #include < fvault >
- #define gPlugin "JailBreak Shop"
- #define gVersion "1.2"
- #define gAuthor "Rejack"
- new
- gCash[ 33 ],
- gConnected[ 33 ],
- gTitle[ 128 ],
- p_Saveway,
- p_Prefix,
- p_ShopEnabled,
- p_Explosive,
- p_Flashbang,
- p_Smokegrenade,
- p_Health,
- p_Armor,
- p_Godmode,
- p_Gravity,
- p_Stealth,
- p_SwitchTeams,
- p_RoundFreeday,
- kill_cash,
- kill_hs_cash,
- p_TaxRate;
- new g_GrenadesNames[ ][ ] = { "Explosive", "Flashbang", "Smoke" }
- new g_GrenadesClass[ ][ ] = { "weapon_hegrenade", "weapon_flashbang", "weapon_smokegrenade" }
- new g_GrenadesCSW[ ] = { CSW_HEGRENADE, CSW_FLASHBANG, CSW_SMOKEGRENADE }
- new g_PowersNames[ ][ ] = { "Godmode 8", "Gravity 10", "Stealth 10" }
- new g_MiscStuffNames[ ][ ] = { "Switch Teams", "Freeday - One Round" }
- new
- bool:d_Godmode[ 33 ] = false,
- bool:d_Gravity[ 33 ] = false,
- bool:d_Stealth[ 33 ] = false;
- public plugin_init( )
- {
- register_plugin(gPlugin, gVersion, gAuthor);
- register_clcmd( "say /shop", "cmdShop" );
- register_clcmd( "say", "cmdSay" );
- register_clcmd( "shop_add_cash", "cmdAddCash" );
- register_clcmd( "shop_remove_cash", "cmdRemoveCash" );
- register_clcmd( "_health_", "subHealth" );
- register_clcmd( "_armor_", "subArmor" );
- p_ShopEnabled = register_cvar( "shop_enabled", "1" );
- p_Prefix = register_cvar( "shop_prefix", "JailBreak" );
- p_Saveway = register_cvar( "shop_save", "2" );
- p_Explosive = register_cvar( "shop_cost_explosive", "2500" );
- p_Flashbang = register_cvar( "shop_cost_flash", "1000" );
- p_Smokegrenade = register_cvar( "shop_cost_smoke", "1500" );
- p_Health = register_cvar( "shop_cost_health", "25" );
- p_Armor = register_cvar( "shop_cost_armor", "12" );
- p_Godmode = register_cvar( "shop_cost_godmode", "4500" );
- p_Gravity = register_cvar( "shop_cost_gravity", "2500" );
- p_Stealth = register_cvar( "shop_cost_stealth", "3500" );
- p_SwitchTeams = register_cvar( "shop_cost_switch", "25000" );
- p_RoundFreeday = register_cvar( "shop_cost_freeday", "8500" );
- kill_cash = register_cvar( "kill_cash", "100" );
- kill_hs_cash = register_cvar( "kill_hs_cash", "150" );
- p_TaxRate = register_cvar( "shop_tax_rate", "7" );
- RegisterHam( Ham_Spawn, "player", "HamSpawn", 1 );
- register_event( "DeathMsg", "Event_DeathMsg", "a" );
- }
- public plugin_natives()
- {
- register_library("jail_cash");
- register_native("get_user_cash", "_get_cash");
- register_native("set_user_cash", "_set_cash");
- }
- public _get_cash( plugin, params )
- {
- return gCash[ get_param( 1 ) ];
- }
- public _set_cash( plugin, params )
- {
- new id = get_param( 1 );
- gCash[ id ] = max( 0, get_param( 2 ) );
- cmdSave( id );
- return gCash[ id ];
- }
- public cmdAddCash( id )
- {
- if ( !(get_user_flags( id ) & ADMIN_IMMUNITY ) )
- return PLUGIN_HANDLED;
- new szTarget[ 32 ], szAmount[ 21 ];
- read_argv( 1, szTarget, 31 );
- read_argv( 2, szAmount, 20 );
- new gPlayer = cmd_target( id, szTarget, 8 );
- if ( !gPlayer )
- {
- return PLUGIN_HANDLED;
- }
- new szName[ 32 ], szPName[ 32 ];
- get_user_name( id, szName, 31 );
- get_user_name( gPlayer, szPName, 31 );
- new CashNum = str_to_num( szAmount );
- gCash[ gPlayer ] += CashNum;
- switch ( get_cvar_num( "amx_show_activity" ) )
- {
- case 1:
- {
- ColorChat( id, "^3ADMIN:^1 added^4 %i^1 cash to the player:^4 %s^1. (^4 %d Cash ^1)", CashNum, szPName, gCash[ gPlayer ] );
- }
- case 2:
- {
- 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 ] );
- }
- }
- ColorChat( gPlayer, "You were added^4 %i^1 cash by the^3 ADMIN:^4 %s", CashNum, szName );
- cmdSave( id );
- return PLUGIN_HANDLED;
- }
- public cmdRemoveCash( id )
- {
- if ( !(get_user_flags( id ) & ADMIN_IMMUNITY ) )
- return PLUGIN_HANDLED;
- new szTarget[ 32 ], szAmount[ 21 ];
- read_argv( 1, szTarget, 31 );
- read_argv( 2, szAmount, 20 );
- new gPlayer = cmd_target( id, szTarget, 8 );
- if ( !gPlayer )
- {
- return PLUGIN_HANDLED;
- }
- new szName[ 32 ], szPName[ 32 ];
- get_user_name( id, szName, 31 );
- get_user_name( gPlayer, szPName, 31 );
- new CashNum = str_to_num( szAmount );
- gCash[ gPlayer ] -= CashNum;
- switch ( get_cvar_num( "amx_show_activity" ) )
- {
- case 1:
- {
- ColorChat( id, "^3ADMIN:^1 removed^4 %i^1 cash from the player:^4 %s^1. (^4 %d Cash ^1)", CashNum, szPName, gCash[ gPlayer ] );
- }
- case 2:
- {
- 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 ] );
- }
- }
- ColorChat( gPlayer, "You were removed^4 %i^1 cash by the^3 ADMIN:^4 %s", CashNum, szName );
- cmdSave( id );
- return PLUGIN_HANDLED;
- }
- public cmdSay( id )
- {
- if ( !(get_pcvar_num( p_ShopEnabled ) ) )
- return PLUGIN_HANDLED;
- new szMsg[ 192 ], Arg[ 38 ], Arg2[ 38 ], Arg3[ 32 ];
- read_argv( 1, szMsg, charsmax( szMsg ) );
- parse( szMsg, Arg, charsmax( Arg ), Arg2, charsmax( Arg2 ), Arg3, charsmax( Arg3 ) );
- if( equal( Arg, "/cash" ) )
- {
- new gPlayer;
- gPlayer = cmd_target( id, Arg2, 8 );
- new szName[ 32 ], szPlayerName[ 32 ];
- get_user_name( gPlayer, szName, 31 );
- get_user_name( id, szPlayerName, 31 );
- if ( !str_to_num( Arg2 ) )
- {
- ColorChat( id, "The player ^3^"^4%s^3^"^1 have^3 %d^1 cash.", szPlayerName, gCash[ id ] );
- return PLUGIN_HANDLED;
- }
- if( !gPlayer )
- {
- ColorChat( id, "The player ^3^"^4%s^3^"^1 was not found.", Arg2 );
- return PLUGIN_HANDLED;
- }
- ColorChat( id, "The player ^3^"^4%s^3^"^1 have^3 %d^1 cash.", szName, gCash[ gPlayer ] );
- return PLUGIN_CONTINUE;
- }
- if( equal( Arg, "/transfer" ) )
- {
- new gPlayer;
- gPlayer = cmd_target( id, Arg2, 8 );
- if( !gPlayer )
- {
- ColorChat( id, "^3Player^1 was not found!" );
- return PLUGIN_HANDLED;
- }
- if ( id == gPlayer )
- {
- ColorChat( id, "You can't transfer cash to yourself." );
- return PLUGIN_HANDLED;
- }
- if( !is_str_num( Arg3 ) )
- {
- ColorChat( id, "You must type vaild numbers only." );
- return PLUGIN_HANDLED;
- }
- new gAmount = str_to_num( Arg3 );
- if( gAmount < 300 )
- {
- ColorChat( id, "The minimum amount of cash you can transfer is^3 300^1 cash." );
- return 1;
- }
- if( gCash[ id ] < gAmount )
- {
- ColorChat( id, "You don't have this amount of cash." )
- return PLUGIN_HANDLED;
- }
- new g_TaxRate = get_pcvar_num( p_TaxRate );
- new Tax = gAmount / 100 * g_TaxRate
- gCash[ id ] -= gAmount;
- gCash[ gPlayer ] += gAmount / 100 * ( 100 - g_TaxRate );
- new szName[ 32 ], szPName[ 32 ]
- get_user_name( gPlayer, szName, 31 );
- get_user_name( id, szPName, 31 );
- ColorChat( 0, "^4%s^1 transfered^3 %i^1 cash to^4 %s^1.^3 Tax: %d^1", szPName, gAmount, szName, Tax );
- return PLUGIN_HANDLED;
- }
- if( equal( Arg, "/gamble" ) )
- {
- if( !is_str_num( Arg2 ) )
- {
- ColorChat(id, "^3USAGE:^4 /^1Gamble ^4<^1 Amount ^4>")
- return PLUGIN_HANDLED;
- }
- new gAmount = str_to_num( Arg2 );
- if ( gAmount < 300 )
- {
- ColorChat(id, "The minimum amount to gamble on is^3 300^1 cash.")
- return PLUGIN_HANDLED;
- }
- if ( gAmount > gCash[ id ] )
- {
- ColorChat(id, "You don't have this amount of cash.")
- return PLUGIN_HANDLED;
- }
- new szName[ 32 ];
- get_user_name(id, szName, 31);
- switch( random_num( 1, 100 ) )
- {
- case 1..50:
- {
- ColorChat( 0, "^4%s^1 just gambled on^3 %d^1 cash and^4 won!", szName, gAmount );
- gCash[ id ] += gAmount
- }
- case 51..100:
- {
- ColorChat( 0, "^4%s^1 just gambled on^3 %d^1 cash and^4 lose!", szName, gAmount );
- gCash[ id ] -= gAmount
- }
- }
- return PLUGIN_HANDLED;
- }
- return PLUGIN_CONTINUE;
- }
- public Event_DeathMsg( )
- {
- if ( !(get_pcvar_num( p_ShopEnabled ) ) )
- return PLUGIN_HANDLED;
- new gAttacker = read_data( 1 );
- new gVictim = read_data( 2 );
- new gHeadshot = read_data( 3 );
- if ( cs_get_user_team( gAttacker ) != CS_TEAM_T )
- return PLUGIN_HANDLED;
- if ( cs_get_user_team( gVictim ) != CS_TEAM_CT )
- return PLUGIN_HANDLED;
- if ( !is_user_connected( gAttacker ) )
- return PLUGIN_HANDLED;
- if ( !is_user_connected( gVictim ) )
- return PLUGIN_HANDLED;
- if ( gAttacker == gVictim )
- return PLUGIN_HANDLED;
- new gHSCash = get_pcvar_num( kill_hs_cash );
- new gKillCash = get_pcvar_num( kill_cash );
- if( gHeadshot ) {
- ColorChat( gAttacker, "You received^3 %i Cash^1 for killing a^4 Guard^1.", gHSCash );
- gCash[ gAttacker ] += gHSCash;
- cmdSave( gAttacker );
- return PLUGIN_HANDLED;
- }
- ColorChat( gAttacker, "You received^3 %i Cash^1 for killing a^4 Guard^1.", gKillCash );
- gCash[ gAttacker ] += gKillCash;
- cmdSave( gAttacker );
- return PLUGIN_HANDLED;
- }
- public client_putinserver( id )
- {
- if ( !(get_pcvar_num( p_ShopEnabled ) ) )
- return PLUGIN_HANDLED;
- cmdLoad( id );
- if ( gConnected[ id ] == 0 )
- {
- gCash[ id ] += 3000;
- gConnected[ id ] = 1;
- }
- return PLUGIN_CONTINUE;
- }
- public client_disconnect( id )
- {
- if ( !(get_pcvar_num( p_ShopEnabled ) ) )
- return PLUGIN_HANDLED;
- cmdSave( id );
- d_Godmode[ id ] = false;
- d_Gravity[ id ] = false;
- d_Stealth[ id ] = false;
- return PLUGIN_CONTINUE;
- }
- public cmdLoad( id )
- {
- if ( !(get_pcvar_num( p_ShopEnabled ) ) )
- return PLUGIN_HANDLED;
- new szSaveway[ 35 ];
- if ( get_pcvar_num( p_Saveway ) >= 2 )
- {
- get_user_authid( id, szSaveway, sizeof( szSaveway ) - 1 );
- }
- if ( get_pcvar_num( p_Saveway ) == 1 )
- {
- get_user_name( id, szSaveway, sizeof( szSaveway ) - 1 );
- }
- if ( get_pcvar_num( p_Saveway ) == 0 )
- {
- get_user_ip( id, szSaveway, sizeof( szSaveway ) - 1 );
- }
- new szData[ 16 ];
- if( fvault_get_data( "ShopCash", szSaveway, szData, sizeof( szData ) - 1 ) )
- {
- gCash[ id ] = str_to_num( szData );
- gConnected[ id ] = str_to_num( szData );
- }
- return PLUGIN_CONTINUE;
- }
- public cmdSave( id )
- {
- if ( !(get_pcvar_num( p_ShopEnabled ) ) )
- return PLUGIN_HANDLED;
- new szSaveway[ 35 ];
- if ( get_pcvar_num( p_Saveway ) >= 2 )
- {
- get_user_authid( id, szSaveway, sizeof( szSaveway ) - 1 );
- }
- if ( get_pcvar_num( p_Saveway ) == 1 )
- {
- get_user_name( id, szSaveway, sizeof( szSaveway ) - 1 );
- }
- if ( get_pcvar_num( p_Saveway ) == 0 )
- {
- get_user_ip( id, szSaveway, sizeof( szSaveway ) - 1 );
- }
- new szData[ 16 ];
- formatex( szData, charsmax( szData ), "%d %d", gCash[ id ], gConnected[ id ] );
- fvault_set_data("ShopCash", szSaveway, szData );
- return PLUGIN_CONTINUE;
- }
- public HamSpawn( id )
- {
- if ( !(get_pcvar_num( p_ShopEnabled ) ) )
- return PLUGIN_HANDLED;
- set_task( 1.5, "SetCashAsMoney", id );
- return PLUGIN_CONTINUE;
- }
- public SetCashAsMoney( id )
- {
- if ( !(get_pcvar_num( p_ShopEnabled ) ) )
- return PLUGIN_HANDLED;
- cs_set_user_money( id, gCash[ id ] );
- return PLUGIN_CONTINUE;
- }
- public cmdShop( id )
- {
- if ( !(get_pcvar_num( p_ShopEnabled ) ) )
- {
- ColorChat(id, "The shop is currently^3 disabled^1." );
- return PLUGIN_HANDLED;
- }
- new gPrefix[ 16 ], Health[ 64 ], Armor[ 64 ];
- get_pcvar_string( p_Prefix, gPrefix, 15 );
- formatex( gTitle, charsmax( gTitle ), "[\d %s \y]\w Shop Menu^n\rJB Cash:\d %d^n\yby\r %s", gPrefix, gCash[ id ], gAuthor )
- formatex( Health, 63, "Purchase Health\d %i Cash per health", get_pcvar_num( p_Health ) );
- formatex( Armor, 63, "Purchase Armor\d %i Cash per armor^n", get_pcvar_num( p_Armor ) );
- new gMenu = menu_create( gTitle, "subShop" );
- menu_additem( gMenu, "Purchase Grenades^n", "0", 0 );
- menu_additem( gMenu, Health, "1", 0 );
- menu_additem( gMenu, Armor, "2", 0 );
- menu_additem( gMenu, "Purchase Powers", "3", 0 );
- menu_additem( gMenu, "Purchase Misc Items", "4", 0 );
- menu_display( id, gMenu );
- return PLUGIN_HANDLED;
- }
- public subShop( id, gMenu, gItem )
- {
- if ( !(get_pcvar_num( p_ShopEnabled ) ) )
- {
- ColorChat(id, "The shop is currently^3 disabled^1." );
- return PLUGIN_HANDLED;
- }
- if ( gItem == MENU_EXIT )
- {
- menu_destroy( gMenu );
- return PLUGIN_HANDLED;
- }
- new gPrefix[ 16 ];
- get_pcvar_string( p_Prefix, gPrefix, 15 );
- switch ( gItem )
- {
- case 0:
- {
- new Explosive[ 64 ], Flashbang[ 64 ], Smokegrenade[ 64 ];
- formatex( gTitle, charsmax( gTitle ), "[\d %s \y]\w Grenades Shop^n\rJB Cash:\d %d^n\yby\r %s", gPrefix, gCash[ id ], gAuthor );
- formatex( Explosive, 63, "Explosive\d - %i Cash", get_pcvar_num( p_Explosive ) );
- formatex( Flashbang, 63, "Flashbang\d - %i Cash", get_pcvar_num( p_Flashbang ) );
- formatex( Smokegrenade, 63, "Smokegrenade\d - %i Cash", get_pcvar_num( p_Smokegrenade ) );
- new gMenu = menu_create( gTitle, "subGrenades" );
- menu_additem( gMenu, Explosive, "0", 0 );
- menu_additem( gMenu, Flashbang, "1", 0 );
- menu_additem( gMenu, Smokegrenade, "2", 0 );
- menu_display( id, gMenu );
- }
- case 1: client_cmd( id, "messagemode _health_" );
- case 2: client_cmd( id, "messagemode _armor_" );
- case 3:
- {
- new Godmode[ 64 ], Gravity[ 64 ], Stealth[ 64 ];
- formatex( gTitle, charsmax( gTitle ), "[\d %s \y]\w Powers Shop^n\rJB Cash:\d %d^n\yby\r %s", gPrefix, gCash[ id ], gAuthor );
- formatex( Godmode, 63, "Godmode -\y 8 Seconds\d - %i Cash", get_pcvar_num( p_Godmode ) );
- formatex( Gravity, 63, "Gravity -\y 10 Seconds\d - %i Cash", get_pcvar_num( p_Gravity ) );
- formatex( Stealth, 63, "Stealth -\y 10 Seconds\d - %i Cash", get_pcvar_num( p_Stealth ) );
- new gMenu = menu_create( gTitle, "subPowers" );
- menu_additem( gMenu, Godmode, "0", 0 );
- menu_additem( gMenu, Gravity, "1", 0 );
- menu_additem( gMenu, Stealth, "2", 0 );
- menu_display( id, gMenu );
- }
- case 4:
- {
- new SwitchTeams[ 64 ], RoundFreeday[ 64 ];
- formatex( gTitle, charsmax( gTitle ), "[\d %s \y]\w Misc Stuff Shop^n\rJB Cash:\d %d^n\yby\r %s", gPrefix, gCash[ id ], gAuthor );
- formatex( SwitchTeams, 63, "Switch Teams\d - %i Cash", get_pcvar_num( p_SwitchTeams ) );
- formatex( RoundFreeday, 63, "Freeday -\y One Round\d - %i Cash", get_pcvar_num( p_RoundFreeday ) );
- new gMenu = menu_create( gTitle, "subMisc" );
- menu_additem( gMenu, SwitchTeams, "0", 0 );
- menu_additem( gMenu, RoundFreeday, "1", 0 );
- menu_display( id, gMenu );
- }
- }
- menu_destroy( gMenu );
- return PLUGIN_HANDLED;
- }
- public subGrenades( id, gMenu, gItem )
- {
- if ( !(get_pcvar_num( p_ShopEnabled ) ) )
- {
- ColorChat(id, "The shop is currently^3 disabled^1." );
- return PLUGIN_HANDLED;
- }
- if ( gItem == MENU_EXIT )
- {
- menu_destroy( gMenu );
- return PLUGIN_HANDLED;
- }
- if ( !is_user_alive( id ) )
- {
- ColorChat( id, "You need to be ^3 Alive^1 in order to purchase^4 Grenades^1 from the shop." );
- return PLUGIN_HANDLED;
- }
- if ( cs_get_user_team( id ) != CS_TEAM_T )
- {
- ColorChat( id, "You need to be a^3 Prisoner^1 in order to purchase^4 Grenades^1 from the shop." );
- return PLUGIN_HANDLED;
- }
- if ( user_has_weapon( id, g_GrenadesCSW[ gItem ] ) )
- {
- ColorChat( id, "You already own this item." );
- return PLUGIN_HANDLED;
- }
- new gExplosive = get_pcvar_num( p_Explosive );
- new gFlashbang = get_pcvar_num( p_Flashbang );
- new gSmokegrenade = get_pcvar_num( p_Smokegrenade );
- switch ( gItem )
- {
- case 0:
- {
- if ( gCash[ id ] < gExplosive )
- {
- ColorChat( id, "Your missing^3 %i Cash^1 in order to purchase this item from the shop.", gExplosive - gCash[ id ] );
- return PLUGIN_HANDLED;
- }
- gCash[ id ] -= gExplosive
- }
- case 1:
- {
- if ( gCash[ id ] < gFlashbang )
- {
- ColorChat( id, "Your missing^3 %i Cash^1 in order to purchase this item from the shop.", gFlashbang - gCash[ id ] );
- return PLUGIN_HANDLED;
- }
- gCash[ id ] -= gFlashbang
- }
- case 2:
- {
- if ( gCash[ id ] < gSmokegrenade )
- {
- ColorChat( id, "Your missing^3 %i Cash^1 in order to purchase this item from the shop.", gSmokegrenade - gCash[ id ] );
- return PLUGIN_HANDLED;
- }
- gCash[ id ] -= gSmokegrenade
- }
- }
- ColorChat( id, "You have purchased the item^4 %s Grenade^1 from the shop.", g_GrenadesNames[ gItem ] );
- give_item( id, g_GrenadesClass[ gItem ] );
- SetCashAsMoney( id );
- menu_destroy( gMenu );
- return PLUGIN_HANDLED;
- }
- public subHealth( id )
- {
- if ( !(get_pcvar_num( p_ShopEnabled ) ) )
- {
- ColorChat(id, "The shop is currently^3 disabled^1." );
- return PLUGIN_HANDLED;
- }
- new Arg[ 128 ];
- read_args( Arg, charsmax(Arg) );
- remove_quotes( Arg );
- new gHealth = get_pcvar_num( p_Health )
- new g_Nums[ 2 ];
- g_Nums[ 0 ] = str_to_num( Arg );
- g_Nums[ 1 ] = str_to_num( Arg ) * gHealth;
- if ( !is_user_alive(id) )
- {
- ColorChat( id, "You need to be ^3 Alive^1 in order to purchase^4 Health^1 from the shop." );
- return PLUGIN_HANDLED;
- }
- if ( !is_str_num( Arg ) )
- return PLUGIN_HANDLED;
- if ( g_Nums[ 0 ] < 1 )
- {
- ColorChat( id, "The value of^3 health^1 must be greater than^4 0" );
- client_cmd(id, "messagemode _health_");
- return PLUGIN_HANDLED;
- }
- if ( g_Nums[ 0 ] > 300 )
- {
- ColorChat( id, "The value of^3 health^1 must be smaller than^4 300" );
- client_cmd(id, "messagemode _health_");
- return PLUGIN_HANDLED;
- }
- if( gCash[ id ] < g_Nums[ 1 ] )
- {
- ColorChat( id, "Your missing^3 %i Cash^1 in order to purchase^4 health^1 from the shop.", g_Nums[ 1 ] - gCash[ id ] );
- client_cmd(id, "messagemode _health_");
- return PLUGIN_HANDLED;
- }
- ColorChat( id, "You have purchased^3 %i Health^1 for^4 %i Cash^1 from the shop.", g_Nums[ 0 ], g_Nums[ 1 ] );
- set_user_health( id, get_user_health( id ) + g_Nums[ 0 ] )
- gCash[ id ] -= g_Nums[ 1 ];
- SetCashAsMoney( id );
- return PLUGIN_HANDLED;
- }
- public subArmor( id )
- {
- if ( !(get_pcvar_num( p_ShopEnabled ) ) )
- {
- ColorChat(id, "The shop is currently^3 disabled^1." );
- return PLUGIN_HANDLED;
- }
- new Arg[ 128 ];
- read_args( Arg, charsmax(Arg) );
- remove_quotes( Arg );
- new gArmor = get_pcvar_num( p_Armor )
- new g_Nums[ 2 ];
- g_Nums[ 0 ] = str_to_num( Arg );
- g_Nums[ 1 ] = str_to_num( Arg ) * gArmor;
- if ( !is_user_alive(id) )
- {
- ColorChat( id, "You need to be ^3 Alive^1 in order to purchase^4 Armor^1 from the shop." );
- return PLUGIN_HANDLED;
- }
- if ( !is_str_num( Arg ) )
- return PLUGIN_HANDLED;
- if ( g_Nums[ 0 ] < 1 )
- {
- ColorChat( id, "The value of^3 armor^1 must be greater than^4 0" );
- client_cmd(id, "messagemode _armor_");
- return PLUGIN_HANDLED;
- }
- if ( g_Nums[ 0 ] > 300 )
- {
- ColorChat( id, "The value of^3 armor^1 must be smaller than^4 300" );
- client_cmd(id, "messagemode _armor_");
- return PLUGIN_HANDLED;
- }
- if( gCash[ id ] < g_Nums[ 1 ] )
- {
- ColorChat( id, "Your missing^3 %i Cash^1 in order to purchase^4 armor^1 from the shop.", g_Nums[ 1 ] - gCash[ id ] );
- client_cmd(id, "messagemode _armor_");
- return PLUGIN_HANDLED;
- }
- ColorChat( id, "You have purchased^3 %i Armor^1 for^4 %i Cash^1 from the shop.", g_Nums[ 0 ], g_Nums[ 1 ] );
- set_user_armor( id, get_user_armor( id ) + g_Nums[ 0 ] )
- gCash[ id ] -= g_Nums[ 1 ];
- SetCashAsMoney( id );
- return PLUGIN_HANDLED;
- }
- public subPowers( id, gMenu, gItem )
- {
- if ( !(get_pcvar_num( p_ShopEnabled ) ) )
- {
- ColorChat(id, "The shop is currently^3 disabled^1." );
- return PLUGIN_HANDLED;
- }
- if ( gItem == MENU_EXIT )
- {
- menu_destroy( gMenu );
- return PLUGIN_HANDLED;
- }
- if ( !is_user_alive( id ) )
- {
- ColorChat( id, "You need to be ^3 Alive^1 in order to purchase^4 Powers^1 from the shop." );
- return PLUGIN_HANDLED;
- }
- if ( cs_get_user_team( id ) != CS_TEAM_T )
- {
- ColorChat( id, "You need to be a^3 Prisoner^1 in order to purchase^4 Powers^1 from the shop." );
- return PLUGIN_HANDLED;
- }
- new gGodmode = get_pcvar_num( p_Godmode );
- new gGravity = get_pcvar_num( p_Gravity );
- new gStealth = get_pcvar_num( p_Stealth );
- switch ( gItem )
- {
- case 0:
- {
- if ( gCash[ id ] < gGodmode )
- {
- ColorChat( id, "Your missing^3 %i Cash^1 in order to purchase this item from the shop.", gGodmode - gCash[ id ] );
- return PLUGIN_HANDLED;
- }
- if ( d_Godmode[ id ] )
- {
- ColorChat( id, "Your currently using this power." );
- return PLUGIN_HANDLED;
- }
- gCash[ id ] -= gGodmode;
- d_Godmode[ id ] = true;
- set_user_godmode( id, 1 );
- set_task( 8.0, "RemoveGodmode", id );
- }
- case 1:
- {
- if ( gCash[ id ] < gGravity )
- {
- ColorChat( id, "Your missing^3 %i Cash^1 in order to purchase this item from the shop.", gGravity - gCash[ id ] );
- return PLUGIN_HANDLED;
- }
- if ( d_Gravity[ id ] )
- {
- ColorChat( id, "Your currently using this power." );
- return PLUGIN_HANDLED;
- }
- gCash[ id ] -= gGravity;
- d_Gravity[ id ] = true;
- set_user_gravity( id, 0.5 );
- set_task( 10.0, "RemoveGravity", id );
- }
- case 2:
- {
- if ( gCash[ id ] < gStealth )
- {
- ColorChat( id, "Your missing^3 %i Cash^1 in order to purchase this item from the shop.", gStealth - gCash[ id ] );
- return PLUGIN_HANDLED;
- }
- if ( d_Stealth[ id ] )
- {
- ColorChat( id, "Your currently using this power." );
- return PLUGIN_HANDLED;
- }
- gCash[ id ] -= gStealth;
- d_Stealth[ id ] = true;
- set_user_rendering( id, kRenderFxGlowShell, 0, 0, 0, kRenderTransAlpha, 0 );
- set_task( 10.0, "RemoveStealth", id );
- }
- }
- ColorChat( id, "You have purchased the item^4 %s Seconds^1 from the shop.", g_PowersNames[ gItem ] );
- SetCashAsMoney( id );
- menu_destroy( gMenu );
- return PLUGIN_HANDLED;
- }
- public RemoveGodmode( id )
- {
- if ( !(get_pcvar_num( p_ShopEnabled ) ) )
- return PLUGIN_HANDLED;
- if ( d_Godmode[ id ] )
- {
- set_user_godmode( id, 0 );
- d_Godmode[ id ] = false;
- }
- return PLUGIN_CONTINUE;
- }
- public RemoveGravity( id )
- {
- if ( !(get_pcvar_num( p_ShopEnabled ) ) )
- return PLUGIN_HANDLED;
- if ( d_Gravity[ id ] )
- {
- set_user_gravity( id, 1.0 );
- d_Gravity[ id ] = false;
- }
- return PLUGIN_CONTINUE;
- }
- public RemoveStealth( id )
- {
- if ( !(get_pcvar_num( p_ShopEnabled ) ) )
- return PLUGIN_HANDLED;
- if ( d_Stealth[ id ] )
- {
- set_user_rendering( id, kRenderFxGlowShell, 0, 0, 0, kRenderTransAlpha, 255 );
- d_Stealth[ id ] = false;
- }
- return PLUGIN_CONTINUE;
- }
- public subMisc( id, gMenu, gItem )
- {
- if ( !(get_pcvar_num( p_ShopEnabled ) ) )
- {
- ColorChat(id, "The shop is currently^3 disabled^1." );
- return PLUGIN_HANDLED;
- }
- if ( gItem == MENU_EXIT )
- {
- menu_destroy( gMenu );
- return PLUGIN_HANDLED;
- }
- if ( !is_user_alive( id ) )
- {
- ColorChat( id, "You need to be ^3 Alive^1 in order to purchase^4 Misc^1 from the shop." );
- return PLUGIN_HANDLED;
- }
- if ( cs_get_user_team( id ) != CS_TEAM_T )
- {
- ColorChat( id, "You need to be a^3 Prisoner^1 in order to purchase^4 Misc^1 from the shop." );
- return PLUGIN_HANDLED;
- }
- new gSwitchTeams = get_pcvar_num( p_SwitchTeams );
- new gRoundFreeday = get_pcvar_num( p_RoundFreeday );
- switch ( gItem )
- {
- case 0:
- {
- if ( gCash[ id ] < gSwitchTeams )
- {
- ColorChat( id, "Your missing^3 %i Cash^1 in order to purchase this item from the shop.", gSwitchTeams - gCash[ id ] );
- return PLUGIN_HANDLED;
- }
- gCash[ id ] -= gSwitchTeams;
- cs_set_user_team( id, CS_TEAM_CT );
- ExecuteHamB( Ham_CS_RoundRespawn, id )
- }
- case 1:
- {
- if ( gCash[ id ] < gRoundFreeday )
- {
- ColorChat( id, "Your missing^3 %i Cash^1 in order to purchase this item from the shop.", gRoundFreeday - gCash[ id ] );
- return PLUGIN_HANDLED;
- }
- gCash[ id ] -= gRoundFreeday;
- set_user_rendering( id, kRenderFxGlowShell, 0, 250, 0, kRenderNormal, 255 )
- }
- }
- new szName[ 32 ]; get_user_name( id, szName, 31 );
- ColorChat( 0, "^4%s^1 have purchased the item^4 %s^1 from the shop.", szName, g_MiscStuffNames[ gItem ] );
- set_hudmessage( 0, 160, 0, 0.1, 0.55, 1, 6.0, 6.0 );
- show_hudmessage( 0, "%s have purchased the item^n%s from the shop.", szName, g_MiscStuffNames[ gItem ] );
- SetCashAsMoney( id );
- menu_destroy( gMenu );
- return PLUGIN_HANDLED;
- }
- stock ColorChat( const id, const string[], any:... )
- {
- new msg[ 191 ], players[ 32 ], count = 1, gPrefix[ 16 ];
- get_pcvar_string( p_Prefix, gPrefix, 15 );
- static len; len = formatex( msg, charsmax( msg ), "^3[^4 %s ^3]^1 ", gPrefix );
- vformat( msg[ len ], charsmax( msg ) - len, string, 3 );
- if( id ) players[ 0 ] = id;
- else get_players( players,count,"ch" );
- for ( new i = 0; i < count; i++ )
- {
- if( is_user_connected( players[ i ] ) )
- {
- message_begin( MSG_ONE_UNRELIABLE, get_user_msgid( "SayText" ), _, players[ i ] );
- write_byte( players[ i ] );
- write_string( msg );
- message_end( );
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment