Advertisement
Swit_Cj

[FS] Velocimetro

Jul 29th, 2014
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.78 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #define Loop(%0,%1) for(new %0 = 0; %0 < %1; %0++)
  4.  
  5. enum td
  6. {
  7.     Text:TDSpeedClock[15]
  8. }
  9.  
  10. new TextDraws[td];
  11. new PlayerText:TextDrawsd[MAX_PLAYERS][4];
  12.  
  13. public OnFilterScriptInit()
  14. {
  15.     TextDraws[TDSpeedClock][0] = TextDrawCreate(496.000000,400.000000,"~p~20");
  16.     TextDraws[TDSpeedClock][1] = TextDrawCreate(487.000000,388.000000,"~p~40");
  17.     TextDraws[TDSpeedClock][2] = TextDrawCreate(483.000000,375.000000,"~p~60");
  18.     TextDraws[TDSpeedClock][3] = TextDrawCreate(488.000000,362.000000,"~p~80");
  19.     TextDraws[TDSpeedClock][4] = TextDrawCreate(491.000000,349.000000,"~b~100");
  20.     TextDraws[TDSpeedClock][5] = TextDrawCreate(508.000000,336.500000,"~b~120");
  21.     TextDraws[TDSpeedClock][6] = TextDrawCreate(536.000000,332.000000,"~b~140");
  22.     TextDraws[TDSpeedClock][7] = TextDrawCreate(567.000000,337.000000,"~b~160");
  23.     TextDraws[TDSpeedClock][8] = TextDrawCreate(584.000000,348.000000,"~b~180");
  24.     TextDraws[TDSpeedClock][9] = TextDrawCreate(595.000000,360.000000,"~g~200");
  25.     TextDraws[TDSpeedClock][10] = TextDrawCreate(603.000000,374.000000,"~g~220");
  26.     TextDraws[TDSpeedClock][11] = TextDrawCreate(594.000000,386.000000,"~g~240");
  27.     TextDraws[TDSpeedClock][14] = TextDrawCreate(585.000000,399.000000,"~r~260");
  28.     TextDraws[TDSpeedClock][12] = TextDrawCreate(534.000000,396.000000,"~p~/ ~p~\\");
  29.     TextDrawLetterSize(TextDraws[TDSpeedClock][12], 1.059999, 2.100000);
  30.     TextDraws[TDSpeedClock][13] = TextDrawCreate(548.000000,401.000000,".");
  31.  
  32.     TextDrawLetterSize(TextDraws[TDSpeedClock][12], 1.059999, 2.100000);
  33.     TextDrawLetterSize(TextDraws[TDSpeedClock][13], 0.73, -2.60);
  34.     TextDrawSetOutline(TextDraws[TDSpeedClock][13], 0);
  35.     TextDrawSetShadow(TextDraws[TDSpeedClock][13], 1);
  36.     TextDrawSetShadow(TextDraws[TDSpeedClock][14], 0);
  37.  
  38.     Loop(o, 13)
  39.     {
  40.         TextDrawSetShadow(TextDraws[TDSpeedClock][o], 0);
  41.     }
  42.     return 1;
  43. }
  44.  
  45.  
  46. public OnPlayerStateChange(playerid, newstate, oldstate)
  47. {
  48.     if(newstate == PLAYER_STATE_DRIVER)
  49.     {
  50.         Loop(o, 15)
  51.         {
  52.             TextDrawShowForPlayer(playerid, TextDraws[TDSpeedClock][o]);
  53.         }
  54.         Loop(o, 4)
  55.         {
  56.             TextDrawsd[playerid][o] = CreatePlayerTextDraw(playerid, 555.0, 402.0, "~b~|");
  57.         }
  58.     }
  59.     if(oldstate == PLAYER_STATE_DRIVER)
  60.     {
  61.         Loop(o, 4)
  62.         {
  63.             PlayerTextDrawHide(playerid, TextDrawsd[playerid][o]);
  64.             PlayerTextDrawDestroy(playerid, TextDrawsd[playerid][o]);
  65.             TextDrawsd[playerid][o] = PlayerText:INVALID_TEXT_DRAW;
  66.         }
  67.         Loop(o, 15)
  68.         {
  69.             TextDrawHideForPlayer(playerid, TextDraws[TDSpeedClock][o]);
  70.         }
  71.     }
  72.     return 1;
  73. }
  74.  
  75.  
  76. public OnPlayerUpdate(playerid)
  77. {
  78.     new Float:fPos[3], Float:Pos[4][2], Float:fSpeed;
  79.     // Velo2
  80.     if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
  81.     {
  82.         GetVehicleVelocity(GetPlayerVehicleID(playerid), fPos[0], fPos[1], fPos[2]);
  83.  
  84.         fSpeed = floatsqroot(floatpower(fPos[0], 2) + floatpower(fPos[1], 2) + floatpower(fPos[2], 2)) * 200;
  85.  
  86.         new Float:alpha = 320 - fSpeed;
  87.  
  88.         Loop(o, 4)
  89.         {
  90.             PlayerTextDrawHide(playerid, TextDrawsd[playerid][o]);
  91.             PlayerTextDrawDestroy(playerid, TextDrawsd[playerid][o]);
  92.             TextDrawsd[playerid][o] = PlayerText:INVALID_TEXT_DRAW;
  93.  
  94.             GetDotXY(548, 401, Pos[o][0], Pos[o][1], alpha, (o + 1) * 8);
  95.             TextDrawsd[playerid][o] = CreatePlayerTextDraw(playerid, Pos[o][0], Pos[o][1], "~b~.");
  96.  
  97.             PlayerTextDrawLetterSize(playerid, TextDrawsd[playerid][o], 0.73, -2.60);
  98.             PlayerTextDrawSetOutline(playerid, TextDrawsd[playerid][o], 0);
  99.             PlayerTextDrawSetShadow(playerid, TextDrawsd[playerid][o], 1);
  100.  
  101.             PlayerTextDrawShow(playerid, TextDrawsd[playerid][o]);
  102.         }
  103.     }
  104.     return 1;
  105. }
  106.  
  107. stock GetDotXY(Float:StartPosX, Float:StartPosY, &Float:NewX, &Float:NewY, Float:alpha, Float:dist)
  108. {
  109.          NewX = StartPosX + (dist * floatsin(alpha, degrees));
  110.          NewY = StartPosY + (dist * floatcos(alpha, degrees));
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement