Advertisement
Kolorado

OnPlayerAirbreak

Feb 28th, 2018
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.09 KB | None | 0 0
  1. /*
  2.  
  3.  
  4. Anti Airbreak by Kolor4dO */
  5.  
  6.  
  7.  
  8. #include <a_samp>
  9.  
  10. static
  11. o_Anim[MAX_PLAYERS],
  12. Float:AC_oX[MAX_PLAYERS],
  13. Float:AC_oY[MAX_PLAYERS],
  14. Float:AC_oZ[MAX_PLAYERS],
  15. Float:AC_setX[MAX_PLAYERS],
  16. Float:AC_setY[MAX_PLAYERS],
  17. Float:AC_setZ[MAX_PLAYERS],
  18. acSet[MAX_PLAYERS],
  19. acGtc[MAX_PLAYERS],
  20. AirVehW[MAX_PLAYERS],
  21. AirW[MAX_PLAYERS],
  22. airb_TIMER [MAX_PLAYERS],
  23. bool:acTpToZ[MAX_PLAYERS];
  24.  
  25. public OnPlayerUpdate(playerid)
  26. {
  27. if(GetPlayerSurfingVehicleID(playerid) != INVALID_VEHICLE_ID || GetPlayerSurfingObjectID(playerid) != INVALID_OBJECT_ID)
  28. return 1;
  29.  
  30. new
  31. pAnim = GetPlayerAnimationIndex(playerid),
  32. ac_gtc = GetTickCount(),
  33. ac_gpp = GetPlayerPing(playerid),
  34. ac_vehid = GetPlayerVehicleID(playerid),
  35. Float:ac_X,
  36. Float:ac_Y,
  37. Float:ac_Z,
  38. Float:ac_vX,
  39. Float:ac_vY,
  40. Float:ac_vZ,
  41. Float:ac_dist = GetPlayerDistanceFromPoint(playerid, AC_oX[playerid], AC_oY[playerid], AC_oZ[playerid]),
  42. Float:ac_dist_set = GetPlayerDistanceFromPoint(playerid, AC_setX[playerid], AC_setY[playerid], (acTpToZ[playerid] ? ac_Z : AC_setZ[playerid]));
  43.  
  44. GetPlayerPos(playerid, ac_X, ac_Y, ac_Z);
  45.  
  46. if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
  47. GetVehicleVelocity(ac_vehid, ac_vX, ac_vY, ac_vZ);
  48.  
  49. else
  50. GetPlayerVelocity(playerid, ac_vX, ac_vY, ac_vZ);
  51.  
  52. new Float:ac_vsp = ac_GetSpeed(ac_vX, ac_vY, ac_vZ);
  53. ac_vX = ac_GetSpeed(ac_vX, ac_vY, ac_vZ);
  54.  
  55. if(ac_dist > 0.2 && (acSet[playerid] == -1 || ac_dist_set > 0.2) &&
  56. ac_gtc > acGtc[playerid] + ac_gpp)
  57. {
  58. if(ac_vX <= ac_dist * (ac_dist < 1.0 ? 20.0 : 5.0) &&
  59. (acSet[playerid] == -1 || ac_vX <= ac_dist_set * (ac_dist_set < 1.0 ? 20.0 : 5.0)))
  60. {
  61. if(ac_vX && pAnim != 1064 && pAnim != 1139 && pAnim != 1136 && pAnim != 1065 &&
  62. pAnim != 1137 && pAnim != 1063 && pAnim != 1138 && pAnim != 1132 && pAnim != 1133 &&
  63. pAnim != 1196 && pAnim != 1235 && pAnim != 1234 && o_Anim[playerid] != 1064 &&
  64. o_Anim[playerid] != 1139 && o_Anim[playerid] != 1266 && o_Anim[playerid] != 1136 &&
  65. o_Anim[playerid] != 1263 && o_Anim[playerid] != 1137 && o_Anim[playerid] != 1138 &&
  66. o_Anim[playerid] != 1265 && o_Anim[playerid] != 1066 && o_Anim[playerid] != 1067 && o_Anim[playerid] != 1063)
  67. {
  68. if(!IsPlayerInAnyVehicle(playerid))
  69. {
  70. KillTimer(airb_TIMER[playerid]);
  71. AirW[playerid] ++;
  72. airb_TIMER[playerid] = SetTimerEx( "AirReset", 4000, false, "i", playerid);
  73. if(AirW[playerid] >= 8)
  74. {
  75. SetPlayerPos(playerid, AC_oX[playerid], AC_oY[playerid], AC_oZ[playerid]);
  76. CallLocalFunction("OnPlayerAirbreak_check", "i", playerid);
  77. }
  78. }
  79. }
  80. }
  81. }
  82.  
  83. if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
  84. {
  85. if(ac_dist > 9.0 && (acSet[playerid] == -1 || ac_dist_set > 9.0) &&
  86. ac_gtc > acGtc[playerid] + ac_gpp)
  87. {
  88. if(ac_vsp < 16.0)
  89. {
  90. KillTimer(airb_TIMER[playerid]);
  91. AirW[playerid] ++;
  92. airb_TIMER[playerid] = SetTimerEx( "AirReset", 4000, false, "i", playerid);
  93. if(AirVehW[playerid] >= 2) CallLocalFunction("OnPlayerAirbreak", "i", playerid);
  94. }
  95. }
  96. }
  97.  
  98. if(GetPlayerSurfingVehicleID(playerid) == INVALID_VEHICLE_ID && GetPlayerSurfingObjectID(playerid) == INVALID_OBJECT_ID)
  99. {
  100. if(ac_dist > 0.7 && (acSet[playerid] == -1 || ac_dist_set > 0.7) &&
  101. ac_gtc > acGtc[playerid] + ac_gpp)
  102. {
  103. if(ac_vX * ac_vY * ac_vZ == 0.0)
  104. {
  105. if(pAnim == 1189 && o_Anim[playerid] == 1189)
  106. {
  107. KillTimer(airb_TIMER[playerid]);
  108. AirW[playerid] ++;
  109. airb_TIMER[playerid] = SetTimerEx( "AirReset", 4000, false, "i", playerid);
  110. if(AirW[playerid] >= 5)
  111. {
  112. CallLocalFunction("OnPlayerAirbreak", "i", playerid);
  113. }
  114. }
  115. }
  116. }
  117.  
  118. static
  119. Float:vx,
  120. Float:vy,
  121. Float:vz,
  122. Float:vl;
  123.  
  124. GetPlayerVelocity(playerid, vx, vy, vz);
  125.  
  126. vl = floatsqroot( (vx*vx)+(vy*vy)+(vz*vz) ) * 150.0;
  127.  
  128. if(vl == 0.0 && ac_dist > 0.2 && (acSet[playerid] == -1 || ac_dist_set > 0.2) &&
  129. ac_gtc > acGtc[playerid] + ac_gpp)
  130. {
  131. if(pAnim == 1231 && o_Anim[playerid] == 1231)
  132. {
  133. KillTimer(airb_TIMER[playerid]);
  134. AirW[playerid] ++;
  135. airb_TIMER[playerid] = SetTimerEx( "AirReset", 4000, false, "i", playerid);
  136. if(AirW[playerid] >= 3)
  137. {
  138. CallLocalFunction("OnPlayerAirbreak", "i", playerid);
  139. }
  140. }
  141. }
  142. }
  143. AC_oX[playerid] = ac_X;
  144. AC_oY[playerid] = ac_Y;
  145. AC_oZ[playerid] = ac_Z;
  146.  
  147. o_Anim[playerid] = pAnim;
  148.  
  149. #if defined AB_OnPlayerUpdate
  150. return AB_OnPlayerUpdate(playerid);
  151. #else
  152. return 1;
  153. #endif
  154. }
  155.  
  156. static ac_GetSpeed(Float:ac_x, Float:ac_y, Float:ac_z, bool:speed3d = true)
  157. {
  158. if(speed3d) return floatround(VectorSize(ac_x, ac_y, ac_z) * 179.28625);
  159. return floatround(VectorSize(ac_x, ac_y, 0.0) * 179.28625);
  160. }
  161.  
  162. #if defined Streamer_UpdateEx
  163. stock ac_Streamer_UpdateEx(playerid, Float:x, Float:y, Float:z, worldid = -1, interiorid = -1, type = -1, compensatedtime = -1, freezeplayer = 1)
  164. {
  165. if(!Streamer_UpdateEx(playerid, x, y, z, worldid, interiorid, type, compensatedtime, freezeplayer)) return 0;
  166. if(compensatedtime >= 0)
  167. {
  168. acSet[playerid] = 4;
  169. AC_setX[playerid] = x;
  170. AC_setY[playerid] = y;
  171. AC_setZ[playerid] = z;
  172. acGtc[playerid] = GetTickCount() + 500;
  173. }
  174. return 1;
  175. }
  176.  
  177. #if defined _ALS_Streamer_UpdateEx
  178. #undef Streamer_UpdateEx
  179. #else
  180. #define _ALS_Streamer_UpdateEx
  181. #endif
  182. #define Streamer_UpdateEx ac_Streamer_UpdateEx
  183. #endif
  184.  
  185.  
  186.  
  187. stock AB_SetPlayerPos(playerid, Float:x, Float:y, Float:z)
  188. {
  189. new
  190. ret = SetPlayerPos(playerid, x, y, z);
  191.  
  192. if(ret)
  193. {
  194. acSet[playerid] = 1;
  195. AC_setX[playerid] = x;
  196. AC_setY[playerid] = y;
  197. AC_setZ[playerid] = z;
  198. acGtc[playerid] = GetTickCount() + 500;
  199. }
  200. return ret;
  201. }
  202. #if defined _ALS_SetPlayerPos
  203. #undef SetPlayerPos
  204. #else
  205. #define _ALS_SetPlayerPos
  206. #endif
  207. #define SetPlayerPos AB_SetPlayerPos
  208.  
  209.  
  210. #if defined _ALS_OnPlayerUpdate
  211. #undef OnPlayerUpdate
  212. #else
  213. #define _ALS_OnPlayerUpdate
  214. #endif
  215. #define OnPlayerUpdate AB_OnPlayerUpdate
  216.  
  217. #if defined AB_OnPlayerUpdate
  218. forward AB_OnPlayerUpdate(playerid);
  219. #endif
  220.  
  221. forward AirReset(playerid);
  222. public AirReset(playerid)
  223. {
  224. AirVehW[playerid] = 0;
  225. AirW[playerid] = 0;
  226. return 1;
  227. }
  228.  
  229. new airbcc_TIMER [MAX_PLAYERS];
  230.  
  231. forward OnPlayerAirbreak_check(playerid);
  232. public OnPlayerAirbreak_check(playerid)
  233. {
  234. AirVehW[playerid] = 0;
  235. AirW[playerid] = 0;
  236. KillTimer(airb_TIMER[playerid]);
  237. KillTimer(airbcc_TIMER[playerid]);
  238. new Float:x, Float:y, Float:z;
  239. GetPlayerPos(playerid, x, y, z);
  240. SetPlayerPos(playerid, 0.0, 0.0, 5.0);
  241. airbcc_TIMER[playerid] = SetTimerEx("CheckAirB0", 900, false, "ifff", playerid, x, y, z);
  242. return 1;
  243. }
  244. forward CheckAirB0(playerid, Float:x, Float:y, Float:z);
  245. public CheckAirB0(playerid, Float:x, Float:y, Float:z)
  246. {
  247. if(GetPlayerDistanceFromPoint(playerid, 0.0, 0.0, 5.0) > 10.0)
  248. {
  249. CallLocalFunction("OnPlayerAirbreak", "i", playerid);
  250. }
  251. SetPlayerPos(playerid, x, y, z);
  252. }
  253.  
  254. forward OnPlayerAirbreak(playerid);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement