Advertisement
LinkiNPark

speedometer

Feb 3rd, 2013
533
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.27 KB | None | 0 0
  1. #include a_samp
  2.  
  3. new
  4.     Float: L_Pos[ 7 ],
  5.      Text: mysp [ 14 ],
  6.      Text: player_text [ MAX_PLAYERS ] ;
  7.  
  8. public OnFilterScriptInit()
  9. {
  10.     new
  11.         count_ [ 14 ] = { 0, 20, ... }, format_ [ 4 ],
  12.         color_red, color_green, Float: color_text = 100 ;
  13.     for ( new i ; i != 14 ; ++ i )
  14.     {
  15.         L_Pos[ 3 ] = 320 - L_Pos [ 2 ] ;
  16.         L_Pos [ 0 ] = 79.5 + ( 65.0 * floatsin ( L_Pos[ 3 ], degrees ) ),
  17.             L_Pos [ 1 ] = 380.0 + ( 55.0 * floatcos ( L_Pos[ 3 ] , degrees ) ) ;
  18.         format ( format_, 4, "%i", count_[ i ] ) ;
  19.         mysp [ i ] = TextDrawCreate ( L_Pos [ 0 ], L_Pos [ 1 ], format_ ) ;
  20.         TextDrawAlignment ( mysp[ i ],0 ),
  21.         color_red = floatround ( ( 100 - color_text ) * 2.55 ), color_green = floatround ( color_text * 2.55 ) ;
  22.         TextDrawColor ( mysp[ i ], ( color_red * 0x1000000 ) + ( color_green * 0x10000 ) + 0xFF ) ;
  23.         TextDrawSetOutline ( mysp [ i ], 1 ),
  24.         TextDrawBackgroundColor ( mysp [ i ], 0x00000001 ),
  25.         TextDrawSetProportional ( mysp [ i ], 1 ),
  26.         TextDrawSetShadow ( mysp[ i ], 0 ),
  27.         TextDrawFont ( mysp[ i ], 2 ) ,
  28.         TextDrawLetterSize ( mysp[ i ], 0.3, 1.1 ) ;
  29.         L_Pos [ 2 ] += 20.0, color_text -= 7.14 ;
  30.     }
  31.     print("--- Speedometer by: LINKINPARK ---");
  32.     return 1;
  33. }
  34. public OnFilterScriptExit()
  35. {
  36.     for ( new i ; i != 14 ; ++ i )
  37.         TextDrawDestroy ( mysp [ i ] ) ;
  38.     return 1;
  39. }
  40. public OnPlayerConnect ( playerid )
  41. {
  42.     player_text [ playerid ] = TextDrawCreate( 0.0, 0.0, "." ) ;
  43.     return 1 ;
  44. }
  45. public OnPlayerDisconnect ( playerid, reason )
  46. {
  47.     TextDrawDestroy ( player_text [ playerid ] ) ;
  48.     return 1 ;
  49. }
  50. public OnPlayerStateChange(playerid, newstate, oldstate)
  51. {
  52.     if ( newstate == PLAYER_STATE_DRIVER )
  53.         for ( new i; i != 14 ; ++ i )
  54.             TextDrawShowForPlayer ( playerid, mysp [ i ] ) ;
  55.     else
  56.     {
  57.         for ( new i ; i != 14 ; ++ i )
  58.             TextDrawHideForPlayer ( playerid, mysp [i ] ) ;
  59.         TextDrawHideForPlayer ( playerid, player_text [ playerid ] ) ;
  60.     }
  61.     return 1;
  62. }
  63. public OnPlayerUpdate(playerid)
  64. {
  65.     if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER )
  66.     {
  67.         GetVehicleVelocity ( GetPlayerVehicleID ( playerid ), L_Pos [ 0 ], L_Pos [ 1 ], L_Pos [ 2 ] ) ;
  68.         L_Pos [ 4 ] = floatsqroot ( floatpower( L_Pos [ 0 ], 2 ) + floatpower ( L_Pos [ 1 ], 2 ) +
  69.             floatpower ( L_Pos [ 2 ], 2 ) ) * 180 ;
  70.         L_Pos[ 6 ] = 320 - L_Pos [ 4 ] ;
  71.         if( L_Pos[ 6 ] < 50 ) L_Pos[ 6 ] = 50 ;
  72.         TextDrawHideForPlayer ( playerid, player_text [ playerid ] ), TextDrawDestroy ( player_text [ playerid ] ) ;
  73.         L_Pos [ 4 ] = 83.5 + ( 55.0 * floatsin ( L_Pos[ 6 ], degrees ) ),
  74.             L_Pos [ 5 ] = 360.0 + (45.0 * floatcos ( L_Pos[ 6 ] , degrees ) ) ;
  75.         player_text [ playerid ] = TextDrawCreate( L_Pos [ 4 ], L_Pos [ 5 ], "." ) ;
  76.         TextDrawFont ( player_text [ playerid ], 1 ) ;
  77.         TextDrawLetterSize ( player_text [ playerid ], 0.890000, 3.299999 ) ;
  78.         TextDrawColor ( player_text [ playerid ], 0xF87C21AA ) ;
  79.         TextDrawSetOutline ( player_text [ playerid ], 0 ) ;
  80.         TextDrawSetShadow ( player_text [ playerid ], 0);
  81.         TextDrawShowForPlayer ( playerid, player_text [ playerid ] ) ;
  82.     }
  83.     return 1;
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement