Lifer

Untitled

Jul 21st, 2011
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.33 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. //Settings
  4. #define UPDATE_COUNT 5
  5. #define POSSIBLE_AIRBREAK_COUNT_CAR 9
  6. #define POSSIBLE_AIRBREAK_COUNT_ONFOOT 7
  7. //Settings end
  8.  
  9. new pupdates[MAX_PLAYERS],airbreakcount[MAX_PLAYERS],running=1;
  10.  
  11. public OnFilterScriptInit()
  12. {
  13. new c;
  14. c=POSSIBLE_AIRBREAK_COUNT_CAR;
  15. if(c < 7)
  16. {
  17. print("PERIGO: POSSIVEL_AIRBREAK_USANDO_CARRO é < 7, deve ser pelo menos >=7!!!");
  18. running=0;
  19. print("Anti Airbreak está agora desligado.");
  20. }
  21. c=POSSIBLE_AIRBREAK_COUNT_ONFOOT;
  22. if(c < 5)
  23. {
  24. print("PERIGO: POSSIVEL_AIRBREAK_ANDANDO_APE é < 5, deve ser pelo menos >=5!!!");
  25. running=0;
  26. print("Anti Airbreak está agora desligado.");
  27. }
  28. return 1;
  29. }
  30.  
  31. public OnPlayerCommandText(playerid,cmdtext[])
  32. {
  33. if(!IsPlayerAdmin(playerid)) return 0;
  34.  
  35. if(strcmp(cmdtext, "/toggleaairbreak", true) == 0)
  36. {
  37. switch(running)
  38. {
  39. case 0: {running=1; SendClientMessage(playerid,0xFF0000FF,"Anti-Airbreak foi ligado!");}
  40. case 1: {running=0; SendClientMessage(playerid,0xFF0000FF,"Anti-Airbreak foi desligado!");}
  41. }
  42. return 1;
  43. }
  44.  
  45. new cmd[128];
  46. new idx;
  47. cmd = strtok(cmdtext, idx);
  48. if(strcmp(cmd, "/pairbreakcount", true) == 0)
  49. {
  50. new tmp[128];
  51. tmp=strtok(cmdtext,idx);
  52. if(!strlen(tmp)) { SendClientMessage(playerid,0xFF0000FF,"Use: /pairbreakcount (id)"); return 1; }
  53. new id = strval(tmp);
  54. new str[60],name[MAX_PLAYER_NAME];
  55. GetPlayerName(id,name,MAX_PLAYER_NAME);
  56. format(str,sizeof(str),"%s's atual airbreakcount é %d",name,airbreakcount[id]);
  57. SendClientMessage(playerid,0xFF0000FF,str);
  58. return 1;
  59. }
  60.  
  61. return 0;
  62. }
  63.  
  64. strtok(const text[], &index)
  65. {
  66. new length = strlen(text);
  67. while ((index < length) && (text[index] <= ' '))
  68. {
  69. index++;
  70. }
  71.  
  72. new offset = index;
  73. new result[20];
  74. while ((index < length) && (text[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  75. {
  76. result[index - offset] = text[index];
  77. index++;
  78. }
  79. result[index - offset] = EOS;
  80. return result;
  81. }
  82.  
  83. public OnPlayerUpdate(playerid)
  84. {
  85. // ANTIAIRBREAK
  86. pupdates[playerid]++;
  87. if(pupdates[playerid] > UPDATE_COUNT && running == 1)
  88. {
  89. pupdates[playerid]=0;
  90. new check;
  91. if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER && IsVehicleValid(GetPlayerVehicleID(playerid)))
  92. {
  93. new Float:vx,Float:vy,Float:vz;
  94. GetVehicleVelocity(GetPlayerVehicleID(playerid),vx,vy,vz);
  95. if(vx==0.0 && vy==0.0 && vz < -0.0032 && vz > -0.022)
  96. {
  97. if(IsPlayerInWater(playerid)==0)
  98. {
  99. check=1;
  100. }
  101. else
  102. {
  103. check=3;
  104. }
  105. }
  106. }
  107. else
  108. {
  109. if(GetPlayerState(playerid)==PLAYER_STATE_ONFOOT && GetPlayerSurfingVehicleID(playerid)==INVALID_VEHICLE_ID)
  110. {
  111. new Float:vx,Float:vy,Float:vz,Float:px,Float:py,Float:pz;
  112. GetPlayerVelocity(playerid,vx,vy,vz);
  113. pupdates[playerid]=0;
  114. new keys,ud,lr;
  115. GetPlayerKeys(playerid,keys,ud,lr);
  116. if (keys & KEY_SPRINT)
  117. {
  118. if(-0.022 < vz < -0.0040 && -0.235 < vx < 0.235 && -0.235 < vy < 0.235)
  119. {
  120. if(!IsPlayerInRangeOfPoint(playerid,2.0,GetPVarFloat(playerid,"oposx"),GetPVarFloat(playerid,"oposy"),GetPVarFloat(playerid,"oposz")) || -0.5>(GetPVarFloat(playerid,"oposz")-pz)>-0.1 || 0.075>(GetPVarFloat(playerid,"oposz")-pz)>-0.075)
  121. {
  122. if(IsPlayerInWater(playerid)==0)
  123. {
  124. check=2;
  125. if(airbreakcount[playerid] > (POSSIBLE_AIRBREAK_COUNT_ONFOOT-2))
  126. {
  127. SetPlayerVelocity(playerid,0.3,0.3,0.3);
  128. }
  129. }
  130. else
  131. {
  132. check=3;
  133. }
  134. }
  135. SetPVarFloat(playerid,"oposx",px);
  136. SetPVarFloat(playerid,"oposy",py);
  137. SetPVarFloat(playerid,"oposz",pz);
  138. }
  139. }
  140. else
  141. {
  142. if(-0.022 < vz < -0.0040 && -0.121 < vx < 0.121 && -0.121 < vy < 0.121)
  143. {
  144. if(!IsPlayerInRangeOfPoint(playerid,2.0,GetPVarFloat(playerid,"oposx"),GetPVarFloat(playerid,"oposy"),GetPVarFloat(playerid,"oposz")) || -0.5>(GetPVarFloat(playerid,"oposz")-pz)>-0.1 || 0.075>(GetPVarFloat(playerid,"oposz")-pz)>-0.075)
  145. {
  146. if(IsPlayerInWater(playerid)==0)
  147. {
  148. check=2;
  149. if(airbreakcount[playerid] > (POSSIBLE_AIRBREAK_COUNT_ONFOOT-2))
  150. {
  151. SetPlayerVelocity(playerid,0.3,0.3,0.3);
  152. }
  153. }
  154. else
  155. {
  156. check=3;
  157. }
  158. }
  159. SetPVarFloat(playerid,"oposx",px);
  160. SetPVarFloat(playerid,"oposy",py);
  161. SetPVarFloat(playerid,"oposz",pz);
  162. }
  163. }
  164. }
  165. }
  166. if(check > 0)
  167. {
  168. if(check < 3)
  169. {
  170. new POSSIBLE_AIRBREAK_COUNT;
  171. switch(check)
  172. {
  173. case 1: POSSIBLE_AIRBREAK_COUNT=POSSIBLE_AIRBREAK_COUNT_CAR;
  174. case 2: POSSIBLE_AIRBREAK_COUNT=POSSIBLE_AIRBREAK_COUNT_ONFOOT;
  175. }
  176. airbreakcount[playerid]++;
  177. if(airbreakcount[playerid] > POSSIBLE_AIRBREAK_COUNT)
  178. {
  179. airbreakcount[playerid]=0;
  180. new ip[20],name[24];
  181. GetPlayerName(playerid,name,sizeof(name));
  182. GetPlayerIp(playerid,ip,sizeof(ip));
  183. switch(check)
  184. {
  185. case 1:printf("Airbreak: %s(%s) foi banido. Reação: Airbreak [CARRO]",name,ip);
  186. case 2:printf("Airbreak: %s(%s) foi banido. Reação: Airbreak [A PÉ]",name,ip);
  187. }
  188. Ban(playerid);
  189. }
  190. }
  191. }
  192. else
  193. {
  194. airbreakcount[playerid]=0;
  195. }
  196. }
  197. return 1;
  198. }
  199.  
  200. public OnPlayerStateChange(playerid, newstate, oldstate)
  201. {
  202. airbreakcount[playerid]=0;
  203. return 1;
  204. }
  205.  
  206. stock IsVehicleValid(id)
  207. {
  208. new type=GetVehicleModel(id);
  209. new blocked[]={ 548, 425, 417, 487, 488, 497, 563, 447, 469, 520 };
  210. for(new i;i<sizeof(blocked);i++)
  211. {
  212. if(type == blocked[i])
  213. {
  214. return 0;
  215. }
  216. }
  217. return 1;
  218. }
  219.  
  220. stock IsPlayerInArea(playerid, Float:max_x, Float:min_x, Float:max_y, Float:min_y)
  221. {
  222. new Float:X, Float:Y, Float:Z;
  223. GetPlayerPos(playerid, X, Y, Z);
  224. if(X <= max_x && X >= min_x && Y <= max_y && Y >= min_y) return 1;
  225. return 0;
  226. }
  227.  
  228. stock IsPlayerInWater(playerid)
  229. {
  230. new Float:x,Float:y,Float:pz;
  231. GetPlayerPos(playerid,x,y,pz);
  232. if (
  233. (IsPlayerInArea(playerid, 2032.1371, 1841.2656, 1703.1653, 1467.1099) && pz <= 9.0484) //lv piratenschiff
  234. || (IsPlayerInArea(playerid, 2109.0725, 2065.8232, 1962.5355, 10.8547) && pz <= 10.0792) //lv visage
  235. || (IsPlayerInArea(playerid, -492.5810, -1424.7122, 2836.8284, 2001.8235) && pz <= 41.06) //lv staucamm
  236. || (IsPlayerInArea(playerid, -2675.1492, -2762.1792, -413.3973, -514.3894) && pz <= 4.24) //sf südwesten kleiner teich
  237. || (IsPlayerInArea(playerid, -453.9256, -825.7167, -1869.9600, -2072.8215) && pz <= 5.72) //sf gammel teich
  238. || (IsPlayerInArea(playerid, 1281.0251, 1202.2368, -2346.7451, -2414.4492) && pz <= 9.3145) //ls neben dem airport
  239. || (IsPlayerInArea(playerid, 2012.6154, 1928.9028, -1178.6207, -1221.4043) && pz <= 18.45) //ls mitte teich
  240. || (IsPlayerInArea(playerid, 2326.4858, 2295.7471, -1400.2797, -1431.1266) && pz <= 22.615) //ls weiter südöstlich
  241. || (IsPlayerInArea(playerid, 2550.0454, 2513.7588, 1583.3751, 1553.0753) && pz <= 9.4171) //lv pool östlich
  242. || (IsPlayerInArea(playerid, 1102.3634, 1087.3705, -663.1653, -682.5446) && pz <= 112.45) //ls pool nordwestlich
  243. || (IsPlayerInArea(playerid, 1287.7906, 1270.4369, -801.3882, -810.0527) && pz <= 87.123) //pool bei maddog's haus oben
  244. || (pz < 1.5)
  245. )
  246. {
  247. return 1;
  248. }
  249. return 0;
  250. }
Advertisement
Add Comment
Please, Sign In to add comment