Advertisement
Guest User

Untitled

a guest
Sep 20th, 2010
602
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.94 KB | None | 0 0
  1. #include a_samp
  2. #define DRIFT_MINKAT 10.0
  3. #define DRIFT_MAXKAT 90.0
  4. #define COLOR_LIGHTRED 0xFF0000FF
  5. #define COLOR_LIGHTBLUE 0x33CCFFAA
  6. #define DRIFT_SPEED 30.0
  7. #pragma tabsize 0
  8. #pragma unused GetPlayerTheoreticAngle
  9. new Float:ppos[200][3];
  10. enum Float:Pos{ Float:sX,Float:sY,Float:sZ };
  11. new Float:SavedPos[MAX_PLAYERS][Pos];
  12. new DriftPointsNow[200];
  13. new PunktyDriftuGracza[200];
  14. new Text:DriftTD[200];
  15. forward LicznikDriftu();
  16. forward clock();
  17. forward PodsumowanieDriftu(playerid);
  18. public OnFilterScriptInit(){
  19. for(new x=0;x<200;x++){
  20.  
  21. DriftTD[x] = TextDrawCreate(42.000000, 304.000000, " ");
  22. TextDrawBackgroundColor(DriftTD[x], 255);
  23. TextDrawFont(DriftTD[x], 1);
  24. TextDrawLetterSize(DriftTD[x], 0.480000, 3.000000);
  25. TextDrawColor(DriftTD[x], -1);
  26. TextDrawSetOutline(DriftTD[x], 0);
  27. TextDrawSetProportional(DriftTD[x], 1);
  28. TextDrawSetShadow(DriftTD[x], 1);
  29. }
  30. SetTimer("AngleUpdate" , 700, true);
  31. SetTimer("LicznikDriftu", 500, true);
  32. return 1;
  33. }
  34. IsCar(vid)
  35. {
  36. new model = GetVehicleModel(vid);
  37. switch(model)
  38. {
  39. case 443:return 0;
  40. case 448:return 0;
  41. case 461:return 0;
  42. case 462:return 0;
  43. case 463:return 0;
  44. case 468:return 0;
  45. case 521:return 0;
  46. case 522:return 0;
  47. case 523:return 0;
  48. case 581:return 0;
  49. case 586:return 0;
  50. case 481:return 0;
  51. case 509:return 0;
  52. case 510:return 0;
  53. case 430:return 0;
  54. case 446:return 0;
  55. case 452:return 0;
  56. case 453:return 0;
  57. case 454:return 0;
  58. case 472:return 0;
  59. case 473:return 0;
  60. case 484:return 0;
  61. case 493:return 0;
  62. case 595:return 0;
  63. case 417:return 0;
  64. case 425:return 0;
  65. case 447:return 0;
  66. case 465:return 0;
  67. case 469:return 0;
  68. case 487:return 0;
  69. case 488:return 0;
  70. case 497:return 0;
  71. case 501:return 0;
  72. case 548:return 0;
  73. case 563:return 0;
  74. case 406:return 0;
  75. case 444:return 0;
  76. case 556:return 0;
  77. case 557:return 0;
  78. case 573:return 0;
  79. case 460:return 0;
  80. case 464:return 0;
  81. case 476:return 0;
  82. case 511:return 0;
  83. case 512:return 0;
  84. case 513:return 0;
  85. case 519:return 0;
  86. case 520:return 0;
  87. case 539:return 0;
  88. case 553:return 0;
  89. case 577:return 0;
  90. case 592:return 0;
  91. case 593:return 0;
  92. case 471:return 0;
  93. }
  94. return 1;
  95. }
  96. forward AngleUpdate();
  97. public AngleUpdate(){
  98. for(new g=0;g<200;g++){
  99. new Float:x, Float:y, Float:z;
  100. if(IsPlayerInAnyVehicle(g))GetVehiclePos(GetPlayerVehicleID(g), x, y, z); else GetPlayerPos(g, x, y, z);
  101. ppos[g][0] = x;
  102. ppos[g][1] = y;
  103. ppos[g][2] = z;
  104. }
  105. }
  106. Float:GetPlayerTheoreticAngle(i)
  107. {
  108. new Float:sin;
  109. new Float:dis;
  110. new Float:angle2;
  111. new Float:x,Float:y,Float:z;
  112. new Float:tmp3;
  113. new Float:tmp4;
  114. new Float:MindAngle;
  115. if(IsPlayerConnected(i)){
  116. GetPlayerPos(i,x,y,z);
  117. dis = floatsqroot(floatpower(floatabs(floatsub(x,ppos[i][0])),2)+floatpower(floatabs(floatsub(y,ppos[i][1])),2));
  118. if(IsPlayerInAnyVehicle(i))GetVehicleZAngle(GetPlayerVehicleID(i), angle2); else GetPlayerFacingAngle(i, angle2);
  119. if(x>ppos[i][0]){tmp3=x-ppos[i][0];}else{tmp3=ppos[i][0]-x;}
  120. if(y>ppos[i][1]){tmp4=y-ppos[i][1];}else{tmp4=ppos[i][1]-y;}
  121. if(ppos[i][1]>y && ppos[i][0]>x){ //1
  122. sin = asin(tmp3/dis);
  123. MindAngle = floatsub(floatsub(floatadd(sin, 90), floatmul(sin, 2)), -90.0);
  124. }
  125. if(ppos[i][1]<y && ppos[i][0]>x){ //2
  126. sin = asin(tmp3/dis);
  127. MindAngle = floatsub(floatadd(sin, 180), 180.0);
  128. }
  129. if(ppos[i][1]<y && ppos[i][0]<x){ //3
  130. sin = acos(tmp4/dis);
  131. MindAngle = floatsub(floatadd(sin, 360), floatmul(sin, 2));
  132. }
  133. if(ppos[i][1]>y && ppos[i][0]<x){ //4
  134. sin = asin(tmp3/dis);
  135. MindAngle = floatadd(sin, 180);
  136. }
  137. }
  138. if(MindAngle == 0.0){
  139. return angle2;
  140. } else
  141. return MindAngle;
  142. }
  143. public PodsumowanieDriftu(playerid){
  144. PunktyDriftuGracza[playerid] = 0;
  145.  
  146. GivePlayerMoney(playerid,DriftPointsNow[playerid]);
  147. DriftPointsNow[playerid] = 0;
  148. TextDrawSetString(DriftTD[playerid]," ");
  149. }
  150. Float:ReturnPlayerAngle(playerid){
  151. new Float:Ang;
  152. if(IsPlayerInAnyVehicle(playerid))GetVehicleZAngle(GetPlayerVehicleID(playerid), Ang); else GetPlayerFacingAngle(playerid, Ang);
  153. return Ang;
  154. }
  155. public LicznikDriftu(){
  156. new Float:Angle1, Float:Angle2, Float:BySpeed, s[256];
  157. new Float:Z;
  158. new Float:X;
  159. new Float:Y;
  160. new Float:SpeedX;
  161. for(new g=0;g<200;g++){
  162. GetPlayerPos(g, X, Y, Z);
  163. SpeedX = floatsqroot(floatadd(floatadd(floatpower(floatabs(floatsub(X,SavedPos[ g ][ sX ])),2),floatpower(floatabs(floatsub(Y,SavedPos[ g ][ sY ])),2)),floatpower(floatabs(floatsub(Z,SavedPos[ g ][ sZ ])),2)));
  164. Angle1 = ReturnPlayerAngle(g);
  165. Angle2 = GetPlayerTheoreticAngle(g);
  166. BySpeed = floatmul(SpeedX, 12);
  167. if(GetPlayerState(g) == PLAYER_STATE_DRIVER && IsCar(GetPlayerVehicleID(g)) && floatabs(floatsub(Angle1, Angle2)) > DRIFT_MINKAT && floatabs(floatsub(Angle1, Angle2)) < DRIFT_MAXKAT && BySpeed > DRIFT_SPEED){
  168. if(PunktyDriftuGracza[g] > 0)KillTimer(PunktyDriftuGracza[g]);
  169. PunktyDriftuGracza[g] = 0;
  170. DriftPointsNow[g] += floatval( floatabs(floatsub(Angle1, Angle2)) * 3 * (BySpeed*0.1) )/10;
  171. PunktyDriftuGracza[g] = SetTimerEx("PodsumowanieDriftu", 3000, 0, "d", g);
  172. }
  173. if(DriftPointsNow[g] > 0){
  174. format(s, sizeof(s), "DriftCash~y~: %d", DriftPointsNow[g]);
  175. TextDrawSetString(DriftTD[g], s);
  176. }
  177. SavedPos[ g ][ sX ] = X;
  178. SavedPos[ g ][ sY ] = Y;
  179. SavedPos[ g ][ sZ ] = Z;
  180. }
  181. }
  182. //Split(s1[], s2[], s3[]=""){new rxx[256];format(rxx, 256, "%s%s%s", s1, s2, s3);return rxx;}
  183. //tostr(int){new st[256];format(st, 256, "%d", int);return st;}
  184. floatval(Float:val){new str[256];format(str, 256, "%.0f", val);return todec(str);}
  185. todec(str[]){return strval(str);}
  186. public OnPlayerStateChange(playerid, newstate, oldstate)
  187. {
  188. if(newstate == PLAYER_STATE_DRIVER){
  189. TextDrawShowForPlayer(playerid, DriftTD[playerid]);
  190. }
  191. return 1;
  192. }
  193.  
  194.  
  195. public OnPlayerConnect(playerid)
  196. {
  197. new x;
  198. TextDrawHideForPlayer(playerid, DriftTD[x]);
  199. SendClientMessage(playerid,COLOR_LIGHTBLUE,"MONEY: Drift for money easy way to earn money Drift Counter by luby edited by kitten");
  200. return 1;
  201. }
  202.  
  203.  
  204.  
  205.  
  206. public OnPlayerCommandText(playerid, cmdtext[])
  207. {
  208. new x;
  209.  
  210. if (strcmp("/driftoff", cmdtext, true, 10) == 0)
  211. {
  212. SendClientMessage(playerid,COLOR_LIGHTBLUE,"You Have Disabled Drift Counter");
  213. TextDrawHideForPlayer(playerid, DriftTD[x]);
  214. return 1;
  215. }
  216.  
  217. if (strcmp("/drifton", cmdtext, true, 10) == 0)
  218. {
  219. SendClientMessage(playerid,COLOR_LIGHTBLUE,"You Have Enabled Drift Counter By Luby editied by kitten");
  220. TextDrawShowForPlayer(playerid, DriftTD[x]);
  221. return 1;
  222. }
  223. return 0;
  224. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement