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