Advertisement
RanAway

[ Pawn ] Brightness menu

May 23rd, 2022
690
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /******** Includes *********/
  2. #include < amxmodx >
  3.  
  4. /******** Defines *********/
  5. #define Prefix          "AMXX"
  6.  
  7. /******** News *********/
  8. new const Lights[][] = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "#OFF" }
  9. new BrightnessID[ 33 ]
  10.  
  11. /******** Plugin init *********/
  12. public plugin_init()
  13. {
  14.     register_plugin( "Brightness", "v1.0", "RanAway`" )
  15.    
  16.     /******** Commands *********/
  17.     register_clcmd( "say /brightness", "BrightnessMenu" )
  18. }
  19.  
  20. /******** Connect *********/
  21. public client_connect( id ) BrightnessID[ id ] = 12
  22.  
  23. /******** Menu *********/
  24. public BrightnessMenu( id )
  25. {
  26.     new szMenu[ 500 ]
  27.    
  28.     formatex( szMenu, charsmax( szMenu ), "\r[\w AMXX \r]\w Brightness ajuster", Prefix )
  29.     new menu = menu_create( szMenu, "sub_brightness" )
  30.    
  31.     menu_additem( menu, "Light" )
  32.     menu_additem( menu, "Dark" )
  33.     menu_additem( menu, "Normal^n" )
  34.    
  35.     menu_additem( menu, "Custom \r+" )
  36.     menu_additem( menu, "Custom \r-" )
  37.    
  38.     menu_display( id, menu )
  39.     return 1
  40. }
  41.  
  42. public sub_brightness( id, menu, item )
  43. {
  44.     if( item == MENU_EXIT ) return menu_destroy( menu )
  45.     if( item == 0 ) set_player_light( id, "#OFF" ), BrightnessID[ id ] = 26
  46.     if( item == 1 ) set_player_light( id, "a" ), BrightnessID[ id ] = 0
  47.     if( item == 2 ) set_player_light( id, "m"), BrightnessID[ id ] = 12
  48.     if( item == 3 )
  49.     {
  50.         if( BrightnessID[ id ] == sizeof Lights - 1 ) return BrightnessMenu( id )
  51.        
  52.         BrightnessID[ id ]++
  53.         set_player_light( id, Lights[ BrightnessID[ id ] ] )
  54.     }
  55.    
  56.     if( item == 4 )
  57.     {
  58.         if( BrightnessID[ id ] == 0 ) return BrightnessMenu( id )
  59.        
  60.         BrightnessID[ id ]--
  61.         set_player_light( id, Lights[ BrightnessID[ id ] ] )
  62.     }
  63.     return BrightnessMenu( id )
  64. }
  65.  
  66. /******** Stocks *********/
  67. stock set_player_light( id, const LightStyle[] ) // Stock by unknown
  68. {
  69.     message_begin( MSG_ONE_UNRELIABLE, SVC_LIGHTSTYLE, .player = id )
  70.     write_byte( 0 )
  71.     write_string( LightStyle )
  72.     message_end()
  73. }
Advertisement
RAW Paste Data Copied
Advertisement