Advertisement
amxDusT

acer

Jul 10th, 2023 (edited)
1,619
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.53 KB | Source Code | 0 0
  1. /*
  2.     allows only m2 in acer and removes all guns but knife.
  3. */
  4. #include < amxmodx >
  5. #include < reapi >
  6.  
  7.  
  8. new bool:bIsActive;
  9. new HookChain:fwPreThink;
  10. new pcvar;
  11. public plugin_init()
  12. {
  13.     register_plugin( "[reApi] Acer", "1.0", "DusT" );
  14.  
  15.     hook_cvar_change( pcvar = create_cvar( "km_stabacer", "1", _, "1: Stab only. 0: disabled", true, 0.0, true, 1.0 ), "@OnStabChange" );
  16. }
  17.  
  18. @OnStabChange( pcvar, const old_value[], const new_value[] )
  19. {
  20.     if( !bIsActive )    return;
  21.  
  22.     if( str_to_num( new_value ) == 1 )
  23.     {
  24.         EnableHookChain( fwPreThink );
  25.     }
  26.     else
  27.     {
  28.         DisableHookChain( fwPreThink );
  29.     }
  30. }
  31.  
  32. public plugin_cfg()
  33. {
  34.     new szMap[ 15 ];
  35.     //get_mapname( szMap, charsmax( szMap ) );
  36.     rh_get_mapname( szMap, charsmax( szMap ), MNT_TRUE );
  37.  
  38.     if( containi( szMap, "ka_acer_2" ) != -1 )
  39.     {
  40.         bIsActive = true;
  41.         if( get_pcvar_num( pcvar ) == 1 )
  42.             fwPreThink = RegisterHookChain( RG_CBasePlayer_PreThink, "fw_PlayerPreThink" );
  43.  
  44.         RegisterHookChain( RG_CBasePlayer_Spawn, "fw_Spawn_Post", true );  
  45.     }
  46. }
  47. public fw_Spawn_Post( id )
  48. {
  49.     if( !is_user_alive( id ) )  return;
  50.     rg_remove_all_items( id );
  51.     rg_give_item( id, "weapon_knife", GT_REPLACE );
  52. }
  53. public fw_PlayerPreThink( id )
  54. {
  55.     if( !is_user_alive( id ) )
  56.         return;    
  57.     static iButton;
  58.     iButton = get_entvar( id, var_button );
  59.     if( iButton & IN_ATTACK )
  60.     {
  61.         set_entvar( id, var_button, ( iButton & ~IN_ATTACK ) | IN_ATTACK2 );
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement