Advertisement
LinkiNPark

classic_speedom

Oct 15th, 2012
1,202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.76 KB | None | 0 0
  1. #include a_samp
  2. #define L_MAX_COUNT 105
  3. new
  4.     L_count[ ][ ] = {
  5.         "0", "20", "40", "60", "80", "100", "120",
  6.         "140", "160", "180", "200", "220"
  7.     },
  8.     Text: L_draw_speed[ 14 ],
  9.     Text: L_player_draw[ MAX_PLAYERS ],
  10.     Float: L_speed_update[ 4 ],
  11.     L_text_update[ 155 ] ;
  12.  
  13. public OnFilterScriptInit ( )
  14. {
  15.     SetTimer ( "SpeedUpdate", 50, false ) ;
  16.     L_draw_speed[ 0 ] = TextDrawCreate ( 190, 400.0, L_count[ 0 ] ) ;
  17.     L_speed_update[ 0 ] = 210 ;
  18.     for ( new i ; i != 12 ; ++ i )
  19.     {
  20.         if ( i ) L_draw_speed[ i ] = TextDrawCreate ( L_speed_update[ 0 ], 400.0, L_count[ i ] ), L_speed_update[ 0 ] += 30.0 ;
  21.         TextDrawColor ( L_draw_speed[ i ], 0xDEDDDC55 ), TextDrawAlignment ( L_draw_speed[ i ], 0 ) ;
  22.         TextDrawBackgroundColor ( L_draw_speed[ i ],0x00000011 ), TextDrawSetOutline ( L_draw_speed[ i ], 1 ) ;
  23.         TextDrawSetProportional ( L_draw_speed[ i ], 1 ), TextDrawSetShadow ( L_draw_speed[ i ], 1 ) ;
  24.         TextDrawFont ( L_draw_speed[ i ], 2 ), TextDrawLetterSize ( L_draw_speed[ i ], 0.3, 1.1 ) ;
  25.     }
  26.     L_speed_update[ 0 ] = 408.0 ;
  27.     for ( new i = 12 ; i != 14; ++ i )
  28.     L_draw_speed[ i ] = TextDrawCreate ( 130.0, L_speed_update[ 0 ], "-" ),
  29.     TextDrawColor ( L_draw_speed[ i ], 0xDEDDDCFF ), TextDrawAlignment ( L_draw_speed[ i ], 0 ),
  30.     TextDrawBackgroundColor ( L_draw_speed[ i ], 0x00000022 ), TextDrawSetOutline ( L_draw_speed[ i ], 1 ),
  31.     TextDrawSetProportional ( L_draw_speed[ i ] , 1 ), TextDrawSetShadow ( L_draw_speed[ i ], 1 ),
  32.     TextDrawFont ( L_draw_speed[ i ], 1 ), TextDrawLetterSize ( L_draw_speed[ i ], 43.0, 0.8 ), L_speed_update[ 0 ] -= 13.0 ;
  33.     return 1;
  34. }
  35. public OnFilterScriptExit ( )
  36. {
  37.     for ( new i = 0x0 ; i != sizeof L_draw_speed ; ++ i )
  38.         TextDrawDestroy ( L_draw_speed[ i ] ) ;
  39.     return 1 ;
  40. }
  41. public OnPlayerConnect ( playerid )
  42. {
  43.     L_player_draw[ playerid ] = TextDrawCreate( 190.0, 377.0, "-" ), TextDrawAlignment ( L_player_draw[playerid], 0 ) ;
  44.     TextDrawBackgroundColor ( L_player_draw[ playerid ],0x00000022 ), TextDrawSetOutline ( L_player_draw[playerid], 1 ) ;
  45.     TextDrawSetProportional ( L_player_draw[ playerid ], 1 ), TextDrawSetShadow ( L_player_draw[ playerid ], 1 ) ;
  46.     TextDrawFont ( L_player_draw[ playerid ], 2 ), TextDrawLetterSize( L_player_draw[ playerid ], 0.3, 5.5 ) ;
  47.     return 1 ;
  48. }
  49. public OnPlayerDisconnect ( playerid, reason )
  50. {
  51.     TextDrawDestroy( L_player_draw[playerid] ) ;
  52.     return 1 ;
  53. }
  54. public OnPlayerStateChange ( playerid, newstate, oldstate )
  55. {
  56.     if ( newstate == 2 )
  57.     {
  58.         for ( new i = 0x0; i != 14; i ++ ) TextDrawShowForPlayer ( playerid, L_draw_speed[ i ] ) ;
  59.         TextDrawShowForPlayer ( playerid, L_player_draw[ playerid ] ) ;
  60.     }
  61.     else
  62.     {
  63.         for ( new i = 0x0; i != 14; ++ i ) TextDrawHideForPlayer ( playerid, L_draw_speed[ i ] ) ;
  64.         TextDrawHideForPlayer( playerid, L_player_draw[ playerid ] ) ;
  65.     }
  66.     return 1 ;
  67. }
  68. forward SpeedUpdate ( ) ;
  69. public SpeedUpdate ( )
  70. {
  71.     for ( new i = 0 ; i != MAX_PLAYERS ; i++ )
  72.     {
  73.         if ( !IsPlayerConnected( i ) ) continue;
  74.         if ( GetPlayerState( i ) != 2 ) continue;
  75.         GetVehicleVelocity ( GetPlayerVehicleID( i ),L_speed_update[ 0 ],L_speed_update[ 1 ],L_speed_update[ 2 ] ) ;
  76.         L_speed_update[ 3 ] = floatsqroot ( floatpower ( floatabs ( L_speed_update[ 0 ] ), 2.0 ) + floatpower ( floatabs ( L_speed_update[ 1 ] ), 2.0 ) + floatpower ( floatabs ( L_speed_update[ 2 ] ), 2.0 ) ) * 179.28625 ;
  77.         L_Update_Text( i, floatround ( L_speed_update[ 3 ] * 0.4 ) ) ;
  78.     }
  79.     SetTimer ( "SpeedUpdate", 50, false ) ;
  80.     return 1;
  81. }
  82. L_Update_Text ( i, count )
  83. {
  84.     new L_index_count[ 150 ] = { ' ', ... } ;
  85.     if ( count < L_MAX_COUNT - 1 ) L_index_count[ count ] = '-' ;
  86.         else L_index_count[ L_MAX_COUNT - 1 ] = '-' ;
  87.     L_text_update[ 0 ] = EOS ;
  88.     format ( L_text_update, 155, "%s", L_index_count ) ;
  89.     TextDrawSetString ( L_player_draw[ i ], L_text_update ) ;
  90. }
  91. //by LinkiNPark
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement