Advertisement
Frost12

Speedo Meter 2

Sep 12th, 2015
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.39 KB | None | 0 0
  1. #include <a_samp>
  2. Frost
  3. {
  4. Text:TDSpeedClock[15]
  5. }
  6.  
  7. new TextDraws[td];
  8. new Text:TextDrawsd[MAX_PLAYERS][4];
  9. new DeActiveSpeedometer[MAX_PLAYERS];
  10.  
  11. public OnFilterScriptInit()
  12. {
  13. print("Clock Speedometer load");
  14.  
  15. TextDraws[TDSpeedClock][0] = TextDrawCreate(496.000000,400.000000,"~g~20");
  16. TextDraws[TDSpeedClock][1] = TextDrawCreate(487.000000,388.000000,"~g~40");
  17. TextDraws[TDSpeedClock][2] = TextDrawCreate(483.000000,375.000000,"~g~60");
  18. TextDraws[TDSpeedClock][3] = TextDrawCreate(488.000000,362.000000,"~g~80");
  19. TextDraws[TDSpeedClock][4] = TextDrawCreate(491.000000,349.000000,"~g~100");
  20. TextDraws[TDSpeedClock][5] = TextDrawCreate(508.000000,336.500000,"~g~120");
  21. TextDraws[TDSpeedClock][6] = TextDrawCreate(536.000000,332.000000,"~g~140");
  22. TextDraws[TDSpeedClock][7] = TextDrawCreate(567.000000,337.000000,"~g~160");
  23. TextDraws[TDSpeedClock][8] = TextDrawCreate(584.000000,348.000000,"~g~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][12] = TextDrawCreate(585.000000,399.000000,"~g~260");
  28. TextDraws[TDSpeedClock][13] = TextDrawCreate(534.000000,396.000000,"~r~/ \\");
  29. TextDraws[TDSpeedClock][14] = TextDrawCreate(548.000000,401.000000,".");
  30. TextDrawLetterSize(TextDraws[TDSpeedClock][13], 1.059999, 2.100000);
  31. TextDrawLetterSize(TextDraws[TDSpeedClock][14], 0.73, -2.60);
  32. for(new i; i < 15; i++)
  33. {
  34. TextDrawSetShadow(TextDraws[TDSpeedClock][i], 1);
  35. TextDrawSetOutline(TextDraws[TDSpeedClock][i], 0);
  36. }
  37.  
  38.  
  39. return 1;
  40. }
  41.  
  42. public OnFilterScriptExit()
  43. {
  44. print("Clock Speedometer unload");
  45.  
  46. return 1;
  47. }
  48.  
  49. public OnPlayerCommandText(playerid, cmdtext[])
  50. {
  51. if(strcmp(cmdtext[1], "speedo", false) == 0)
  52. {
  53. new strOptionInfo[2][37]=
  54. {
  55. "You have turned on your speedometer",
  56. "You have turned off your speedometer"
  57. };
  58.  
  59. DeActiveSpeedometer[playerid] = !DeActiveSpeedometer[playerid];
  60. SendClientMessage(playerid, 0x00AA00FF, strOptionInfo[DeActiveSpeedometer[playerid]]);
  61. if(!DeActiveSpeedometer[playerid])
  62. {
  63. for(new i; i < 15; i++)
  64. TextDrawShowForPlayer(playerid, TextDraws[TDSpeedClock][i]);
  65.  
  66. for(new i; i < 4; i++)
  67. TextDrawsd[playerid][i] = TextDrawCreate(555.0, 402.0, "~b~.");
  68. }
  69. else
  70. {
  71. for(new i; i < 4; i++)
  72. TextDrawHideForPlayer(playerid, TextDrawsd[playerid][i]);
  73. for(new i; i < 15; i++)
  74. TextDrawHideForPlayer(playerid, TextDraws[TDSpeedClock][i]);
  75. }
  76.  
  77. return 1;
  78. }
  79.  
  80. return 0;
  81. }
  82.  
  83. public OnPlayerStateChange(playerid, newstate, oldstate)
  84. {
  85. if(newstate == PLAYER_STATE_DRIVER && !DeActiveSpeedometer[playerid])
  86. {
  87. for(new i; i < 15; i++)
  88. TextDrawShowForPlayer(playerid, TextDraws[TDSpeedClock][i]);
  89.  
  90. for(new i; i < 4; i++)
  91. TextDrawsd[playerid][i] = TextDrawCreate(555.0, 402.0, "~b~.");
  92.  
  93. }
  94. else
  95. {
  96. for(new i; i < 4; i++)
  97. TextDrawHideForPlayer(playerid, TextDrawsd[playerid][i]);
  98. for(new i; i < 15; i++)
  99. TextDrawHideForPlayer(playerid, TextDraws[TDSpeedClock][i]);
  100. }
  101.  
  102. return 1;
  103. }
  104.  
  105. public OnPlayerUpdate(playerid)
  106. {
  107. new
  108. Float:fPos[3],
  109. Float:Pos[4][2],
  110. Float:fSpeed;
  111.  
  112. if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER && !DeActiveSpeedometer[playerid])
  113. {
  114. GetVehicleVelocity(GetPlayerVehicleID(playerid), fPos[0], fPos[1], fPos[2]);
  115.  
  116. fSpeed = floatsqroot(floatpower(fPos[0], 2) + floatpower(fPos[1], 2) +
  117. floatpower(fPos[2], 2)) * 200;
  118.  
  119. new Float:alpha = 320 - fSpeed;
  120. if(alpha < 60)
  121. alpha = 60;
  122.  
  123. for(new i; i < 4; i++)
  124. {
  125. TextDrawHideForPlayer(playerid, TextDrawsd[playerid][i]);
  126. TextDrawDestroy(TextDrawsd[playerid][i]);
  127. GetDotXY(548, 401, Pos[i][0], Pos[i][1], alpha, (i + 1) * 8);
  128. TextDrawsd[playerid][i] = TextDrawCreate(Pos[i][0], Pos[i][1], "~b~.");
  129. TextDrawLetterSize(TextDrawsd[playerid][i], 0.73, -2.60);
  130. TextDrawSetOutline(TextDrawsd[playerid][i], 0);
  131. TextDrawSetShadow(TextDrawsd[playerid][i], 1);
  132. TextDrawShowForPlayer(playerid, TextDrawsd[playerid][i]);
  133. }
  134. }
  135.  
  136.  
  137. return 1;
  138. }
  139.  
  140. stock GetDotXY(Float:StartPosX, Float:StartPosY, &Float:NewX, &Float:NewY, Float:alpha, Float:dist)
  141. {
  142. NewX = StartPosX + (dist * floatsin(alpha, degrees));
  143. NewY = StartPosY + (dist * floatcos(alpha, degrees));
  144. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement