Advertisement
Guest User

dc

a guest
Dec 23rd, 2013
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.79 KB | None | 0 0
  1. ////////////////////////////////////////////////////////////
  2. /////////////// DRIFT POINTS COUNTER BY Luby ///////////////
  3. /////////////// A little editted by Florinca//////////////
  4. //-Keep Credits-//
  5.  
  6. //////////////NOW NEW updated by Florinca ////////////////
  7.  
  8. ////////////////////////////////////////////////////////////
  9.  
  10. #include <a_samp>// by I dont know .. :D lol
  11.  
  12. #define DRIFT_MINKAT 10.0
  13. #define DRIFT_MAXKAT 90.0
  14. #define DRIFT_SPEED 30.0
  15. #define PATH "/Driftscore/%s.ini"
  16.  
  17. //////////// Added by Florinca///////
  18. #define COLOR_Label 0xFFFFFFFF
  19. #define COLOR_LabelOut 0x00000040
  20. #define COLOR_ValueOut 0xFFFFFF40
  21. #define COLOR_Value 0x000000FF
  22.  
  23. /////////////////////////////////////
  24.  
  25. new DriftTimer[MAX_PLAYERS]; // Added by Florinca
  26. new TimerA,TimerB,TimerC; // Added by Abhinav
  27.  
  28. new DriftPointsNow[MAX_PLAYERS]; // by Florinca
  29. new PlayerDriftCancellation[MAX_PLAYERS]; // by Luby
  30. new Float:ppos[MAX_PLAYERS][3]; // by Luby
  31. enum Float:Pos{ Float:sX,Float:sY,Float:sZ }; // by Luby
  32. new Float:SavedPos[MAX_PLAYERS][Pos]; // by Luby
  33.  
  34. new bool:DriftMode[MAX_PLAYERS]=false; // Added by Florinca
  35. new DriftBonus[MAX_PLAYERS]=1; // Added by Abhinav
  36. new Float:HealthInit[MAX_PLAYERS]=1000.0; // Added by Abhinav
  37. new bool:AutoFixBool[MAX_PLAYERS]=true; // Added by Florinca
  38.  
  39. new Text:TDLabels[3]; // Added by Abhinav
  40. new Text:TDValueDrift[MAX_PLAYERS]; // Added by Abhinav
  41. new Text:TDValueBonus[MAX_PLAYERS]; // Added by Abhinav
  42. new Text:TDValueCash[MAX_PLAYERS]; // Added by Florinca
  43.  
  44. new Text:Textdraw0;
  45.  
  46. forward Drift(); // by Florinca
  47. forward AngleUpdate(); // by Luby
  48. forward DriftExit(playerid); // by Luby
  49. forward CheckPlayerState(); // Added by Florinca
  50. forward AutoFix(); // Added by Abhinav
  51.  
  52.  
  53. public OnFilterScriptInit()
  54. {
  55. TimerA=SetTimer("AngleUpdate", 200, true); // by Luby
  56. TimerB=SetTimer("AutoFix", 500, true); //by Florinca
  57. TimerC=SetTimer("CheckPlayerState", 100, true); //by Abhinav
  58. LoadTextDraws();
  59. return 1;
  60. }
  61.  
  62. public OnFilterScriptExit()
  63. {
  64. KillTimer(TimerA);
  65. KillTimer(TimerB);
  66. KillTimer(TimerC);
  67. return 1;
  68. }
  69.  
  70. Float:GetPlayerTheoreticAngle(i) // By Luby
  71. {
  72. new Float:sin;
  73. new Float:dis;
  74. new Float:angle2;
  75. new Float:x,Float:y,Float:z;
  76. new Float:tmp3;
  77. new Float:tmp4;
  78. new Float:MindAngle;
  79.  
  80. if(IsPlayerConnected(i)){
  81.  
  82. GetPlayerPos(i,x,y,z);
  83.  
  84. dis = floatsqroot(floatpower(floatabs(floatsub(x,ppos[i][0])),2)+floatpower(floatabs(floatsub(y,ppos[i][1])),2));
  85.  
  86. if(IsPlayerInAnyVehicle(i)){GetVehicleZAngle(GetPlayerVehicleID(i), angle2);}else{GetPlayerFacingAngle(i, angle2);}
  87.  
  88. if(x>ppos[i][0]){tmp3=x-ppos[i][0];}else{tmp3=ppos[i][0]-x;}
  89. if(y>ppos[i][1]){tmp4=y-ppos[i][1];}else{tmp4=ppos[i][1]-y;}
  90.  
  91. if(ppos[i][1]>y && ppos[i][0]>x){
  92. sin = asin(tmp3/dis);
  93. MindAngle = floatsub(floatsub(floatadd(sin, 90), floatmul(sin, 2)), -90.0);
  94. }
  95.  
  96. if(ppos[i][1]<y && ppos[i][0]>x){
  97. sin = asin(tmp3/dis);
  98. MindAngle = floatsub(floatadd(sin, 180), 180.0);
  99. }
  100.  
  101. if(ppos[i][1]<y && ppos[i][0]<x){
  102. sin = acos(tmp4/dis);
  103. MindAngle = floatsub(floatadd(sin, 360), floatmul(sin, 2));
  104. }
  105.  
  106. if(ppos[i][1]>y && ppos[i][0]<x){
  107. sin = asin(tmp3/dis);
  108. MindAngle = floatadd(sin, 180);
  109. }
  110. }
  111.  
  112. if(MindAngle == 0.0){return angle2;}else{return MindAngle;}
  113. }
  114.  
  115. public DriftExit(playerid){ // By Florinca
  116. PlayerDriftCancellation[playerid] = 0;
  117.  
  118. ////////////////// by Florinca ///////////////////
  119. new Float:h;
  120. GetVehicleHealth(GetPlayerVehicleID(playerid),h);
  121. if(DriftPointsNow[playerid]>70 && DriftPointsNow[playerid]<100000 && h==HealthInit[playerid]) SetPlayerScore(playerid,DriftPointsNow[playerid]*DriftBonus[playerid]*3);
  122. TextDrawHideForPlayer(playerid,TDLabels[0]);
  123. TextDrawHideForPlayer(playerid,TDLabels[1]);
  124. TextDrawHideForPlayer(playerid,TDLabels[2]);
  125. TextDrawHideForPlayer(playerid,TDValueDrift[playerid]);
  126. TextDrawHideForPlayer(playerid,TDValueBonus[playerid]);
  127. TextDrawHideForPlayer(playerid,TDValueCash[playerid]);
  128.  
  129. TextDrawHideForPlayer(playerid,Textdraw0);//added by Jagat
  130.  
  131. DriftBonus[playerid]=1;
  132. AutoFixBool[playerid]=true;
  133. SetVehicleHealth(GetPlayerVehicleID(playerid),HealthInit[playerid]);
  134. ////////////////////////////////////////////////////
  135.  
  136. DriftPointsNow[playerid] = 0;
  137. }
  138.  
  139. Float:ReturnPlayerAngle(playerid){ // By Luby
  140. new Float:Ang;
  141. if(IsPlayerInAnyVehicle(playerid))GetVehicleZAngle(GetPlayerVehicleID(playerid), Ang); else GetPlayerFacingAngle(playerid, Ang);
  142. return Ang;
  143. }
  144.  
  145. public Drift(){ // By Florinca
  146. new Float:Angle1, Float:Angle2, Float:BySpeed;
  147. new Float:Z;
  148. new Float:X;
  149. new Float:Y;
  150. new Float:SpeedX;
  151. for(new g=0;g<200;g++){
  152. GetPlayerPos(g, X, Y, Z);
  153. 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)));
  154. Angle1 = ReturnPlayerAngle(g);
  155. Angle2 = GetPlayerTheoreticAngle(g);
  156. BySpeed = floatmul(SpeedX, 12);
  157. if(IsPlayerInAnyVehicle(g) && GetVType(GetPlayerVehicleID(g)) && floatabs(floatsub(Angle1, Angle2)) > DRIFT_MINKAT && floatabs(floatsub(Angle1, Angle2)) < DRIFT_MAXKAT && BySpeed > DRIFT_SPEED){
  158. if(PlayerDriftCancellation[g] > 0)KillTimer(PlayerDriftCancellation[g]);
  159. PlayerDriftCancellation[g] = 0;
  160. DriftPointsNow[g] += floatval( floatabs(floatsub(Angle1, Angle2)) * 4.1 * (BySpeed*0.2) )/10;
  161. PlayerDriftCancellation[g] = SetTimerEx("DriftExit", 3000, 0, "d", g);
  162. }
  163.  
  164. if(DriftPointsNow[g] > 70 && DriftPointsNow[g]<10000){
  165. ///////////// by Florinca ////////////////////
  166. if(DriftPointsNow[g]<500){
  167. DriftBonus[g]=1;
  168. }
  169. //edited all by Jagat
  170. if(DriftPointsNow[g]>=500 && DriftPointsNow[g]<700){
  171. DriftBonus[g]=2;
  172. }
  173. if(DriftPointsNow[g]>=700 && DriftPointsNow[g]<1200){
  174. DriftBonus[g]=3;
  175. }
  176. if(DriftPointsNow[g]>=1200 && DriftPointsNow[g]<1700){
  177. DriftBonus[g]=4;
  178. }
  179. if(DriftPointsNow[g]>=1700 && DriftPointsNow[g]<2500){
  180. DriftBonus[g]=5;
  181. }
  182. if(DriftPointsNow[g]>=2500 && DriftPointsNow[g]<3000){
  183. DriftBonus[g]=6;
  184. }
  185. if(DriftPointsNow[g]>=3000 && DriftPointsNow[g]<5000){
  186. DriftBonus[g]=7;
  187. }
  188. if(DriftPointsNow[g]>=5000 && DriftPointsNow[g]<7400){
  189. DriftBonus[g]=8;
  190. }
  191. if(DriftPointsNow[g]>=7400 && DriftPointsNow[g]<10000){
  192. DriftBonus[g]=9;
  193. }
  194. if(DriftPointsNow[g]>=10000 && DriftPointsNow[g]<13570){
  195. DriftBonus[g]=10;
  196. }
  197. if(DriftPointsNow[g]>=13570 && DriftPointsNow[g]<15345){
  198. DriftBonus[g]=11;
  199. }
  200. if(DriftPointsNow[g]>=17800 && DriftPointsNow[g]<19999){
  201. DriftBonus[g]=12;
  202. }
  203. if(DriftPointsNow[g]>=22085 && DriftPointsNow[g]<23467){
  204. DriftBonus[g]=13;
  205. }
  206. if(DriftPointsNow[g]>=23467 && DriftPointsNow[g]<25000){
  207. DriftBonus[g]=14;
  208. }
  209. if(DriftPointsNow[g]>=25000){
  210. DriftBonus[g]=15;
  211. }
  212.  
  213. TextDrawShowForPlayer(g,TDLabels[0]);
  214. TextDrawShowForPlayer(g,TDLabels[1]);
  215. TextDrawShowForPlayer(g,TDLabels[2]);
  216.  
  217. TextDrawShowForPlayer(g,TDValueDrift[g]);
  218. TextDrawShowForPlayer(g,TDValueBonus[g]);
  219. TextDrawShowForPlayer(g,TDValueCash[g]);
  220.  
  221. TextDrawShowForPlayer(g,Textdraw0);//added by Jagat
  222.  
  223.  
  224.  
  225. new DPs[128],DBn[128],Cash[128],csh;
  226.  
  227. valstr(DPs,DriftPointsNow[g],false);
  228. format(DBn,sizeof(DBn),"X%i",DriftBonus[g]);
  229. csh=DriftPointsNow[g]*DriftBonus[g];
  230. format(Cash,sizeof(Cash),"$%i",csh);
  231.  
  232. TextDrawSetString(TDValueDrift[g],DPs);
  233. TextDrawSetString(TDValueBonus[g],DBn);
  234. TextDrawSetString(TDValueCash[g],Cash);
  235. ////////////////////////////////////////
  236. }
  237. SavedPos[ g ][ sX ] = X;
  238. SavedPos[ g ][ sY ] = Y;
  239. SavedPos[ g ][ sZ ] = Z;
  240. }
  241. }
  242.  
  243. public AngleUpdate(){ // By Florinca
  244. for(new g=0;g<=MAX_PLAYERS;g++){
  245. new Float:x, Float:y, Float:z;
  246. if(IsPlayerInAnyVehicle(g))GetVehiclePos(GetPlayerVehicleID(g), x, y, z); else GetPlayerPos(g, x, y, z);
  247. ppos[g][0] = x;
  248. ppos[g][1] = y;
  249. ppos[g][2] = z;
  250. }
  251. }
  252.  
  253. floatval(Float:val){ // By Luby
  254. new str[256];
  255. format(str, 256, "%.0f", val);
  256. return todec(str);
  257. }
  258.  
  259. todec(str[]){ // By Luby
  260. return strval(str);
  261. }
  262.  
  263. LoadTextDraws(){// by Abhinav
  264. //edited all text draws by Jagat
  265.  
  266. Textdraw0 = TextDrawCreate(322.000000, 338.000000, "~n~");
  267. TextDrawLetterSize(Textdraw0, 1.600000, 6.359762);
  268. TextDrawSetOutline(Textdraw0, 3);
  269. TextDrawTextSize(Textdraw0, 146.000000, 4.000000);//-------------------------~|~
  270.  
  271. TDLabels[0]=TextDrawCreate(160.000000, 348.000000,"Drift Points:");
  272. TextDrawColor(TDLabels[0],0x33AA33AA);
  273. TextDrawSetShadow(TDLabels[0],0);
  274. TextDrawSetOutline(TDLabels[0],3);
  275. TextDrawLetterSize(TDLabels[0],0.36,1.123);
  276. TextDrawBackgroundColor(TDLabels[0],COLOR_LabelOut);
  277. TextDrawFont(TDLabels[0],1);
  278.  
  279.  
  280. TDLabels[1]=TextDrawCreate(160.000000, 365.000000,"Drift Bonus:");
  281. TextDrawColor(TDLabels[1],0xFF0000FF);
  282. TextDrawSetShadow(TDLabels[1],0);
  283. TextDrawSetOutline(TDLabels[1],3);
  284. TextDrawLetterSize(TDLabels[1],0.36,1.123);
  285. TextDrawBackgroundColor(TDLabels[1],COLOR_LabelOut);
  286. TextDrawFont(TDLabels[1],1);
  287.  
  288. TDLabels[2]=TextDrawCreate(160.000000, 382.000000,"Drift Cash:");
  289. TextDrawColor(TDLabels[2],0x6DC5F3FF);
  290. TextDrawSetShadow(TDLabels[2],0);
  291. TextDrawSetOutline(TDLabels[2],3);
  292. TextDrawLetterSize(TDLabels[2],0.36,1.123);
  293. TextDrawBackgroundColor(TDLabels[2],COLOR_LabelOut);
  294. TextDrawFont(TDLabels[2],1);
  295.  
  296.  
  297. new i;
  298. for(i=0;i<=MAX_PLAYERS;i++){
  299. TDValueDrift[i]=TextDrawCreate(246.000500, 347.000000,"0");
  300. TextDrawColor(TDValueDrift[i],0xFFFF00AA);
  301. TextDrawSetShadow(TDValueDrift[i],0);
  302. TextDrawLetterSize(TDValueDrift[i],0.37,1.2);
  303. TextDrawBackgroundColor(TDValueDrift[i],COLOR_ValueOut);
  304. TextDrawFont(TDValueDrift[i],3);
  305.  
  306.  
  307. TDValueBonus[i]=TextDrawCreate(246.005000, 364.000000," X1");
  308. TextDrawColor(TDValueBonus[i],0xFFFF00AA);
  309. TextDrawSetShadow(TDValueBonus[i],0);
  310. TextDrawLetterSize(TDValueBonus[i],0.37,1.2);
  311. TextDrawBackgroundColor(TDValueBonus[i],COLOR_ValueOut);
  312. TextDrawFont(TDValueBonus[i],3);
  313.  
  314.  
  315. TDValueCash[i]=TextDrawCreate(245.000600, 381.000000,"$0");
  316. TextDrawColor(TDValueCash[i],0xFFFF00AA);
  317. TextDrawSetShadow(TDValueCash[i],0);
  318. TextDrawLetterSize(TDValueCash[i],0.37,1.2);
  319. TextDrawBackgroundColor(TDValueCash[i],COLOR_ValueOut);
  320. TextDrawFont(TDValueCash[i],3);
  321.  
  322. }
  323.  
  324. return 1;
  325. }
  326.  
  327. //__//__removed drift stop function on big strike with any thing || by Florinca
  328. public CheckPlayerState(){ //by Florinca
  329. new i,cs;
  330.  
  331. for(i=0;i<=MAX_PLAYERS;i++){
  332. cs=GetPlayerState(i);
  333. if(DriftMode[i] && cs==PLAYER_STATE_DRIVER && DriftPointsNow[i]>70){
  334.  
  335. }
  336. if(cs==PLAYER_STATE_DRIVER && DriftMode[i]==false){
  337. if(GetVType(GetPlayerVehicleID(i))){
  338. DriftMode[i]=true;
  339. GetVehicleHealth(GetPlayerVehicleID(i),HealthInit[i]);
  340. AutoFixBool[i]=false;
  341. DriftTimer[i]=SetTimerEx("Drift", 200, true, "i", i);
  342. }
  343. }
  344. else if(cs!=PLAYER_STATE_DRIVER && DriftMode[i]==true){
  345. KillTimer(DriftTimer[i]);
  346. DriftMode[i]=false;
  347. AutoFixBool[i]=true;
  348. }
  349. else{}
  350. }
  351. return 1;
  352. }
  353.  
  354. GetVType(vid){ // By Florinca
  355.  
  356. new Convertibles[4]={480, 533, 439, 555};
  357. new Industrial[26]={499, 422, 482, 498, 609, 524, 578, 455, 403, 414, 582, 443, 514, 413, 515, 440, 543, 605, 459, 531, 408, 552, 478, 456, 554};
  358. new LowRider[8]={536, 575, 534, 567, 535, 566, 576, 412};
  359. new OffRoad[13]={568, 424, 573, 579, 400, 500, 444, 556, 557, 470, 489, 505, 595};
  360. new Service[19]={416, 433, 431, 438, 437, 523, 427, 490, 528, 407, 544, 596, 596, 597, 598, 599, 432, 601, 420};
  361. new Saloon[35]={445, 504, 401, 518, 527, 542, 507, 562, 585, 419, 526, 604, 466, 492, 474, 546, 517, 410, 551, 516, 467, 600, 426, 436, 547, 405, 580, 560, 550, 549, 540, 491, 529, 421};
  362. new Sports[20]={602, 429, 496, 402, 541, 415, 589, 587, 565, 494, 502, 503, 411, 559, 603, 475, 506, 451, 558, 477};
  363. new Wagons[5]={418, 404, 479, 458, 561};
  364.  
  365. new modelid=GetVehicleModel(vid);
  366. new i;
  367. for(i=0;i<3;i++){
  368. if(Convertibles[i]==modelid) return 1;
  369. }
  370. for(i=0;i<25;i++){
  371. if(Industrial[i]==modelid) return 1;
  372. }
  373. for(i=0;i<7;i++){
  374. if(LowRider[i]==modelid) return 1;
  375. }
  376. for(i=0;i<12;i++){
  377. if(OffRoad[i]==modelid) return 1;
  378. }
  379. for(i=0;i<19;i++){
  380. if(Service[i]==modelid) return 1;
  381. }
  382. for(i=0;i<35;i++){
  383. if(Saloon[i]==modelid) return 1;
  384. }
  385. for(i=0;i<20;i++){
  386. if(Sports[i]==modelid) return 1;
  387. }
  388. for(i=0;i<5;i++){
  389. if(Wagons[i]==modelid) return 1;
  390. }
  391. return 0;
  392. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement