Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Anti Airbreak by Kolor4dO */
- #include <a_samp>
- static
- o_Anim[MAX_PLAYERS],
- Float:AC_oX[MAX_PLAYERS],
- Float:AC_oY[MAX_PLAYERS],
- Float:AC_oZ[MAX_PLAYERS],
- Float:AC_setX[MAX_PLAYERS],
- Float:AC_setY[MAX_PLAYERS],
- Float:AC_setZ[MAX_PLAYERS],
- acSet[MAX_PLAYERS],
- acGtc[MAX_PLAYERS],
- AirVehW[MAX_PLAYERS],
- AirW[MAX_PLAYERS],
- airb_TIMER [MAX_PLAYERS],
- bool:acTpToZ[MAX_PLAYERS];
- public OnPlayerUpdate(playerid)
- {
- if(GetPlayerSurfingVehicleID(playerid) != INVALID_VEHICLE_ID || GetPlayerSurfingObjectID(playerid) != INVALID_OBJECT_ID)
- return 1;
- new
- pAnim = GetPlayerAnimationIndex(playerid),
- ac_gtc = GetTickCount(),
- ac_gpp = GetPlayerPing(playerid),
- ac_vehid = GetPlayerVehicleID(playerid),
- Float:ac_X,
- Float:ac_Y,
- Float:ac_Z,
- Float:ac_vX,
- Float:ac_vY,
- Float:ac_vZ,
- Float:ac_dist = GetPlayerDistanceFromPoint(playerid, AC_oX[playerid], AC_oY[playerid], AC_oZ[playerid]),
- Float:ac_dist_set = GetPlayerDistanceFromPoint(playerid, AC_setX[playerid], AC_setY[playerid], (acTpToZ[playerid] ? ac_Z : AC_setZ[playerid]));
- GetPlayerPos(playerid, ac_X, ac_Y, ac_Z);
- if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
- GetVehicleVelocity(ac_vehid, ac_vX, ac_vY, ac_vZ);
- else
- GetPlayerVelocity(playerid, ac_vX, ac_vY, ac_vZ);
- new Float:ac_vsp = ac_GetSpeed(ac_vX, ac_vY, ac_vZ);
- ac_vX = ac_GetSpeed(ac_vX, ac_vY, ac_vZ);
- if(ac_dist > 0.2 && (acSet[playerid] == -1 || ac_dist_set > 0.2) &&
- ac_gtc > acGtc[playerid] + ac_gpp)
- {
- if(ac_vX <= ac_dist * (ac_dist < 1.0 ? 20.0 : 5.0) &&
- (acSet[playerid] == -1 || ac_vX <= ac_dist_set * (ac_dist_set < 1.0 ? 20.0 : 5.0)))
- {
- if(ac_vX && pAnim != 1064 && pAnim != 1139 && pAnim != 1136 && pAnim != 1065 &&
- pAnim != 1137 && pAnim != 1063 && pAnim != 1138 && pAnim != 1132 && pAnim != 1133 &&
- pAnim != 1196 && pAnim != 1235 && pAnim != 1234 && o_Anim[playerid] != 1064 &&
- o_Anim[playerid] != 1139 && o_Anim[playerid] != 1266 && o_Anim[playerid] != 1136 &&
- o_Anim[playerid] != 1263 && o_Anim[playerid] != 1137 && o_Anim[playerid] != 1138 &&
- o_Anim[playerid] != 1265 && o_Anim[playerid] != 1066 && o_Anim[playerid] != 1067 && o_Anim[playerid] != 1063)
- {
- if(!IsPlayerInAnyVehicle(playerid))
- {
- KillTimer(airb_TIMER[playerid]);
- AirW[playerid] ++;
- airb_TIMER[playerid] = SetTimerEx( "AirReset", 4000, false, "i", playerid);
- if(AirW[playerid] >= 8)
- {
- SetPlayerPos(playerid, AC_oX[playerid], AC_oY[playerid], AC_oZ[playerid]);
- CallLocalFunction("OnPlayerAirbreak_check", "i", playerid);
- }
- }
- }
- }
- }
- if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
- {
- if(ac_dist > 9.0 && (acSet[playerid] == -1 || ac_dist_set > 9.0) &&
- ac_gtc > acGtc[playerid] + ac_gpp)
- {
- if(ac_vsp < 16.0)
- {
- KillTimer(airb_TIMER[playerid]);
- AirW[playerid] ++;
- airb_TIMER[playerid] = SetTimerEx( "AirReset", 4000, false, "i", playerid);
- if(AirVehW[playerid] >= 2) CallLocalFunction("OnPlayerAirbreak", "i", playerid);
- }
- }
- }
- if(GetPlayerSurfingVehicleID(playerid) == INVALID_VEHICLE_ID && GetPlayerSurfingObjectID(playerid) == INVALID_OBJECT_ID)
- {
- if(ac_dist > 0.7 && (acSet[playerid] == -1 || ac_dist_set > 0.7) &&
- ac_gtc > acGtc[playerid] + ac_gpp)
- {
- if(ac_vX * ac_vY * ac_vZ == 0.0)
- {
- if(pAnim == 1189 && o_Anim[playerid] == 1189)
- {
- KillTimer(airb_TIMER[playerid]);
- AirW[playerid] ++;
- airb_TIMER[playerid] = SetTimerEx( "AirReset", 4000, false, "i", playerid);
- if(AirW[playerid] >= 5)
- {
- CallLocalFunction("OnPlayerAirbreak", "i", playerid);
- }
- }
- }
- }
- static
- Float:vx,
- Float:vy,
- Float:vz,
- Float:vl;
- GetPlayerVelocity(playerid, vx, vy, vz);
- vl = floatsqroot( (vx*vx)+(vy*vy)+(vz*vz) ) * 150.0;
- if(vl == 0.0 && ac_dist > 0.2 && (acSet[playerid] == -1 || ac_dist_set > 0.2) &&
- ac_gtc > acGtc[playerid] + ac_gpp)
- {
- if(pAnim == 1231 && o_Anim[playerid] == 1231)
- {
- KillTimer(airb_TIMER[playerid]);
- AirW[playerid] ++;
- airb_TIMER[playerid] = SetTimerEx( "AirReset", 4000, false, "i", playerid);
- if(AirW[playerid] >= 3)
- {
- CallLocalFunction("OnPlayerAirbreak", "i", playerid);
- }
- }
- }
- }
- AC_oX[playerid] = ac_X;
- AC_oY[playerid] = ac_Y;
- AC_oZ[playerid] = ac_Z;
- o_Anim[playerid] = pAnim;
- #if defined AB_OnPlayerUpdate
- return AB_OnPlayerUpdate(playerid);
- #else
- return 1;
- #endif
- }
- static ac_GetSpeed(Float:ac_x, Float:ac_y, Float:ac_z, bool:speed3d = true)
- {
- if(speed3d) return floatround(VectorSize(ac_x, ac_y, ac_z) * 179.28625);
- return floatround(VectorSize(ac_x, ac_y, 0.0) * 179.28625);
- }
- #if defined Streamer_UpdateEx
- stock ac_Streamer_UpdateEx(playerid, Float:x, Float:y, Float:z, worldid = -1, interiorid = -1, type = -1, compensatedtime = -1, freezeplayer = 1)
- {
- if(!Streamer_UpdateEx(playerid, x, y, z, worldid, interiorid, type, compensatedtime, freezeplayer)) return 0;
- if(compensatedtime >= 0)
- {
- acSet[playerid] = 4;
- AC_setX[playerid] = x;
- AC_setY[playerid] = y;
- AC_setZ[playerid] = z;
- acGtc[playerid] = GetTickCount() + 500;
- }
- return 1;
- }
- #if defined _ALS_Streamer_UpdateEx
- #undef Streamer_UpdateEx
- #else
- #define _ALS_Streamer_UpdateEx
- #endif
- #define Streamer_UpdateEx ac_Streamer_UpdateEx
- #endif
- stock AB_SetPlayerPos(playerid, Float:x, Float:y, Float:z)
- {
- new
- ret = SetPlayerPos(playerid, x, y, z);
- if(ret)
- {
- acSet[playerid] = 1;
- AC_setX[playerid] = x;
- AC_setY[playerid] = y;
- AC_setZ[playerid] = z;
- acGtc[playerid] = GetTickCount() + 500;
- }
- return ret;
- }
- #if defined _ALS_SetPlayerPos
- #undef SetPlayerPos
- #else
- #define _ALS_SetPlayerPos
- #endif
- #define SetPlayerPos AB_SetPlayerPos
- #if defined _ALS_OnPlayerUpdate
- #undef OnPlayerUpdate
- #else
- #define _ALS_OnPlayerUpdate
- #endif
- #define OnPlayerUpdate AB_OnPlayerUpdate
- #if defined AB_OnPlayerUpdate
- forward AB_OnPlayerUpdate(playerid);
- #endif
- forward AirReset(playerid);
- public AirReset(playerid)
- {
- AirVehW[playerid] = 0;
- AirW[playerid] = 0;
- return 1;
- }
- new airbcc_TIMER [MAX_PLAYERS];
- forward OnPlayerAirbreak_check(playerid);
- public OnPlayerAirbreak_check(playerid)
- {
- AirVehW[playerid] = 0;
- AirW[playerid] = 0;
- KillTimer(airb_TIMER[playerid]);
- KillTimer(airbcc_TIMER[playerid]);
- new Float:x, Float:y, Float:z;
- GetPlayerPos(playerid, x, y, z);
- SetPlayerPos(playerid, 0.0, 0.0, 5.0);
- airbcc_TIMER[playerid] = SetTimerEx("CheckAirB0", 900, false, "ifff", playerid, x, y, z);
- return 1;
- }
- forward CheckAirB0(playerid, Float:x, Float:y, Float:z);
- public CheckAirB0(playerid, Float:x, Float:y, Float:z)
- {
- if(GetPlayerDistanceFromPoint(playerid, 0.0, 0.0, 5.0) > 10.0)
- {
- CallLocalFunction("OnPlayerAirbreak", "i", playerid);
- }
- SetPlayerPos(playerid, x, y, z);
- }
- forward OnPlayerAirbreak(playerid);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement