Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float floatadd(float val_1, float val_2) {
- return val_2 = val_1 + val_2;
- }
- float floatsub(float val_1, float val_2) {
- return val_2 = val_2 - val_1;
- }
- float floatmul(float val_1, float val_2) {
- return val_2 = val_1 * val_2;
- }
- float ReturnPlayerAngle(int playerid) {
- float Ang;
- IsPlayerInAnyVehicle(playerid)? GetVehicleZAngle(GetPlayerVehicleID(playerid), &Ang): GetPlayerFacingAngle(playerid, &Ang);
- return Ang;
- }
- float GetPlayerTheoreticAngle(int i) {
- float Sin_Dis[2];
- float Positions[5];
- float Temporary[2];
- if(IsPlayerConnected(i)) {
- GetPlayerPos(i, &Positions[0], &Positions[1], &Positions[2]);
- Sin_Dis[1] = sqrtf(powf(fabs(floatsub(Positions[0], ppos[i][0])), 2)
- +
- powf(fabs(floatsub(Positions[1], ppos[i][1])), 2));
- IsPlayerInAnyVehicle(i)? GetVehicleZAngle(GetPlayerVehicleID(i), &Positions[3]): GetPlayerFacingAngle(i, &Positions[3]);
- Positions[0] > ppos[i][0]? Temporary[0] = Positions[0] - ppos[i][0]: Temporary[0] = ppos[i][0] - Positions[0];
- Positions[1] > ppos[i][1]? Temporary[1] = Positions[1] - ppos[i][1]: Temporary[1] = ppos[i][1] - Positions[1];
- if(ppos[i][1] > Positions[1] && ppos[i][0] > Positions[0]) {
- Sin_Dis[0] = asin(Temporary[0] / Sin_Dis[1]);
- Positions[4] = floatsub(floatsub(floatadd(Sin_Dis[0], 90), floatmul(Sin_Dis[0], 2)), -90.0);
- }
- else if(ppos[i][1] < Positions[1] && ppos[i][0] > Positions[0]) {
- Sin_Dis[0] = asin(Temporary[0] / Sin_Dis[1]);
- Positions[4] = floatsub(floatadd(Sin_Dis[0], 180), 180.0);
- }
- else if(ppos[i][1] < Positions[1] && ppos[i][0] < Positions[0]) {
- Sin_Dis[0] = acos(Temporary[1] / Sin_Dis[1]);
- Positions[4] = floatsub(floatadd(Sin_Dis[0], 360), floatmul(Sin_Dis[0], 2));
- }
- else if(ppos[i][1] > Positions[1] && ppos[i][0] < Positions[0]) {
- Sin_Dis[0] = asin(Temporary[0] / Sin_Dis[1]);
- Positions[4] = floatadd(Sin_Dis[0], 180);
- }
- }
- Positions[4] == 0.0? Positions[3]: Positions[4];
- }
- bool IsCar(int veh_id) {
- switch(GetVehicleModel(veh_id)) {
- case 443: case 448: case 461: case 462: case 463: case 468:
- case 521: case 522: case 523: case 581: case 586: case 481:
- case 509: case 510: case 430: case 446: case 452: case 453:
- case 454: case 472: case 473: case 484: case 493: case 595:
- case 417: case 425: case 447: case 465: case 469: case 487:
- case 488: case 497: case 501: case 548: case 563: case 406:
- case 444: case 556: case 557: case 573: case 460: case 464:
- case 476: case 511: case 512: case 513: case 519: case 520:
- case 539: case 553: case 577: case 592: case 593: case 471:
- return false;
- break;
- }
- return true;
- }
- float floatval(float val) {
- char str[128];
- sprintf(str, "%.0f", val);
- return (float) atoi(str);
- }
- // Timers:
- function void SAMPGDK_CALL Clear3DTexts(int, void *) {
- int playerid = NULL;
- foreach(playerid, MAX_PLAYERS + 1) {
- UpdatePlayer3DTextLabelText(playerid, Drift3DText[playerid], -1, " ");
- IsValidObject(CarFireObject[playerid])? DestroyObject(CarFireObject[playerid]): false;
- RemoveVehicleComponent(GetPlayerVehicleID(playerid), 1010);
- }
- }
- function void SAMPGDK_CALL LoadDrift(int, void *) {
- int playerid;
- foreach(playerid, MAX_PLAYERS + 1) {
- Timer_PlayerDriftPoints[playerid] = 0;
- GivePlayerMoney(playerid, PointsFromDrift[playerid] / 2);
- GivePlayerScore(playerid, PointsFromDrift[playerid]);
- PointsFromDrift[playerid] = 0;
- Timer_Clear3DTexts[playerid] = SetTimer(Clear3DTexts, 100, false);
- // = SetTimer(Clear3DTexts, 100, false);
- }
- }
- function void SAMPGDK_CALL CountDrift(int, void *) {
- int playerid = 0;
- float Angle[2];
- float Speed[2];
- float Position[3];
- char s[96];
- float sX[MAX_PLAYERS];
- float sY[MAX_PLAYERS];
- float sZ[MAX_PLAYERS];
- foreach(playerid, MAX_PLAYERS + 1) {
- GetPlayerPos(playerid, &Position[0], &Position[1], &Position[2]);
- Speed[1] = sqrtf(floatadd(floatadd(powf(fabs(floatsub(Position[0], sX[playerid])), 2), powf(fabs(floatsub(Position[1], sY[playerid])), 2)), powf(fabs(floatsub(Position[2], sZ[playerid])), 2)));
- Angle[0] = ReturnPlayerAngle(playerid);
- Angle[1] = GetPlayerTheoreticAngle(playerid);
- Speed[0] = floatmul(Speed[1], 12);
- if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER && IsCar(GetPlayerVehicleID(playerid)) && fabs(floatsub(Angle[0], Angle[1])) > MinAngle_Drift && fabs(floatsub(Angle[0], Angle[1])) < MaxAngle_Drift && Speed[0] > MaxSpeed_Drift) {
- if(Timer_PlayerDriftPoints[playerid] > 0) KillTimer(Timer_PlayerDriftPoints[playerid]);
- Timer_PlayerDriftPoints[playerid] = 0;
- PointsFromDrift[playerid] += floatval(fabs(floatsub(Angle[0], Angle[1])) * 3 * (Speed[0] * 0.1)) / 10.0;
- Timer_PlayerDriftPoints[playerid] = SetTimer(LoadDrift, 3000, 0);
- }
- if(PointsFromDrift[playerid] > 0) {
- sprintf(s, "\n\n\n%d $\n%d %s\n~k~~VEHICLE_FIREWEAPON~ - {FF0000}Nitro{FFFFFF}!", PointsFromDrift[playerid] / 2, PointsFromDrift[playerid], dli(PointsFromDrift[playerid], "Punkt", "Punkty", "Punktów"));
- UpdatePlayer3DTextLabelText(playerid, Drift3DText[playerid], -1, s);
- }
- sX[playerid] = Position[0];
- sY[playerid] = Position[1];
- sZ[playerid] = Position[2];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement