Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //-------------------- Includes --------------------//
- #include < amxmodx >
- #include < engine >
- #include < fun >
- #include < cstrike >
- #include < hamsandwich >
- //-------------------- Defines --------------------//
- #define Prefix "AMXX"
- #define ACCESS_ADMIN ADMIN_IMMUNITY
- //-------------------- Weapons functions --------------------//
- enum WeaponsStats { weaponname[ 32 ], WeaponID[ 33 ], WeaponCSW }
- new const Weapons[][ WeaponsStats ] =
- {
- //-------------------- Assault rifles --------------------//
- { "m4a1", "weapon_m4a1", CSW_M4A1 },
- { "ak47", "weapon_ak47", CSW_AK47 },
- { "awp", "weapon_awp", CSW_AWP },
- { "m3", "weapon_m3", CSW_M3 },
- { "xm1014", "weapon_xm1014", CSW_XM1014 },
- { "tmp", "weapon_tmp", CSW_TMP },
- { "mac10", "weapon_mac10", CSW_MAC10 },
- { "mp5navy", "weapon_mp5navy", CSW_MP5NAVY },
- { "p90", "weapon_p90", CSW_P90 },
- { "ump45", "weapon_ump45", CSW_UMP45 },
- { "famas", "weapon_famas", CSW_FAMAS },
- { "galil", "weapon_galil", CSW_GALIL },
- { "sg552", "weapon_sg552", CSW_SG552 },
- { "aug", "weapon_aug", CSW_AUG },
- { "scout", "weapon_scout", CSW_SCOUT },
- { "sg550", "weapon_sg550", CSW_SG550 },
- { "g3sg1", "weapon_g3sg1", CSW_G3SG1 },
- { "m249", "weapon_m249", CSW_M249 },
- //-------------------- Pistols --------------------//
- { "glock18", "weapon_glock18", CSW_GLOCK18 },
- { "usp", "weapon_usp", CSW_USP },
- { "p228", "weapon_p228", CSW_P228 },
- { "deagle", "weapon_deagle", CSW_DEAGLE },
- { "fiveseven", "weapon_fiveseven", CSW_FIVESEVEN },
- { "elite", "weapon_elite", CSW_ELITE }
- }
- //-------------------- Functions --------------------//
- new bool:DontShowAgain[ 33 ], bool:Respawn = true, Primary[ 33 ], Secondary[ 33 ], menutype[ 33 ]
- //-------------------- Plugin init --------------------//
- public plugin_init()
- {
- register_plugin( "csdm", "v1.0", "RanAway" )
- //-------------------- Commands --------------------//
- register_clcmd( "say /guns", "guns" )
- register_clcmd( "say /turnrp", "turnrespawn" )
- //-------------------- Respawn --------------------//
- RegisterHam( Ham_Spawn, "player", "HamSpawn", 1 )
- }
- //-------------------- Authorized --------------------//
- public client_authorized( id ) Primary[ id ] = 0, Secondary[ id ] = 18, DontShowAgain[ id ] = false
- //-------------------- Respawn --------------------//
- public HamSpawn( id )
- {
- if( get_user_team( id ) == 3 || !is_user_connected( id ) || !is_user_alive( id ) ) return 1
- if( DontShowAgain[ id ] == true ) return GiveWeapon( id )
- return gunsmenu( id )
- }
- public client_PreThink( id )
- {
- if( !Respawn || get_user_team( id ) == 3 || !is_user_connected( id ) || is_user_alive( id ) ) return 1
- set_task( 1.0, "respawn", id )
- return 1
- }
- public respawn( id )
- {
- if( !Respawn || get_user_team( id ) == 3 || !is_user_connected( id ) || is_user_alive( id ) ) return 1
- if( DontShowAgain[ id ] == true ) ColorChat( id, "You'r menu now ^3disabled^1. to ^3enable^1 the menu type ^3/guns^1." )
- return DispatchSpawn( id )
- }
- public turnrespawn( id )
- {
- if( ~get_user_flags( id ) & ACCESS_ADMIN ) return 0
- Respawn ^= true
- return ColorChat( 0, "Admin: ^3%n^1 has ^3%sactivated^1 the respawn.", id, Respawn ? "" : "de" )
- }
- //-------------------- Guns menu --------------------//
- public guns( id )
- {
- DontShowAgain[ id ] ^= true
- return ColorChat( id, "Your guns menu is now ^3%sabled^1.", DontShowAgain[ id ] ? "dis" : "en" )
- }
- public gunsmenu( id )
- {
- new menu = menu_create( fmt( "\r[\w %s \r] \wcsdm menu", Prefix ), "sub_gunsmenu" )
- menu_additem( menu, "Choose weapon" )
- menu_additem( menu, "Choose again" )
- menu_additem( menu, "Dont show again" )
- menu_display( id, menu )
- return 1
- }
- public sub_gunsmenu( id, menu, item )
- {
- if( item == MENU_EXIT ) return menu_destroy( menu )
- if( item == 0 ) return menutype[ id ] = true, chooseweapon( id )
- if( item == 2 )
- {
- DontShowAgain[ id ] = true
- ColorChat( id, "To ^3enable^1 the menu type^3/guns^1." )
- }
- return GiveWeapon( id )
- }
- //-------------------- Choose weapon --------------------//
- public chooseweapon( id )
- {
- new menu = menu_create( fmt( "\r[\w %s \r]\w Choose %s", Prefix, menutype[ id ] ? "primary" : "secondary" ), "sub_weapon" )
- for( new i = menutype[ id ] ? 0 : 18; i < sizeof( Weapons ) - ( menutype[ id ] ? 6 : 0 ); i++ ) menu_additem( menu, Weapons[ i ][ weaponname ] )
- menu_display( id, menu )
- return 1
- }
- public sub_weapon( id, menu, item )
- {
- if( item == MENU_EXIT ) return gunsmenu( id )
- if( menutype[ id ] )
- {
- Primary[ id ] = item
- menutype[ id ] = false
- return chooseweapon( id )
- }
- Secondary[ id ] = item + 18
- return GiveWeapon( id )
- }
- //-------------------- Give weapon --------------------//
- public GiveWeapon( id )
- {
- //-------------------- Strip --------------------//
- strip_user_weapons( id )
- //-------------------- Give knife and grenades --------------------//
- give_item( id, "weapon_knife" )
- give_item( id, "weapon_smokegrenade" )
- give_item( id, "weapon_hegrenade" )
- give_item( id, "weapon_flashbang" )
- //-------------------- Give orimary and secondary --------------------//
- give_item( id, Weapons[ Primary[ id ] ][ WeaponID ] )
- give_item( id, Weapons[ Secondary[ id ] ][ WeaponID ] )
- cs_set_user_bpammo( id, Weapons[ Primary[ id ] ][ WeaponCSW ], 9000 )
- cs_set_user_bpammo( id, Weapons[ Secondary[ id ] ][ WeaponCSW ], 900 )
- return 1
- }
- //-------------------- Stocks - ColorChat --------------------//
- stock ColorChat( id, const string[], any:... )
- {
- new msg[ 191 ], players[ 32 ], count = 1
- new len = formatex( msg, charsmax( msg ), "^3[^1 %s ^3]^1 ", Prefix )
- 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()
- }
- }
- return 1
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement