Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //------------------------------------------------------------------//
- // EPILEPSY WARNING!!!!! //
- // This code contains flashing visual effects that may //
- // trigger symptoms of an epileptic seizure in sensitive //
- // users. Please exercise caution if you are sensitive //
- // to flashing lights. //
- //------------------------------------------------------------------//
- //-------------------- Includes --------------------//
- #include < amxmodx >
- //-------------------- Defines --------------------//
- #define Prefix "AMXX"
- #define ADMIN_ACCESS ADMIN_IMMUNITY
- //-------------------- Effect list --------------------//
- enum _:EffectInfo { effectname[ 64 ], effectid[ 66 ] }
- new Effectlist[][ EffectInfo ] =
- {
- { "NORMAL", "m" }, // normal
- { "UNDERWATER LIGHT MUTATION", "UNDERWATER LIGHT MUTATION" }, // UNDERWATER LIGHT MUTATION
- { "GENTLE PULSE 1", "jklmnopqrstuvwxyzyxwvutsrqponmlkj" }, // GENTLE PULSE 1
- { "SLOW STROBE", "aaaaaaaazzzzzzzz" }, // SLOW STROBE (fourth variety)
- { "FAST STROBE", "mamamamamama" }, // FAST STROBE
- { "SLOW STRONG PULSE", "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba" }, // SLOW STRONG PULSE
- { "SLOW PULSE NOT FADE TO BLACK", "abcdefghijklmnopqrrqponmlkjihgfedcba" }, // SLOW PULSE NOT FADE TO BLACK
- { "FLICKER #1", "mmnmmommommnonmmonqnmmo" }, // FLICKER (first variety)
- { "FLICKER #2", "nmonqnmomnmomomno" }, // FLICKER (second variety)
- { "FLUORESCENT FLICKER", "mmamammmmammamamaaamammma" }, // FLUORESCENT FLICKER
- { "CANDLE #1", "mmmmmaaaaammmmmaaaaaabcdefgabcdefg" }, // CANDLE (first variety)
- { "CANDLE #2", "mmmaaaabcdefgmmmmaaaammmaamm" }, // CANDLE (second variety)
- { "CANDLE #3", "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa" } // CANDLE (third variety)
- }
- //-------------------- Functions --------------------//
- new bool: letterprecentage = false, bool: specialeffect = false, bool: typemenu[ 33 ]
- new Lights[ 33 ][ 26 ], SLights[ 33 ], page[ 33 ], RememberPlayer[ 33 ]
- //-------------------- Plugin init --------------------//
- public plugin_init()
- {
- register_plugin( "Advanced Brightness", "v1.0", "RanAway`" )
- //-------------------- Commands --------------------//
- register_clcmd( "say /brightness", "BrightnessMenu" )
- register_clcmd( "nightvision", "BrightnessMenu" )
- }
- //-------------------- Authorized --------------------//
- public client_authorized( id ) Lights[ id ][ 0 ] = 'm', SLights[ id ] = 0
- //-------------------- Brightness menu --------------------//
- public BrightnessMenu( id )
- {
- new item[ 200 ], output[ 90 ]
- //-------------------- Organize the menu --------------------//
- if( SLights[ id ] != 0 )
- formatex( output, charsmax( output ), Effectlist[ SLights[ id ] ][ effectname ] )
- else
- get_brightness_string( Lights[ id ][ 0 ], output )
- formatex( item, charsmax( item ), "\r[\w %s \r]\w Brightness adjuster", Prefix )
- new menu = menu_create( item, "sub_brightness" )
- menu_additem( menu, "Light", _, .callback = menu_makecallback( "blockmenu" ) )
- menu_additem( menu, "Dark", _, .callback = menu_makecallback( "blockmenu" ) )
- menu_additem( menu, "Normal^n", _, .callback = menu_makecallback( "blockmenu" ) )
- menu_additem( menu, "Custom \r+", _, .callback = menu_makecallback( "blockmenu" ) )
- menu_additem( menu, "Custom \r-^n", _, .callback = menu_makecallback( "blockmenu" ) )
- formatex( item, charsmax( item ), "%sSpecial effects", SLights[ id ] != 0 ? "\y" : "\d" )
- menu_additem( menu, item, _, .callback = menu_makecallback( "blockmenu" ) )
- menu_additem( menu, "Admin options^n", _, ADMIN_ACCESS )
- formatex( item, charsmax( item ), "\r<<< %s%s \r>>>", SLights[ id ] != 0 ? "\y" : "\d", output )
- menu_addtext( menu, item, 0 )
- menu_display( id, menu )
- return 1
- }
- public blockmenu( id, menu, item )
- {
- if( ( item == 0 && ( SLights[ id ] == 0 && Lights[ id ][ 0 ] == 'z' ) )
- || ( item == 1 && ( SLights[ id ] == 0 && Lights[ id ][ 0 ] == 'a' ) )
- || ( item == 2 && ( SLights[ id ] == 0 && Lights[ id ][ 0 ] == 'm' ) )
- || ( item == 3 && ( SLights[ id ] != 0 || Lights[ id ][ 0 ] == 'z' ) )
- || ( item == 4 && ( SLights[ id ] != 0 || Lights[ id ][ 0 ] == 'a' ) )
- || ( item == 5 && specialeffect == false ) )
- return ITEM_DISABLED
- return 1
- }
- public sub_brightness( id, menu, item )
- {
- if( item == MENU_EXIT ) return menu_destroy( menu )
- if( item == 0 ) Lights[ id ][ 0 ] = 'z', SLights[ id ] = 0
- if( item == 1 ) Lights[ id ][ 0 ] = 'a', SLights[ id ] = 0
- if( item == 2 ) Lights[ id ][ 0 ] = 'm', SLights[ id ] = 0
- if( item == 3 ) if( Lights[ id ][ 0 ]++ > 'z' ) Lights[ id ][ 0 ] = 'z'
- if( item == 4 ) if( Lights[ id ][ 0 ]-- < 'a' ) Lights[ id ][ 0 ] = 'a'
- if( item == 5 )
- {
- //-------------------- Make sure the light set right --------------------//
- if( SLights[ id ]++ >= charsmax( Effectlist ) )
- {
- SLights[ id ] = 0
- set_light( id, Lights[ id ][ 0 ] )
- }
- else set_light( id, Effectlist[ SLights[ id ] ][ effectid ] )
- return BrightnessMenu( id )
- }
- if( item == 6 ) return AdminOptions( id )
- set_light( id, Lights[ id ][ 0 ] )
- return BrightnessMenu( id )
- }
- //-------------------- Admin options menu --------------------//
- public AdminOptions( id )
- {
- //-------------------- Access to the menu & prevent heap low --------------------//
- if( !( get_user_flags( id ) & ADMIN_ACCESS ) || !is_user_connected( id ) ) return 0
- new item[ 300 ], warning[ 200 ]
- add( warning, charsmax( warning ), "\d^n----------------- \rEPILEPSY WARNING!!!!!!!! \d------------------^n" )
- add( warning, charsmax( warning ), "\r-\y Flashing effects ahead; may cause seizures.^n" )
- add( warning, charsmax( warning ), "\r-\y Sensitive users should exercise caution.^n" )
- formatex( item, charsmax( item ), "\r[\w %s \r]\w Admin options", Prefix )
- new menu = menu_create( item, "sub_adminoptions" )
- menu_additem( menu, "select player", _, .callback = menu_makecallback( "blockselect" ) )
- menu_additem( menu, "Change for all^n" )
- formatex( item, charsmax( item ), "\r<<< \w%s \r>>>^n%s", letterprecentage ? "Letters" : "Precentage", warning )
- menu_additem( menu, item )
- formatex( item, charsmax( item ), "Special effects: %s", specialeffect ? "\ractivated" : "\ydeactivated" )
- menu_additem( menu, item )
- menu_setprop( menu, MPROP_EXITNAME, "back" )
- menu_display( id, menu )
- return 1
- }
- public blockselect( id, menu, item )
- {
- //-------------------- block the button "select player" if there is no one ( not include you ) online --------------------//
- new playercounter = 0
- for( new i = 1; i <= get_maxplayers(); i++ )
- {
- //-------------------- If the player is not connected or yourself --------------------//
- if( !is_user_connected( i ) || i == id ) continue
- playercounter++
- }
- if( playercounter == 0 ) return ITEM_DISABLED
- return 1
- }
- public sub_adminoptions( id, menu, item )
- {
- //-------------------- Access to the menu --------------------//
- if( !( get_user_flags( id ) & ADMIN_ACCESS ) ) return 0
- if( item == MENU_EXIT ) return BrightnessMenu( id )
- if( item == 0 ) return typemenu[ id ] = true, page[ id ] = 0, selectplayer( id )
- if( item == 1 ) return typemenu[ id ] = false, adminbrightness( id )
- if( item == 2 ) letterprecentage = !letterprecentage
- if( item == 3 ) specialeffect = !specialeffect
- return AdminOptions( id )
- }
- //-------------------- selecting menu --------------------//
- public selectplayer( id )
- {
- //-------------------- Access to the menu & prevent heap low --------------------//
- if( !( get_user_flags( id ) & ADMIN_ACCESS ) || !is_user_connected( id ) ) return 0
- new item[ 200 ], data[ 6 ]
- formatex( item, charsmax( item ), "\r[\w %s \r]\w select player", Prefix )
- new menu = menu_create( item, "sub_chooseplayer" )
- for( new i = 1; i <= get_maxplayers(); i++ )
- {
- //-------------------- If the player is not connected or yourself --------------------//
- if( !is_user_connected( i ) || i == id ) continue
- num_to_str( i, data, charsmax( data ) )
- menu_additem( menu, GetName( i ), data )
- }
- //-------------------- Previous / Next / Exit --------------------//
- if( menu_items( menu ) > 7 )
- {
- menu_setprop( menu, MPROP_NEXTNAME, "next page" )
- menu_setprop( menu, MPROP_BACKNAME, "previous page" )
- }
- menu_setprop( menu, MPROP_EXITNAME, "back" )
- menu_display( id, menu, page[ id ] )
- return 1
- }
- public sub_chooseplayer( id, menu, item )
- {
- //-------------------- Access to the menu --------------------//
- if( !( get_user_flags( id ) & ADMIN_ACCESS ) ) return 0
- if( item == MENU_EXIT ) return AdminOptions( id )
- //-------------------- Get player info --------------------//
- new access, data[ 6 ], name[ 32 ]
- menu_item_getinfo( menu, item, access, data, charsmax( data ), name, charsmax( name ), access )
- player_menu_info( id, menu, menu, page[ id ] )
- //-------------------- Remember player's data --------------------//
- RememberPlayer[ id ] = str_to_num( data )
- //-------------------- If the player is not connected --------------------//
- if( !is_user_connected( RememberPlayer[ id ] ) ) return selectplayer( id )
- return adminbrightness( id )
- }
- //-------------------- Admin brightness menu --------------------//
- public adminbrightness( id )
- {
- //-------------------- Access to the menu & prevent heap low --------------------//
- if( !( get_user_flags( id ) & ADMIN_ACCESS ) || !is_user_connected( id ) ) return 0
- new item[ 200 ], output[ 90 ], text[ 33 ], player = typemenu[ id ] ? RememberPlayer[ id ] : id
- //-------------------- Organize the menu --------------------//
- if( typemenu[ id ] )
- formatex( text, charsmax( text ), "%s", GetName( player ) )
- else
- formatex( text, charsmax( text ), "everyone" )
- if( SLights[ player ] != 0 || specialeffect == false )
- formatex( output, charsmax( output ), Effectlist[ SLights[ player ] ][ effectname ] )
- else
- get_brightness_string( Lights[ player ][ 0 ], output )
- formatex( item, charsmax( item ), "\r[\w %s \r]\w Brightness adjuster for: \r%s", Prefix, text )
- new menu = menu_create( item, "sub_adminbrightness" )
- menu_additem( menu, "Light", _, .callback = menu_makecallback( "blockadminmenu" ) )
- menu_additem( menu, "Dark", _, .callback = menu_makecallback( "blockadminmenu" ) )
- menu_additem( menu, "Normal^n", _, .callback = menu_makecallback( "blockadminmenu" ) )
- menu_additem( menu, "Custom \r+", _, .callback = menu_makecallback( "blockadminmenu" ) )
- menu_additem( menu, "Custom \r-^n", _, .callback = menu_makecallback( "blockadminmenu" ) )
- formatex( item, charsmax( item ), "%sSpecial effects^n", SLights[ id ] != 0 ? "\y" : "\d" )
- menu_additem( menu, item, _, .callback = menu_makecallback( "blockadminmenu" ) )
- formatex( item, charsmax( item ), "\r<<< %s%s \r>>>", SLights[ id ] != 0 ? "\y" : "\d", output )
- menu_addtext( menu, item )
- menu_setprop( menu, MPROP_EXITNAME, "back" )
- menu_display( id, menu )
- return 1
- }
- public blockadminmenu( id, menu, item )
- {
- new player = typemenu[ id ] ? RememberPlayer[ id ] : id
- if( ( item == 0 && ( SLights[ player ] == 0 && Lights[ player ][ 0 ] == 'z' ) )
- || ( item == 1 && ( SLights[ player ] == 0 && Lights[ player ][ 0 ] == 'a' ) )
- || ( item == 2 && ( SLights[ player ] == 0 && Lights[ player ][ 0 ] == 'm' ) )
- || ( item == 3 && ( SLights[ player ] != 0 || Lights[ player ][ 0 ] == 'z' ) )
- || ( item == 4 && ( SLights[ player ] != 0 || Lights[ player ][ 0 ] == 'a' ) )
- || ( item == 5 && specialeffect == false ) )
- return ITEM_DISABLED
- return 1
- }
- public sub_adminbrightness( id, menu, item )
- {
- //-------------------- Access to the menu --------------------//
- if( !( get_user_flags( id ) & ADMIN_ACCESS ) ) return 0
- if( item == MENU_EXIT ) return typemenu[ id ] ? selectplayer( id ) : AdminOptions( id )
- new player = typemenu[ id ] ? RememberPlayer[ id ] : id
- if( item == 0 ) Lights[ player ][ 0 ] = 'z', SLights[ player ] = 0
- if( item == 1 ) Lights[ player ][ 0 ] = 'a', SLights[ player ] = 0
- if( item == 2 ) Lights[ player ][ 0 ] = 'm', SLights[ player ] = 0
- if( item == 3 ) if( Lights[ player ][ 0 ]++ > 'z' ) Lights[ player ][ 0 ] = 'z'
- if( item == 4 ) if( Lights[ player ][ 0 ]-- < 'a' ) Lights[ player ][ 0 ] = 'a'
- if( item == 5 )
- {
- //-------------------- Make sure the light set right - everyone --------------------//
- if( !typemenu[ id ] )
- {
- SLights[ player ]++
- for( new i = 1; i <= get_maxplayers(); i++ )
- {
- if( !is_user_connected( i ) ) continue
- if( SLights[ player ] >= charsmax( Effectlist ) )
- {
- SLights[ player ] = 0
- set_light( i, Lights[ player ][ 0 ] )
- }
- else SLights[ i ] = SLights[ player ], set_light( i, Effectlist[ SLights[ player ] ][ effectid ] )
- }
- }
- //-------------------- Make sure the light set right - selected player --------------------//
- else
- {
- if( SLights[ player ]++ >= charsmax( Effectlist ) )
- {
- SLights[ player ] = 0
- set_light( player, Lights[ player ][ 0 ] )
- }
- else set_light( player, Effectlist[ SLights[ player ] ][ effectid ] )
- }
- return adminbrightness( id )
- }
- if( !typemenu[ id ] )
- {
- for( new i = 1; i <= get_maxplayers(); i++ )
- {
- if( !is_user_connected( i ) ) continue
- Lights[ i ][ 0 ] = Lights[ player ][ 0 ]
- set_light( i, Lights[ player ][ 0 ] )
- }
- }
- else set_light( player, Lights[ player ][ 0 ] )
- return adminbrightness( id )
- }
- //-------------------- Stocks --------------------//
- GetName( id )
- {
- new name[ 33 ]
- get_user_name( id, name, charsmax( name ) )
- return name
- }
- stock get_brightness_string( input, output[] )
- {
- new multiplier = 100, pos = 0
- for( new i = 0; i < 26; i++ )
- {
- //------------- letters --------------//
- if( letterprecentage )
- {
- if( i == input - 'a' )
- pos += formatex( output[ pos ], 90 - pos, "\y%c\d", 'a' + i )
- else
- pos += formatex( output[ pos ], 90 - pos, "%c", 'a' + i )
- }
- //------------- precentage --------------//
- else
- {
- if( i == input - 'a' )
- {
- pos = formatex( output[ pos ], 90 - pos, "\y%d%%\d", ( ( input - 'a' ) * multiplier ) / 25 )
- break
- }
- }
- }
- output[ pos ] = EOS
- }
- stock set_light( id, const light[] )
- {
- message_begin( MSG_ONE_UNRELIABLE, SVC_LIGHTSTYLE, .player = id )
- write_byte( 0 )
- write_string( light )
- message_end()
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement