everyone is wrong...
using such a timer and making a function what can result the angle of the car = angle
getting the angle by making a timer which saves by the angle per 100 ms = knowledge about angle
finding the correct formula for it = angle position
and you can do something like this:
if(angle >= formula) or however it comes and it results cash
HELPY SOURCE:
FORUM >>
http://pastebin.com/f1841d042Code:
1.////////////////////////////////////////////////////////////
2./////////////// DRIFT POINTS COUNTER BY LUBY ///////////////
3./////////////// A little editted by Abhinav ////////////////
4.////////////////////////////////////////////////////////////
5.
6.#include <a_samp> // by I dont know .. :D lol
7.
8.#define DRIFT_MINKAT 10.0 // by Luby
9.#define DRIFT_MAXKAT 90.0 // by Luby
10.#define DRIFT_SPEED 30.0 // by Luby
11.
12.//////////// Added by Abhinav///////
13.#define COLOR_Label 0xFFFFFFFF
14.#define COLOR_LabelOut 0x00000040
15.#define COLOR_ValueOut 0xFFFFFF40
16.#define COLOR_Value 0x000000FF
17.
18.#define Label_X 500
19.#define Value_X 500
20.#define TD_Y 100
21./////////////////////////////////////
22.
23.new DriftTimer[MAX_PLAYERS]; // Added by Abhinav
24.new TimerA,TimerB,TimerC; // Added by Abhinav
25.
26.new DriftPointsNow[MAX_PLAYERS]; // by Luby
27.new PlayerDriftCancellation[MAX_PLAYERS]; // by Luby
28.new Float:ppos[MAX_PLAYERS][3]; // by Luby
29.enum Float:Pos{ Float:sX,Float:sY,Float:sZ }; // by Luby
30.new Float:SavedPos[MAX_PLAYERS][Pos]; // by Luby
31.
32.new bool:DriftMode[MAX_PLAYERS]=false; // Added by Abhinav
33.new DriftBonus[MAX_PLAYERS]=1; // Added by Abhinav
34.new Float:HealthInit[MAX_PLAYERS]=1000.0; // Added by Abhinav
35.new bool:AutoFixBool[MAX_PLAYERS]=true; // Added by Abhinav
36.
37.new Text:TDLabels[3]; // Added by Abhinav
38.new Text:TDValueDrift[MAX_PLAYERS]; // Added by Abhinav
39.new Text:TDValueBonus[MAX_PLAYERS]; // Added by Abhinav
40.new Text:TDValueCash[MAX_PLAYERS]; // Added by Abhinav
41.
42.forward Drift(); // by Luby
43.forward AngleUpdate(); // by Luby
44.forward DriftExit(playerid); // by Luby
45.forward CheckPlayerState(); // Added by Abhinav
46.forward AutoFix(); // Added by Abhinav
47.
48.public OnFilterScriptInit(){
49. TimerA=SetTimer("AngleUpdate", 200, true); // by Luby
50. TimerB=SetTimer("AutoFix", 500, true); //by Abhinav
51. TimerC=SetTimer("CheckPlayerState", 100, true); //by Abhinav
52. LoadTextDraws();
53. return 1;
54.}
55.
56.public OnFilterScriptExit(){
57. KillTimer(TimerA);
58. KillTimer(TimerB);
59. KillTimer(TimerC);
60. return 1;
61.}
62.
63.Float:GetPlayerTheoreticAngle(i) // By Luby
64.{
65. new Float:sin;
66. new Float:dis;
67. new Float:angle2;
68. new Float:x,Float:y,Float:z;
69. new Float:tmp3;
70. new Float:tmp4;
71. new Float:MindAngle;
72.
73. if(IsPlayerConnected(i)){
74.
75. GetPlayerPos(i,x,y,z);
76.
77. dis = floatsqroot(floatpower(floatabs(floatsub(x,ppos[i][0])),2)+floatpower(floatabs(floatsub(y,ppos[i][1])),2));
78.
79. if(IsPlayerInAnyVehicle(i)){GetVehicleZAngle(GetPlayerVehicleID(i), angle2);}else{GetPlayerFacingAngle(i, angle2);}
80.
81. if(x>ppos[i][0]){tmp3=x-ppos[i][0];}else{tmp3=ppos[i][0]-x;}
82. if(y>ppos[i][1]){tmp4=y-ppos[i][1];}else{tmp4=ppos[i][1]-y;}
83.
84. if(ppos[i][1]>y && ppos[i][0]>x){
85. sin = asin(tmp3/dis);
86. MindAngle = floatsub(floatsub(floatadd(sin, 90), floatmul(sin, 2)), -90.0);
87. }
88.
89. if(ppos[i][1]<y && ppos[i][0]>x){
90. sin = asin(tmp3/dis);
91. MindAngle = floatsub(floatadd(sin, 180), 180.0);
92. }
93.
94. if(ppos[i][1]<y && ppos[i][0]<x){
95. sin = acos(tmp4/dis);
96. MindAngle = floatsub(floatadd(sin, 360), floatmul(sin, 2));
97. }
98.
99. if(ppos[i][1]>y && ppos[i][0]<x){
100. sin = asin(tmp3/dis);
101. MindAngle = floatadd(sin, 180);
102. }
103. }
104.
105. if(MindAngle == 0.0){return angle2;}else{return MindAngle;}
106.}
107.
108.public DriftExit(playerid){ // By Luby
109. PlayerDriftCancellation[playerid] = 0;
110.
111. ////////////////// by Abhinav ///////////////////
112. new Float:h;
113. GetVehicleHealth(GetPlayerVehicleID(playerid),h);
114. if(DriftPointsNow[playerid]>70 && DriftPointsNow[playerid]<10000 && h==HealthInit[playerid]) GivePlayerMoney(playerid,DriftPointsNow[playerid]*DriftBonus[playerid]);
115. TextDrawHideForPlayer(playerid,TDLabels[0]);
116. TextDrawHideForPlayer(playerid,TDLabels[1]);
117. TextDrawHideForPlayer(playerid,TDLabels[2]);
118. TextDrawHideForPlayer(playerid,TDValueDrift[playerid]);
119. TextDrawHideForPlayer(playerid,TDValueBonus[playerid]);
120. TextDrawHideForPlayer(playerid,TDValueCash[playerid]);
121. DriftBonus[playerid]=1;
122. AutoFixBool[playerid]=true;
123. SetVehicleHealth(GetPlayerVehicleID(playerid),HealthInit[playerid]);
124. ////////////////////////////////////////////////////
125.
126. DriftPointsNow[playerid] = 0;
127.}
128.
129.Float:ReturnPlayerAngle(playerid){ // By Luby
130. new Float:Ang;
131. if(IsPlayerInAnyVehicle(playerid))GetVehicleZAngle(GetPlayerVehicleID(playerid), Ang); else GetPlayerFacingAngle(playerid, Ang);
132. return Ang;
133.}
134.
135.public Drift(){ // By Luby
136. new Float:Angle1, Float:Angle2, Float:BySpeed;
137. new Float:Z;
138. new Float:X;
139. new Float:Y;
140. new Float:SpeedX;
141. for(new g=0;g<200;g++){
142. GetPlayerPos(g, X, Y, Z);
143. 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)));
144. Angle1 = ReturnPlayerAngle(g);
145. Angle2 = GetPlayerTheoreticAngle(g);
146. BySpeed = floatmul(SpeedX, 12);
147. if(IsPlayerInAnyVehicle(g) && GetVType(GetPlayerVehicleID(g)) && floatabs(floatsub(Angle1, Angle2)) > DRIFT_MINKAT && floatabs(floatsub(Angle1, Angle2)) < DRIFT_MAXKAT && BySpeed > DRIFT_SPEED){
148. if(PlayerDriftCancellation[g] > 0)KillTimer(PlayerDriftCancellation[g]);
149. PlayerDriftCancellation[g] = 0;
150. DriftPointsNow[g] += floatval( floatabs(floatsub(Angle1, Angle2)) * 3 * (BySpeed*0.1) )/10;
151. PlayerDriftCancellation[g] = SetTimerEx("DriftExit", 3000, 0, "d", g);
152. }
153.
154. if(DriftPointsNow[g] > 70 && DriftPointsNow[g]<10000){
155. ///////////// by Abhinav ////////////////////
156. if(DriftPointsNow[g]<500){
157. DriftBonus[g]=1;
158. }
159. if(DriftPointsNow[g]>=500 && DriftPointsNow[g]<1000){
160. DriftBonus[g]=2;
161. }
162. if(DriftPointsNow[g]>=1000 && DriftPointsNow[g]<1700){
163. DriftBonus[g]=3;
164. }
165. if(DriftPointsNow[g]>=1700 && DriftPointsNow[g]<2500){
166. DriftBonus[g]=4;
167. }
168. if(DriftPointsNow[g]>=2500){
169. DriftBonus[g]=5;
170. }
171.
172. TextDrawShowForPlayer(g,TDLabels[0]);
173. TextDrawShowForPlayer(g,TDLabels[1]);
174. TextDrawShowForPlayer(g,TDLabels[2]);
175.
176. TextDrawShowForPlayer(g,TDValueDrift[g]);
177. TextDrawShowForPlayer(g,TDValueBonus[g]);
178. TextDrawShowForPlayer(g,TDValueCash[g]);
179.
180. new DPs[128],DBn[128],Cash[128],csh;
181.
182. valstr(DPs,DriftPointsNow[g],false);
183. format(DBn,sizeof(DBn),"X%i",DriftBonus[g]);
184. csh=DriftPointsNow[g]*DriftBonus[g];
185. format(Cash,sizeof(Cash),"$%i",csh);
186.
187. TextDrawSetString(TDValueDrift[g],DPs);
188. TextDrawSetString(TDValueBonus[g],DBn);
189. TextDrawSetString(TDValueCash[g],Cash);
190. ////////////////////////////////////////
191. }
192. SavedPos[ g ][ sX ] = X;
193. SavedPos[ g ][ sY ] = Y;
194. SavedPos[ g ][ sZ ] = Z;
195. }
196.}
197.
198.public AngleUpdate(){ // By Luby
199. for(new g=0;g<=MAX_PLAYERS;g++){
200. new Float:x, Float:y, Float:z;
201. if(IsPlayerInAnyVehicle(g))GetVehiclePos(GetPlayerVehicleID(g), x, y, z); else GetPlayerPos(g, x, y, z);
202. ppos[g][0] = x;
203. ppos[g][1] = y;
204. ppos[g][2] = z;
205. }
206.}
207.
208.floatval(Float:val){ // By Luby
209. new str[256];
210. format(str, 256, "%.0f", val);
211. return todec(str);
212.}
213.
214.todec(str[]){ // By Luby
215. return strval(str);
216.}
217.
218.LoadTextDraws(){ // by Abhinav
219. TDLabels[0]=TextDrawCreate(Label_X,TD_Y,"Drift Points");
220. TextDrawColor(TDLabels[0],COLOR_Label);
221. TextDrawSetShadow(TDLabels[0],0);
222. TextDrawSetOutline(TDLabels[0],1);
223. TextDrawLetterSize(TDLabels[0],0.5,2);
224. TextDrawBackgroundColor(TDLabels[0],COLOR_LabelOut);
225. TextDrawFont(TDLabels[0],1);
226.
227. TDLabels[1]=TextDrawCreate(Label_X,TD_Y+50,"Drift Bonus");
228. TextDrawColor(TDLabels[1],COLOR_Label);
229. TextDrawSetShadow(TDLabels[1],0);
230. TextDrawSetOutline(TDLabels[1],1);
231. TextDrawLetterSize(TDLabels[1],0.5,2);
232. TextDrawBackgroundColor(TDLabels[1],COLOR_LabelOut);
233. TextDrawFont(TDLabels[1],1);
234.
235. TDLabels[2]=TextDrawCreate(Label_X,TD_Y+100,"Drift Cash");
236. TextDrawColor(TDLabels[2],COLOR_Label);
237. TextDrawSetShadow(TDLabels[2],0);
238. TextDrawSetOutline(TDLabels[2],1);
239. TextDrawLetterSize(TDLabels[2],0.5,2);
240. TextDrawBackgroundColor(TDLabels[2],COLOR_LabelOut);
241. TextDrawFont(TDLabels[2],1);
242.
243. new i;
244. for(i=0;i<=MAX_PLAYERS;i++){
245. TDValueDrift[i]=TextDrawCreate(Value_X,TD_Y+20,"0");
246. TextDrawColor(TDValueDrift[i],COLOR_Value);
247. TextDrawSetShadow(TDValueDrift[i],0);
248. TextDrawSetOutline(TDValueDrift[i],1);
249. TextDrawLetterSize(TDValueDrift[i],0.5,2);
250. TextDrawBackgroundColor(TDValueDrift[i],COLOR_ValueOut);
251. TextDrawFont(TDValueDrift[i],3);
252.
253. TDValueBonus[i]=TextDrawCreate(Value_X,TD_Y+70,"X1");
254. TextDrawColor(TDValueBonus[i],COLOR_Value);
255. TextDrawSetShadow(TDValueBonus[i],0);
256. TextDrawSetOutline(TDValueBonus[i],1);
257. TextDrawLetterSize(TDValueBonus[i],0.5,2);
258. TextDrawBackgroundColor(TDValueBonus[i],COLOR_ValueOut);
259. TextDrawFont(TDValueBonus[i],3);
260.
261. TDValueCash[i]=TextDrawCreate(Value_X,TD_Y+120,"$0");
262. TextDrawColor(TDValueCash[i],COLOR_Value);
263. TextDrawSetShadow(TDValueCash[i],0);
264. TextDrawSetOutline(TDValueCash[i],1);
265. TextDrawLetterSize(TDValueCash[i],0.5,2);
266. TextDrawBackgroundColor(TDValueCash[i],COLOR_ValueOut);
267. TextDrawFont(TDValueCash[i],3);
268. }
269.
270. return 1;
271.}
272.
273.public CheckPlayerState(){ //by Abhinav
274. new i,cs;
275.
276. for(i=0;i<=MAX_PLAYERS;i++){
277. cs=GetPlayerState(i);
278. if(DriftMode[i] && cs==PLAYER_STATE_DRIVER && DriftPointsNow[i]>70){
279. new Float:h;
280. GetVehicleHealth(GetPlayerVehicleID(i),h);
281. if(h<HealthInit[i]){
282. KillTimer(DriftTimer[i]);
283. DriftExit(i);
284. GameTextForPlayer(i,"~n~~n~~n~~n~~n~~n~~n~~r~Boom",800,5);
285. DriftMode[i]=false;
286. }
287. }
288. if(cs==PLAYER_STATE_DRIVER && DriftMode[i]==false){
289. if(GetVType(GetPlayerVehicleID(i))){
290. DriftMode[i]=true;
291. GetVehicleHealth(GetPlayerVehicleID(i),HealthInit[i]);
292. AutoFixBool[i]=false;
293. DriftTimer[i]=SetTimerEx("Drift", 200, true, "i", i);
294. }
295. }
296. else if(cs!=PLAYER_STATE_DRIVER && DriftMode[i]==true){
297. KillTimer(DriftTimer[i]);
298. DriftMode[i]=false;
299. AutoFixBool[i]=true;
300. }
301. else{}
302. }
303. return 1;
304.}
305.
306.public AutoFix(){ // By abhinav
307. new i;
308. for(i=0;i<=MAX_PLAYERS;i++){
309. if(AutoFixBool[i] && IsPlayerInAnyVehicle(i)){
310. SetVehicleHealth(GetPlayerVehicleID(i),HealthInit[i]);
311. }
312. }
313.}
314.
315.GetVType(vid){ // By Abhinav
316.
317. new Convertibles[4]={480, 533, 439, 555};
318. 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};
319. new LowRider[8]={536, 575, 534, 567, 535, 566, 576, 412};
320. new OffRoad[13]={568, 424, 573, 579, 400, 500, 444, 556, 557, 470, 489, 505, 595};
321. new Service[19]={416, 433, 431, 438, 437, 523, 427, 490, 528, 407, 544, 596, 596, 597, 598, 599, 432, 601, 420};
322. 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};
323. new Sports[20]={602, 429, 496, 402, 541, 415, 589, 587, 565, 494, 502, 503, 411, 559, 603, 475, 506, 451, 558, 477};
324. new Wagons[5]={418, 404, 479, 458, 561};
325.
326. new modelid=GetVehicleModel(vid);
327. new i;
328. for(i=0;i<3;i++){
329. if(Convertibles[i]==modelid) return 1;
330. }
331. for(i=0;i<25;i++){
332. if(Industrial[i]==modelid) return 1;
333. }
334. for(i=0;i<7;i++){
335. if(LowRider[i]==modelid) return 1;
336. }
337. for(i=0;i<12;i++){
338. if(OffRoad[i]==modelid) return 1;
339. }
340. for(i=0;i<19;i++){
341. if(Service[i]==modelid) return 1;
342. }
343. for(i=0;i<35;i++){
344. if(Saloon[i]==modelid) return 1;
345. }
346. for(i=0;i<20;i++){
347. if(Sports[i]==modelid) return 1;
348. }
349. for(i=0;i<5;i++){
350. if(Wagons[i]==modelid) return 1;
351. }
352. return 0;
353.}