Advertisement
iXdoctor

Set Bind Key

May 20th, 2014
385
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.69 KB | None | 0 0
  1. /* Plugin generated by AMXX-Studio */
  2.  
  3. #include < amxmodx >
  4. #include < amxmisc >
  5.  
  6. #define MENU_PREFIX "\d[ \yAMXX\d ] "
  7. enum _: iData
  8. {
  9.     iCategory[ 33 ],
  10.     iBind[ 33 ],
  11.     iCommand[ 33 ]
  12. }
  13.  
  14. new const szKeys [ ] [ ] =
  15. {
  16.     "a", "b", "c", "d",
  17.     "e", "f", "g", "h",
  18.     "i", "j", "k", "l",
  19.     "m", "n", "o", "p",
  20.     "q", "r", "s", "t",
  21.     "u"
  22. }
  23.  
  24. new const BindsTemp [ ] [ iData ] =
  25. {
  26.     { "Bunnyhop", "Auto On/Off Bhop", "/bhop" },
  27.     { "Public", "ResetScore", "/rs" },
  28.     { "Everything", "Open Top15", "/top15" }
  29. }
  30.  
  31. new iOption[ 33 ], iKeyOption[ 33 ];
  32.  
  33. public plugin_init()
  34. {
  35.     register_plugin( "Set Key Binds", "1.0", "Xdoctor" );
  36.    
  37.     register_saycmd( "setbinds", "CmdBinds" );
  38. }
  39.  
  40. public CmdBinds( client )
  41. {
  42.     new szMenu[ 128 ];
  43.    
  44.     formatex( szMenu, charsmax( szMenu ), "%s Set Binds Menu", MENU_PREFIX );
  45.    
  46.     new Menu = menu_create( szMenu, "CmdBindsHandler" );
  47.    
  48.     formatex( szMenu, charsmax( szMenu ), "\rCategory %s\w:\y Bind\w:\y %s", BindsTemp[ iOption[ client ] ] );
  49.        
  50.     menu_additem( Menu, szMenu );
  51.        
  52.     formatex( szMenu, charsmax( szMenu ), "\rBind Key\w: \d[ \y%s\d ]", szKeys[ iKeyOption[ client ] ] );
  53.        
  54.     menu_additem( Menu, szMenu );
  55.        
  56.     menu_additem( Menu, "Activate Bind" );
  57.        
  58.     menu_display( client, Menu, 0 );
  59.    
  60.     return 1;
  61. }
  62.  
  63. public CmdBindsHandler( client, Menu, Item )
  64. {
  65.     if( Item >= MENU_EXIT )
  66.     {
  67.         menu_destroy( Menu );
  68.        
  69.         return 1;
  70.     }
  71.    
  72.     switch( Item )
  73.     {
  74.         case 0:
  75.         {
  76.            
  77.             if( iOption[ client ] >= charsmax( BindsTemp ) )
  78.                 iOption[ client ] = 0
  79.            
  80.             else
  81.                 iOption[ client ] += 1;    
  82.         }
  83.        
  84.         case 1:
  85.        
  86.         {
  87.                
  88.         if( iKeyOption[ client ] >= charsmax( szKeys ) )
  89.             iKeyOption[ client ] = 0;
  90.                
  91.         else
  92.             iKeyOption[ client ]++;
  93.         }
  94.        
  95.         case 2:
  96.        
  97.         {
  98.             ColorChat( client, "^4%s^1 Your bind^4 %s^1 is on key: ^4%s", GetUserName( client ), BindsTemp[ iOption[ client ] ][ iBind ], szKeys[ iOption[ client ] ] );
  99.            
  100.             client_cmd( client, "bind %s ^"say %s ^"", szKeys[ iOption[ client ] ], BindsTemp[ iOption[ client ] ][ iCommand ] );
  101.            
  102.             return 1;
  103.            
  104.         }      
  105.        
  106.     }
  107.        
  108.     return 1;  
  109. }
  110.    
  111. stock GetUserName( const Index )
  112. {
  113.     new szName[ 32 ];
  114.    
  115.     get_user_name( Index, szName, charsmax( szName ) );
  116.    
  117.     return szName;
  118.    
  119. }
  120.  
  121. stock register_saycmd( const cmd[], const function[], flags = -1, const info[] = "", FlagManager = -1 )
  122. {
  123.         new i, j;
  124.         new szString[ 64 ];
  125.         new const szSayTypes[ ][ ] = { "say", "say_team" };
  126.         new const szTypes[ ][ ] = { "/", "!", "." }
  127.         for( i = 0 ; i < sizeof szSayTypes ; i ++ )
  128.         {
  129.                 for( j = 0 ; j < sizeof szTypes ; j ++ )
  130.                 {
  131.                         formatex( szString, sizeof szString - 1, "%s %s%s", szSayTypes[ i ], szTypes[ j ], cmd );
  132.                         register_clcmd( szString, function, flags, info, FlagManager );
  133.            
  134.         }  
  135.     }
  136. }
  137.    
  138. stock ColorChat(const id,const string[],any:...)
  139. {
  140.         new msg[191], players[32], count = 1;
  141.         static len; len = formatex(msg,charsmax(msg),"^1[ ^4AMXX ^1] ");
  142.         vformat(msg[len],charsmax(msg) - len,string,3);
  143.        
  144.         static msgSayText;
  145.        
  146.         if (!msgSayText)
  147.                 msgSayText = get_user_msgid("SayText");
  148.        
  149.         if(id)  players[0] = id;
  150.         else    get_players(players,count,"ch");
  151.        
  152.         for (new i = 0; i < count; i++)
  153.         {
  154.                 if(is_user_connected(players[i]))
  155.                 {
  156.                         message_begin(MSG_ONE_UNRELIABLE,msgSayText,.player = players[i]);
  157.                         write_byte(players[i]); // Sender ID
  158.                         write_string(msg); // String 1
  159.                         message_end();
  160.                 }
  161.         }
  162.    
  163.     return 1;
  164. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement