SHOW:
|
|
- or go back to the newest paste.
1 | #include <a_samp> | |
2 | ||
3 | new Text:ServerTextDrawOne; | |
4 | new Text:ServerTextDrawTwo; | |
5 | new Text:ServerTextDrawThree[MAX_PLAYERS]; | |
6 | new Text:ServerTextDrawFour[MAX_PLAYERS]; | |
7 | new Text:ServerTextDrawFive[MAX_PLAYERS]; | |
8 | new ServerTimerOne; | |
9 | new ServerTimerTwo; | |
10 | new PlayerMoney[MAX_PLAYERS]; | |
11 | new PlayerScore[MAX_PLAYERS]; | |
12 | new PlayerCombo[MAX_PLAYERS]; | |
13 | new Float:PlayerPositionX[MAX_PLAYERS]; | |
14 | new Float:PlayerPositionY[MAX_PLAYERS]; | |
15 | new Float:PlayerPositionZ[MAX_PLAYERS]; | |
16 | new PlayerTimerOne[MAX_PLAYERS]; | |
17 | ||
18 | forward PlayerUpdate(); | |
19 | forward PlayerDrift(); | |
20 | forward PlayerDriftEnd(Player); | |
21 | ||
22 | Float:PlayerTheoreticAngle(Player) | |
23 | { | |
24 | new Float:X; | |
25 | new Float:Y; | |
26 | new Float:Z; | |
27 | GetVehiclePos(GetPlayerVehicleID(Player),X,Y,Z); | |
28 | new Float:NewX; | |
29 | if(X > PlayerPositionX[Player]) NewX = X - PlayerPositionX[Player]; | |
30 | if(X < PlayerPositionX[Player]) NewX = PlayerPositionX[Player] - X; | |
31 | new Float:NewY; | |
32 | if(Y > PlayerPositionY[Player]) NewY = Y - PlayerPositionY[Player]; | |
33 | if(Y < PlayerPositionY[Player]) NewY = PlayerPositionY[Player] - Y; | |
34 | new Float:Sinus; | |
35 | new Float:Cosinus; | |
36 | Cosinus = floatsqroot(floatpower(floatabs(floatsub(X,PlayerPositionX[Player])),2) + floatpower(floatabs(floatsub(Y,PlayerPositionY[Player])),2)); | |
37 | new Float:TheoreticAngle; | |
38 | if(PlayerPositionX[Player] > X && PlayerPositionY[Player] > Y) | |
39 | { | |
40 | Sinus = asin(NewX / Cosinus); | |
41 | TheoreticAngle = floatsub(floatsub(floatadd(Sinus,90),floatmul(Sinus,2)),-90.0); | |
42 | } | |
43 | if(PlayerPositionX[Player] > X && PlayerPositionY[Player] < Y) | |
44 | { | |
45 | Sinus = asin(NewX / Cosinus); | |
46 | TheoreticAngle = floatsub(floatadd(Sinus,180),180.0); | |
47 | } | |
48 | if(PlayerPositionX[Player] < X && PlayerPositionY[Player] < Y) | |
49 | { | |
50 | Sinus = acos(NewY / Cosinus); | |
51 | TheoreticAngle = floatsub(floatadd(Sinus,360),floatmul(Sinus,2)); | |
52 | } | |
53 | if(PlayerPositionX[Player] < X && PlayerPositionY[Player] > Y) | |
54 | { | |
55 | Sinus = asin(NewX / Cosinus); | |
56 | TheoreticAngle = floatadd(Sinus,180); | |
57 | } | |
58 | if(TheoreticAngle == 0.0) GetVehicleZAngle(GetPlayerVehicleID(Player),TheoreticAngle); | |
59 | return TheoreticAngle; | |
60 | } | |
61 | ||
62 | stock VehicleIsCar(Vehicle) | |
63 | { | |
64 | switch(GetVehicleModel(Vehicle)) | |
65 | { | |
66 | case 480: return 1; | |
67 | case 533: return 1; | |
68 | case 439: return 1; | |
69 | case 555: return 1; | |
70 | case 536: return 1; | |
71 | case 575: return 1; | |
72 | case 534: return 1; | |
73 | case 567: return 1; | |
74 | case 535: return 1; | |
75 | case 566: return 1; | |
76 | case 576: return 1; | |
77 | case 412: return 1; | |
78 | case 445: return 1; | |
79 | case 504: return 1; | |
80 | case 401: return 1; | |
81 | case 518: return 1; | |
82 | case 527: return 1; | |
83 | case 542: return 1; | |
84 | case 507: return 1; | |
85 | case 562: return 1; | |
86 | case 585: return 1; | |
87 | case 419: return 1; | |
88 | case 526: return 1; | |
89 | case 604: return 1; | |
90 | case 466: return 1; | |
91 | case 492: return 1; | |
92 | case 474: return 1; | |
93 | case 546: return 1; | |
94 | case 517: return 1; | |
95 | case 410: return 1; | |
96 | case 551: return 1; | |
97 | case 516: return 1; | |
98 | case 467: return 1; | |
99 | case 426: return 1; | |
100 | case 436: return 1; | |
101 | case 547: return 1; | |
102 | case 405: return 1; | |
103 | case 580: return 1; | |
104 | case 560: return 1; | |
105 | case 550: return 1; | |
106 | case 549: return 1; | |
107 | case 540: return 1; | |
108 | case 491: return 1; | |
109 | case 529: return 1; | |
110 | case 421: return 1; | |
111 | case 602: return 1; | |
112 | case 429: return 1; | |
113 | case 496: return 1; | |
114 | case 402: return 1; | |
115 | case 541: return 1; | |
116 | case 415: return 1; | |
117 | case 589: return 1; | |
118 | case 587: return 1; | |
119 | case 565: return 1; | |
120 | case 494: return 1; | |
121 | case 502: return 1; | |
122 | case 503: return 1; | |
123 | case 411: return 1; | |
124 | case 559: return 1; | |
125 | case 603: return 1; | |
126 | case 475: return 1; | |
127 | case 506: return 1; | |
128 | case 451: return 1; | |
129 | case 558: return 1; | |
130 | case 477: return 1; | |
131 | case 418: return 1; | |
132 | case 404: return 1; | |
133 | case 479: return 1; | |
134 | case 458: return 1; | |
135 | case 561: return 1; | |
136 | } | |
137 | return 0; | |
138 | } | |
139 | ||
140 | stock VehicleSpeed(Vehicle) | |
141 | { | |
142 | new Float:X; | |
143 | new Float:Y; | |
144 | new Float:Z; | |
145 | GetVehicleVelocity(Vehicle,X,Y,Z); | |
146 | new Float:Speed; | |
147 | Speed = floatsqroot(floatpower(floatabs(X),2.0) + floatpower(floatabs(Y),2.0) + floatpower(floatabs(Z),2.0)) * 200.0; | |
148 | return floatround(Speed); | |
149 | } | |
150 | ||
151 | public OnFilterScriptInit() | |
152 | { | |
153 | ServerTextDrawOne = TextDrawCreate(320.000000,250.000000,"-"); | |
154 | TextDrawAlignment(ServerTextDrawOne,2); | |
155 | TextDrawBackgroundColor(ServerTextDrawOne,80); | |
156 | TextDrawFont(ServerTextDrawOne,1); | |
157 | TextDrawLetterSize(ServerTextDrawOne,15.000000,30.000000); | |
158 | TextDrawColor(ServerTextDrawOne,80); | |
159 | TextDrawSetOutline(ServerTextDrawOne,0); | |
160 | TextDrawSetProportional(ServerTextDrawOne,1); | |
161 | TextDrawSetShadow(ServerTextDrawOne,1); | |
162 | ServerTextDrawTwo = TextDrawCreate(320.000000,395.000000,"~W~~H~Drift Counter"); | |
163 | TextDrawAlignment(ServerTextDrawTwo,2); | |
164 | TextDrawBackgroundColor(ServerTextDrawTwo,255); | |
165 | TextDrawFont(ServerTextDrawTwo,3); | |
166 | TextDrawLetterSize(ServerTextDrawTwo,0.500000,1.000000); | |
167 | TextDrawColor(ServerTextDrawTwo,-1); | |
168 | TextDrawSetOutline(ServerTextDrawTwo,1); | |
169 | TextDrawSetProportional(ServerTextDrawTwo,1); | |
170 | for(new Player; Player < GetMaxPlayers(); Player++) | |
171 | { | |
172 | ServerTextDrawThree[Player] = TextDrawCreate(250.000000,405.000000," "); | |
173 | TextDrawBackgroundColor(ServerTextDrawThree[Player],255); | |
174 | TextDrawFont(ServerTextDrawThree[Player],2); | |
175 | TextDrawLetterSize(ServerTextDrawThree[Player],0.200000,1.000000); | |
176 | TextDrawColor(ServerTextDrawThree[Player],-1); | |
177 | TextDrawSetOutline(ServerTextDrawThree[Player],1); | |
178 | TextDrawSetProportional(ServerTextDrawThree[Player],1); | |
179 | ServerTextDrawFour[Player] = TextDrawCreate(250.000000,415.000000," "); | |
180 | TextDrawBackgroundColor(ServerTextDrawFour[Player],255); | |
181 | TextDrawFont(ServerTextDrawFour[Player],2); | |
182 | TextDrawLetterSize(ServerTextDrawFour[Player],0.200000,1.000000); | |
183 | TextDrawColor(ServerTextDrawFour[Player],-1); | |
184 | TextDrawSetOutline(ServerTextDrawFour[Player],1); | |
185 | TextDrawSetProportional(ServerTextDrawFour[Player],1); | |
186 | ServerTextDrawFive[Player] = TextDrawCreate(250.000000,425.000000," "); | |
187 | TextDrawBackgroundColor(ServerTextDrawFive[Player],255); | |
188 | TextDrawFont(ServerTextDrawFive[Player],2); | |
189 | TextDrawLetterSize(ServerTextDrawFive[Player],0.200000,1.000000); | |
190 | TextDrawColor(ServerTextDrawFive[Player],-1); | |
191 | TextDrawSetOutline(ServerTextDrawFive[Player],1); | |
192 | TextDrawSetProportional(ServerTextDrawFive[Player],1); | |
193 | } | |
194 | ServerTimerOne = SetTimer("PlayerUpdate",1000,1); | |
195 | ServerTimerTwo = SetTimer("PlayerDrift",500,1); | |
196 | return 1; | |
197 | } | |
198 | ||
199 | public OnFilterScriptExit() | |
200 | { | |
201 | TextDrawDestroy(ServerTextDrawOne); | |
202 | TextDrawDestroy(ServerTextDrawTwo); | |
203 | for(new Player; Player < GetMaxPlayers(); Player++) | |
204 | { | |
205 | TextDrawDestroy(ServerTextDrawThree[Player]); | |
206 | TextDrawDestroy(ServerTextDrawFour[Player]); | |
207 | TextDrawDestroy(ServerTextDrawFive[Player]); | |
208 | } | |
209 | KillTimer(ServerTimerOne); | |
210 | KillTimer(ServerTimerTwo); | |
211 | return 1; | |
212 | } | |
213 | ||
214 | public OnPlayerConnect(playerid) | |
215 | { | |
216 | TextDrawHideForPlayer(playerid,ServerTextDrawOne); | |
217 | TextDrawHideForPlayer(playerid,ServerTextDrawTwo); | |
218 | TextDrawHideForPlayer(playerid,ServerTextDrawThree[playerid]); | |
219 | TextDrawHideForPlayer(playerid,ServerTextDrawFour[playerid]); | |
220 | TextDrawHideForPlayer(playerid,ServerTextDrawFive[playerid]); | |
221 | TextDrawSetString(ServerTextDrawThree[playerid]," "); | |
222 | TextDrawSetString(ServerTextDrawFour[playerid]," "); | |
223 | TextDrawSetString(ServerTextDrawFive[playerid]," "); | |
224 | PlayerMoney[playerid] = 0; | |
225 | PlayerScore[playerid] = 0; | |
226 | PlayerCombo[playerid] = 1; | |
227 | PlayerPositionX[playerid] = 0.0; | |
228 | PlayerPositionY[playerid] = 0.0; | |
229 | PlayerPositionZ[playerid] = 0.0; | |
230 | KillTimer(PlayerTimerOne[playerid]); | |
231 | return 1; | |
232 | } | |
233 | ||
234 | public OnPlayerDisconnect(playerid) | |
235 | { | |
236 | TextDrawHideForPlayer(playerid,ServerTextDrawOne); | |
237 | TextDrawHideForPlayer(playerid,ServerTextDrawTwo); | |
238 | TextDrawHideForPlayer(playerid,ServerTextDrawThree[playerid]); | |
239 | TextDrawHideForPlayer(playerid,ServerTextDrawFour[playerid]); | |
240 | TextDrawHideForPlayer(playerid,ServerTextDrawFive[playerid]); | |
241 | TextDrawSetString(ServerTextDrawThree[playerid]," "); | |
242 | TextDrawSetString(ServerTextDrawFour[playerid]," "); | |
243 | TextDrawSetString(ServerTextDrawFive[playerid]," "); | |
244 | PlayerMoney[playerid] = 0; | |
245 | PlayerScore[playerid] = 0; | |
246 | PlayerCombo[playerid] = 1; | |
247 | PlayerPositionX[playerid] = 0.0; | |
248 | PlayerPositionY[playerid] = 0.0; | |
249 | PlayerPositionZ[playerid] = 0.0; | |
250 | KillTimer(PlayerTimerOne[playerid]); | |
251 | return 1; | |
252 | } | |
253 | ||
254 | public PlayerUpdate() | |
255 | { | |
256 | for(new Player; Player < GetMaxPlayers(); Player++) | |
257 | { | |
258 | if(IsPlayerConnected(Player) && GetPlayerState(Player) == PLAYER_STATE_DRIVER && VehicleIsCar(GetPlayerVehicleID(Player))) GetVehiclePos(GetPlayerVehicleID(Player),PlayerPositionX[Player],PlayerPositionY[Player],PlayerPositionZ[Player]); | |
259 | } | |
260 | return 1; | |
261 | } | |
262 | ||
263 | public PlayerDrift() | |
264 | { | |
265 | for(new Player; Player < GetMaxPlayers(); Player++) | |
266 | { | |
267 | if(IsPlayerConnected(Player) && GetPlayerState(Player) == PLAYER_STATE_DRIVER && VehicleIsCar(GetPlayerVehicleID(Player))) | |
268 | { | |
269 | new Float:Angle; | |
270 | GetVehicleZAngle(GetPlayerVehicleID(Player),Angle); | |
271 | if(floatabs(floatsub(Angle,PlayerTheoreticAngle(Player))) < 90.0 && floatabs(floatsub(Angle,PlayerTheoreticAngle(Player))) > 10.0 && VehicleSpeed(GetPlayerVehicleID(Player)) < 300 && VehicleSpeed(GetPlayerVehicleID(Player)) > 30) | |
272 | { | |
273 | if(PlayerMoney[Player] == 0 && PlayerScore[Player] == 0 && PlayerCombo[Player] == 1) | |
274 | { | |
275 | TextDrawShowForPlayer(Player,ServerTextDrawOne); | |
276 | TextDrawShowForPlayer(Player,ServerTextDrawTwo); | |
277 | TextDrawShowForPlayer(Player,ServerTextDrawThree[Player]); | |
278 | TextDrawShowForPlayer(Player,ServerTextDrawFour[Player]); | |
279 | TextDrawShowForPlayer(Player,ServerTextDrawFive[Player]); | |
280 | TextDrawSetString(ServerTextDrawThree[Player]," "); | |
281 | TextDrawSetString(ServerTextDrawFour[Player]," "); | |
282 | TextDrawSetString(ServerTextDrawFive[Player]," "); | |
283 | } | |
284 | PlayerMoney[Player] += floatround(floatabs(floatsub(Angle,PlayerTheoreticAngle(Player))) * (VehicleSpeed(GetPlayerVehicleID(Player)) * 0.1)) / 10; | |
285 | PlayerScore[Player] += floatround(floatabs(floatsub(Angle,PlayerTheoreticAngle(Player))) * 3 * (VehicleSpeed(GetPlayerVehicleID(Player)) * 0.1)) / 10; | |
286 | PlayerCombo[Player] = PlayerScore[Player] / 1000; | |
287 | if(PlayerCombo[Player] < 1) PlayerCombo[Player] = 1; | |
288 | new String[100]; | |
289 | format(String,sizeof(String),"~R~~H~Cash For Drift: ~W~~H~%d$",PlayerMoney[Player]); | |
290 | TextDrawSetString(ServerTextDrawThree[Player],String); | |
291 | format(String,sizeof(String),"~R~~H~Score For Drift: ~W~~H~%d",PlayerScore[Player]); | |
292 | TextDrawSetString(ServerTextDrawFour[Player],String); | |
293 | format(String,sizeof(String),"~R~~H~Combo: ~W~~H~X%d",PlayerCombo[Player]); | |
294 | TextDrawSetString(ServerTextDrawFive[Player],String); | |
295 | KillTimer(PlayerTimerOne[Player]); | |
296 | PlayerTimerOne[Player] = SetTimerEx("PlayerDriftEnd",3000,0,"d",Player); | |
297 | } | |
298 | } | |
299 | } | |
300 | return 1; | |
301 | } | |
302 | ||
303 | public PlayerDriftEnd(Player) | |
304 | { | |
305 | TextDrawHideForPlayer(Player,ServerTextDrawOne); | |
306 | TextDrawHideForPlayer(Player,ServerTextDrawTwo); | |
307 | TextDrawHideForPlayer(Player,ServerTextDrawThree[Player]); | |
308 | TextDrawHideForPlayer(Player,ServerTextDrawFour[Player]); | |
309 | TextDrawHideForPlayer(Player,ServerTextDrawFive[Player]); | |
310 | TextDrawSetString(ServerTextDrawThree[Player]," "); | |
311 | TextDrawSetString(ServerTextDrawFour[Player]," "); | |
312 | TextDrawSetString(ServerTextDrawFive[Player]," "); | |
313 | GivePlayerMoney(Player,PlayerMoney[Player]); | |
314 | SetPlayerScore(Player,GetPlayerScore(Player) + PlayerScore[Player] * PlayerCombo[Player]); | |
315 | PlayerMoney[Player] = 0; | |
316 | PlayerScore[Player] = 0; | |
317 | PlayerCombo[Player] = 1; | |
318 | return 1; | |
319 | } |