Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /************* includes ***************/
- #include < amxmodx >
- #include < fakemeta >
- /************* defines ***************/
- #define Prefix "AMXX"
- /************* news ***************/
- new showspeed[ 33 ], speedcolor[ 33 ][ 4 ], Float:speedpos[ 33 ][ 3 ]
- /************* plugin init ************/
- public plugin_init()
- {
- register_plugin( "speedometer", "v1.0", "RanAway" )
- /************* commands ************/
- register_clcmd( "say /speed", "speedometermenu" )
- /************* show speed hud ************/
- set_task( 0.1, "speedometer", 0, _, _, "b" )
- }
- /************* connect ************/
- public client_connect( id )
- {
- /************* speed hud status ************/
- showspeed[ id ] = true
- /************* speed hud color ************/
- speedcolor[ id ][ 1 ] = 85
- speedcolor[ id ][ 2 ] = 85
- speedcolor[ id ][ 3 ] = 85
- /************* speed hud position ************/
- speedpos[ id ][ 1 ] = 0.47
- speedpos[ id ][ 2 ] = 0.80
- }
- /************* speedometer menu ***********/
- public speedometermenu( id )
- {
- new item[ 250 ]
- formatex( item, charsmax( item ), "\r[\w %s \r]\w speed o meter menu", Prefix )
- new menu = menu_create( item, "sub_speedometermenu" )
- formatex( item, charsmax( item ), "status: %sactivated^n", showspeed[ id ] ? "\y" : "\rde" )
- menu_additem( menu, item )
- menu_additem( menu, "change colors" )
- menu_additem( menu, "change position" )
- menu_addtext( menu, "^n\d----------\r details\d -----------" )
- formatex( item, charsmax( item ), "\wcolors: \y|\r R: \y%i \y|\r G: \y%i \y|\r B: \y%i", speedcolor[ id ][ 1 ], speedcolor[ id ][ 2 ], speedcolor[ id ][ 3 ] )
- menu_addtext( menu, item )
- formatex( item, charsmax( item ), "\wposition: \y|\r X: \y%.2f \y|\r Y: \y%.2f", speedpos[ id ][ 1 ], speedpos[ id ][ 2 ] )
- menu_addtext( menu, item )
- menu_display( id, menu )
- return 1
- }
- public sub_speedometermenu( id, menu, item )
- {
- if( item == MENU_EXIT ) return menu_destroy( menu )
- /************* de / activate speed hud ***********/
- if( item == 0 ) showspeed[ id ] = !showspeed[ id ]
- if( item == 1 ) return colorsmenu( id )
- if( item == 2 ) return positionmenu( id )
- return speedometermenu( id )
- }
- /************* position menu ***********/
- public positionmenu( id )
- {
- new item[ 250 ]
- formatex( item, charsmax( item ), "\r[\w %s \r]\w position menu", Prefix )
- new menu = menu_create( item, "sub_positionmenu" )
- menu_additem( menu, "move left \r<<<<<<",_, .callback = menu_makecallback( "blockposition" ) )
- menu_additem( menu, "move right \r>>>>>>^n",_, .callback = menu_makecallback( "blockposition" ) )
- menu_additem( menu, "move up \r^^^^^^^^^^^^ ",_, .callback = menu_makecallback( "blockposition" ) )
- menu_additem( menu, "move down \rvvvvvv^n",_, .callback = menu_makecallback( "blockposition" ) )
- formatex( item, charsmax( item ), "\wposition: \y|\r X: \y%.2f \y|\r Y: \y%.2f", speedpos[ id ][ 1 ], speedpos[ id ][ 2 ] )
- menu_addtext( menu, item )
- menu_setprop( menu, MPROP_EXITNAME, "back to menu" )
- menu_display( id, menu )
- return 1
- }
- public sub_positionmenu( id, menu, item )
- {
- if( item == MENU_EXIT ) return speedometermenu( id )
- /************* change X position ***********/
- if( item == 0 && speedpos[ id ][ 1 ] > 0.01 ) speedpos[ id ][ 1 ] -= 0.01
- if( item == 1 && speedpos[ id ][ 1 ] < 1.00 ) speedpos[ id ][ 1 ] += 0.01
- /************* change Y position ***********/
- if( item == 2 && speedpos[ id ][ 2 ] > 0.01 ) speedpos[ id ][ 2 ] -= 0.01
- if( item == 3 && speedpos[ id ][ 2 ] < 1.00 ) speedpos[ id ][ 2 ] += 0.01
- return positionmenu( id )
- }
- /************* block positions ***********/
- public blockposition( id, menu, item )
- {
- /************* X position ***********/
- if( item == 0 && speedpos[ id ][ 1 ] <= 0.01 ) return ITEM_DISABLED
- if( item == 1 && speedpos[ id ][ 1 ] >= 1.00 ) return ITEM_DISABLED
- /************* Y position ***********/
- if( item == 2 && speedpos[ id ][ 2 ] <= 0.01 ) return ITEM_DISABLED
- if( item == 3 && speedpos[ id ][ 2 ] >= 1.00 ) return ITEM_DISABLED
- return 1
- }
- /************* colors menu ***********/
- public colorsmenu( id )
- {
- new item[ 250 ]
- formatex( item, charsmax( item ), "\r[\w %s \r]\w colors menu", Prefix )
- new menu = menu_create( item, "sub_colorsmenu" )
- menu_additem( menu, "R \y-\r ++",_, .callback = menu_makecallback( "blockcolors" ) )
- menu_additem( menu, "R \y-\r --^n",_, .callback = menu_makecallback( "blockcolors" ) )
- menu_additem( menu, "G \y-\r ++",_, .callback = menu_makecallback( "blockcolors" ) )
- menu_additem( menu, "G \y-\r --^n",_, .callback = menu_makecallback( "blockcolors" ) )
- menu_additem( menu, "B \y-\r ++",_, .callback = menu_makecallback( "blockcolors" ) )
- menu_additem( menu, "B \y-\r --^n",_, .callback = menu_makecallback( "blockcolors" ) )
- formatex( item, charsmax( item ), "\wcolors: \y|\r R: \y%i \y|\r G: \y%i \y|\r B: \y%i", speedcolor[ id ][ 1 ], speedcolor[ id ][ 2 ], speedcolor[ id ][ 3 ] )
- menu_addtext( menu, item )
- menu_setprop( menu, MPROP_EXITNAME, "back to menu" )
- menu_display( id, menu )
- return 1
- }
- public sub_colorsmenu( id, menu, item )
- {
- if( item == MENU_EXIT ) return speedometermenu( id )
- /************* change R position ***********/
- if( item == 0 && speedcolor[ id ][ 1 ] < 255 ) speedcolor[ id ][ 1 ] += 5
- if( item == 1 && speedcolor[ id ][ 1 ] > 0 ) speedcolor[ id ][ 1 ] -= 5
- /************* change G position ***********/
- if( item == 2 && speedcolor[ id ][ 2 ] < 255 ) speedcolor[ id ][ 2 ] += 5
- if( item == 3 && speedcolor[ id ][ 2 ] > 0 ) speedcolor[ id ][ 2 ] -= 5
- /************* change B position ***********/
- if( item == 4 && speedcolor[ id ][ 3 ] < 255 ) speedcolor[ id ][ 3 ] += 5
- if( item == 5 && speedcolor[ id ][ 3 ] > 0 ) speedcolor[ id ][ 3 ] -= 5
- return colorsmenu( id )
- }
- /************* block colors ***********/
- public blockcolors( id, menu, item )
- {
- /************* change R position ***********/
- if( item == 0 && speedcolor[ id ][ 1 ] >= 255 ) return ITEM_DISABLED
- if( item == 1 && speedcolor[ id ][ 1 ] <= 0 ) return ITEM_DISABLED
- /************* change G position ***********/
- if( item == 2 && speedcolor[ id ][ 2 ] >= 255 ) return ITEM_DISABLED
- if( item == 3 && speedcolor[ id ][ 2 ] <= 0 ) return ITEM_DISABLED
- /************* change B position ***********/
- if( item == 4 && speedcolor[ id ][ 3 ] >= 255 ) return ITEM_DISABLED
- if( item == 5 && speedcolor[ id ][ 3 ] <= 0 ) return ITEM_DISABLED
- return 1
- }
- /************* speedometer ***********/
- public speedometer()
- {
- new Float:speed, Float:speedf, Float:velocity[ 3 ]
- for( new i; i < get_maxplayers(); i++ )
- {
- if( !is_user_connected( i ) || !is_user_alive( i ) || !showspeed[ i ] ) continue
- pev( i, pev_velocity, velocity )
- speed = vector_length( velocity )
- speedf = floatsqroot( floatpower( velocity[ 0 ], 2.0 ) + floatpower( velocity[ 1 ], 2.0 ) )
- set_hudmessage( speedcolor[ i ][ 1 ], speedcolor[ i ][ 2 ], speedcolor[ i ][ 3 ], speedpos[ i ][ 1 ], speedpos[ i ][ 2 ], 0, 0.0, 0.1, 0.01, 0.0 )
- ShowSyncHudMsg( i, CreateHudSyncObj(), "velocity: %3.2f", speed, speedf )
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement