Advertisement
RanAway

[ Pawn - small plugins ] csdm

Oct 5th, 2020 (edited)
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.05 KB | None | 0 0
  1. //-------------------- Includes --------------------//
  2. #include < amxmodx >
  3. #include < engine >
  4. #include < fun >
  5. #include < cstrike >
  6. #include < hamsandwich >
  7.  
  8. //-------------------- Defines --------------------//
  9. #define Prefix              "AMXX"
  10. #define ACCESS_ADMIN        ADMIN_IMMUNITY
  11.  
  12. //-------------------- Weapons functions --------------------//
  13. enum WeaponsStats { weaponname[ 32 ], WeaponID[ 33 ], WeaponCSW }
  14.  
  15. new const Weapons[][ WeaponsStats ] =
  16. {
  17.     //-------------------- Assault rifles --------------------//
  18.     {   "m4a1",         "weapon_m4a1",      CSW_M4A1        },
  19.     {   "ak47",         "weapon_ak47",      CSW_AK47        },
  20.     {   "awp",          "weapon_awp",       CSW_AWP         },
  21.     {   "m3",           "weapon_m3",        CSW_M3          },
  22.     {   "xm1014",       "weapon_xm1014",    CSW_XM1014      },
  23.     {   "tmp",          "weapon_tmp",       CSW_TMP         },
  24.     {   "mac10",        "weapon_mac10",     CSW_MAC10       },
  25.     {   "mp5navy",      "weapon_mp5navy",   CSW_MP5NAVY     },
  26.     {   "p90",          "weapon_p90",       CSW_P90         },
  27.     {   "ump45",        "weapon_ump45",     CSW_UMP45       },
  28.     {   "famas",        "weapon_famas",     CSW_FAMAS       },
  29.     {   "galil",        "weapon_galil",     CSW_GALIL       },
  30.     {   "sg552",        "weapon_sg552",     CSW_SG552       },
  31.     {   "aug",          "weapon_aug",       CSW_AUG         },
  32.     {   "scout",        "weapon_scout",     CSW_SCOUT       },
  33.     {   "sg550",        "weapon_sg550",     CSW_SG550       },
  34.     {   "g3sg1",        "weapon_g3sg1",     CSW_G3SG1       },
  35.     {   "m249",         "weapon_m249",      CSW_M249        },
  36.     //-------------------- Pistols --------------------//  
  37.     {   "glock18",      "weapon_glock18",   CSW_GLOCK18     },
  38.     {   "usp",          "weapon_usp",       CSW_USP         },
  39.     {   "p228",         "weapon_p228",      CSW_P228        },
  40.     {   "deagle",       "weapon_deagle",    CSW_DEAGLE      },
  41.     {   "fiveseven",    "weapon_fiveseven", CSW_FIVESEVEN   },
  42.     {   "elite",        "weapon_elite",     CSW_ELITE       }
  43. }
  44.  
  45. //-------------------- Functions --------------------//
  46. new bool:DontShowAgain[ 33 ], bool:Respawn = true, Primary[ 33 ], Secondary[ 33 ], menutype[ 33 ]
  47.  
  48. //-------------------- Plugin init --------------------//
  49. public plugin_init()
  50. {
  51.     register_plugin( "csdm", "v1.0", "RanAway" )
  52.  
  53.     //-------------------- Commands --------------------//
  54.     register_clcmd( "say /guns", "guns" )
  55.     register_clcmd( "say /turnrp", "turnrespawn" )
  56.  
  57.     //-------------------- Respawn --------------------//
  58.     RegisterHam( Ham_Spawn, "player", "HamSpawn", 1 )
  59. }
  60.  
  61. //-------------------- Authorized --------------------//
  62. public client_authorized( id ) Primary[ id ] = 0, Secondary[ id ] = 18, DontShowAgain[ id ] = false
  63.  
  64. //-------------------- Respawn --------------------//
  65. public HamSpawn( id )
  66. {
  67.     if( get_user_team( id ) == 3 || !is_user_connected( id ) || !is_user_alive( id ) ) return 1
  68.  
  69.     if( DontShowAgain[ id ] == true ) return GiveWeapon( id )
  70.  
  71.     return gunsmenu( id )
  72. }
  73.  
  74. public client_PreThink( id )
  75. {
  76.     if( !Respawn || get_user_team( id ) == 3 || !is_user_connected( id ) || is_user_alive( id ) ) return 1
  77.    
  78.     set_task( 1.0, "respawn", id )
  79.     return 1
  80. }
  81.  
  82. public respawn( id )
  83. {
  84.     if( !Respawn || get_user_team( id ) == 3 || !is_user_connected( id ) || is_user_alive( id ) ) return 1
  85.  
  86.     if( DontShowAgain[ id ] == true ) ColorChat( id, "You'r menu now ^3disabled^1. to ^3enable^1 the menu type ^3/guns^1." )
  87.  
  88.     return DispatchSpawn( id )
  89. }
  90.  
  91. public turnrespawn( id )
  92. {
  93.     if( ~get_user_flags( id ) & ACCESS_ADMIN ) return 0
  94.  
  95.     Respawn ^= true
  96.     return ColorChat( 0, "Admin: ^3%n^1 has ^3%sactivated^1 the respawn.", id, Respawn ? "" : "de" )
  97. }
  98.  
  99. //-------------------- Guns menu --------------------//
  100. public guns( id )
  101. {
  102.     DontShowAgain[ id ] ^= true
  103.     return ColorChat( id, "Your guns menu is now ^3%sabled^1.", DontShowAgain[ id ] ? "dis" : "en" )
  104. }
  105.  
  106. public gunsmenu( id )
  107. {
  108.     new menu = menu_create( fmt( "\r[\w %s \r] \wcsdm menu", Prefix ), "sub_gunsmenu" )
  109.  
  110.     menu_additem( menu, "Choose weapon" )
  111.     menu_additem( menu, "Choose again" )
  112.     menu_additem( menu, "Dont show again" )
  113.  
  114.     menu_display( id, menu )
  115.     return 1
  116. }
  117.  
  118. public sub_gunsmenu( id, menu, item )
  119. {
  120.     if( item == MENU_EXIT ) return menu_destroy( menu )
  121.  
  122.     if( item == 0 ) return menutype[ id ] = true, chooseweapon( id )
  123.     if( item == 2 )
  124.     {
  125.         DontShowAgain[ id ] = true
  126.         ColorChat( id, "To ^3enable^1 the menu type^3/guns^1." )
  127.     }
  128.     return GiveWeapon( id )
  129. }
  130.  
  131. //-------------------- Choose weapon --------------------//
  132. public chooseweapon( id )
  133. {
  134.     new menu = menu_create( fmt( "\r[\w %s \r]\w Choose %s", Prefix, menutype[ id ] ? "primary" : "secondary" ), "sub_weapon" )
  135.  
  136.     for( new i = menutype[ id ] ? 0 : 18; i < sizeof( Weapons ) - ( menutype[ id ] ? 6 : 0 ); i++ ) menu_additem( menu, Weapons[ i ][ weaponname ] )
  137.  
  138.     menu_display( id, menu )
  139.     return 1
  140. }
  141.  
  142. public sub_weapon( id, menu, item )
  143. {
  144.     if( item == MENU_EXIT ) return gunsmenu( id )
  145.  
  146.     if( menutype[ id ] )
  147.     {
  148.         Primary[ id ] = item
  149.         menutype[ id ] = false
  150.         return chooseweapon( id )
  151.     }
  152.  
  153.     Secondary[ id ] = item + 18
  154.     return GiveWeapon( id )
  155. }
  156.  
  157. //-------------------- Give weapon --------------------//
  158. public GiveWeapon( id )
  159. {
  160.     //-------------------- Strip --------------------//
  161.     strip_user_weapons( id )
  162.  
  163.     //-------------------- Give knife and grenades --------------------//
  164.     give_item( id, "weapon_knife" )
  165.     give_item( id, "weapon_smokegrenade" )
  166.     give_item( id, "weapon_hegrenade" )
  167.     give_item( id, "weapon_flashbang" )
  168.  
  169.     //-------------------- Give orimary and secondary --------------------//
  170.     give_item( id, Weapons[ Primary[ id ] ][ WeaponID ] )
  171.     give_item( id, Weapons[ Secondary[ id ] ][ WeaponID ] )
  172.  
  173.     cs_set_user_bpammo( id, Weapons[ Primary[ id ] ][ WeaponCSW ], 9000 )
  174.     cs_set_user_bpammo( id, Weapons[ Secondary[ id ] ][ WeaponCSW ], 900 )
  175.     return 1
  176. }
  177.  
  178. //-------------------- Stocks - ColorChat --------------------//
  179. stock ColorChat( id, const string[], any:... )
  180. {
  181.     new msg[ 191 ], players[ 32 ], count = 1
  182.  
  183.     new len = formatex( msg, charsmax( msg ), "^3[^1 %s ^3]^1 ", Prefix )
  184.     vformat( msg[ len ], charsmax( msg ) - len, string, 3 )
  185.  
  186.     if( id )
  187.         players[ 0 ] = id
  188.     else
  189.         get_players( players, count, "ch" )
  190.  
  191.     for( new i = 0; i < count; i++ )
  192.     {
  193.         if( is_user_connected( players[ i ] ) )
  194.         {
  195.             message_begin( MSG_ONE_UNRELIABLE, get_user_msgid( "SayText" ), _, players[ i ] )
  196.             write_byte( players[ i ] )
  197.             write_string( msg )
  198.             message_end()
  199.         }
  200.     }
  201.     return 1
  202. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement