pbAntiCheat.inc 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916
  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. //
  4. // #### ######## ###### ######## ######## ### ## ##
  5. // ## ## ## ## ## ## ## ## ## ### ###
  6. // ## ## ## ## ## ## ## ## #### ####
  7. // ## ######## ###### ## ###### ## ## ## ### ##
  8. // ## ## ## ## ## ######### ## ##
  9. // ## ## ## ## ## ## ## ## ## ##
  10. // #### ## ###### ## ######## ## ## ## ##
  11. //
  12. //
  13. // Por Bruno da Silva (iPs DraKiNs) e Paulo (iPs Paulo)
  14. //
  15. // Acesse meu blog sobre programação www.brunodasilva.com
  16. //
  17. // --------------------------------------------
  18. //
  19. // Detectar:
  20. // Bot,
  21. // Death Flood,
  22. // Surf Vehicle,
  23. // Car Teleport,
  24. // State Hack,
  25. // No-Reload,
  26. // Ammo Hack,
  27. // Freeze Hack,
  28. // Score Hack,
  29. // Health Hack,
  30. // Armour Hack,
  31. // Publish Text,
  32. // Offend Text,
  33. // Flood Text,
  34. // Teleport Hack,
  35. // Air Break,
  36. // Player Bugger,
  37. // High Ping,
  38. // Spider Hack,
  39. // CP Race Hack,
  40. // Speed Hack,
  41. // Player Speed Hack,
  42. // Fly Hack
  43. //
  44. // --------------------------------------------
  45. //
  46. // www.brunodasilva.com
  47. // * Bruno da Silva (email@brunodasilva.com)
  48. //
  49. // Ingresse também na [iPs]TeaM
  50. // wwww.ips-team.forumeiros.com
  51. //
  52. //////////////////////////////////////////////////////////////////////////////////
  53. enum {
  54. // Anti DDos Bots
  55. PLAYER_BOT_LEVEL3,
  56. PLAYER_BOT_LEVEL2,
  57. PLAYER_BOT_LEVEL1,
  58. // Anti Cleo4 Fake-kill
  59. PLAYER_DEATHFLOOD_LEVEL3,
  60. PLAYER_DEATHFLOOD_LEVEL2,
  61. PLAYER_DEATHFLOOD_LEVEL1,
  62. // Anti Bug Cars
  63. PLAYER_SURF_VEHICLE,
  64. PLAYER_CAR_TELEPORT,
  65. PLAYER_STATE_HACK,
  66. // hackings
  67. PLAYER_FREEZE_HACK,
  68. PLAYER_SCORE_HACK,
  69. PLAYER_HEALTH_HACK,
  70. PLAYER_ARMOUR_HACK,
  71. // Text Chat
  72. PLAYER_PUBLISH_TEXT,
  73. PLAYER_OFFEND_TEXT,
  74. PLAYER_FLOOD_TEXT,
  75. // pos cheat
  76. PLAYER_TELEPORT_HACK,
  77. PLAYER_AIRBREAK_HACK,
  78. PLAYER_BUGGER_HACK,
  79. // outros
  80. PLAYER_HIGH_PING,
  81. PLAYER_SPIDER_HACK,
  82. PLAYER_CPRACE_HACK,
  83. PLAYER_SPEED_HACK,
  84. PLAYER_PSPEED_HACK,
  85. PLAYER_FLY_HACK
  86. }
  87. new connect = -1,
  88. Float: g_ucPos[4],
  89. databaseIP[MAX_PLAYERS][20],
  90. Float:g_diferencasAngle[MAX_VEHICLES],
  91. vehVelocity[MAX_VEHICLES],
  92. bool: vehRespawn[MAX_VEHICLES],
  93. bool: pOPC,
  94. bool: pOPS,
  95. bool: pOPDI,
  96. bool: pOPT,
  97. bool: pOPD,
  98. bool: pOVM,
  99. bool: pOPERCP,
  100. bool: pOPU,
  101. bool: pOPSC,
  102. bool: pOUVU;
  103. forward OnPlayerHacking(playerid, hackid);
  104. #define INVALID_CHAT_BLOCK
  105. #define SERVER_SIDE_DELAY (0002)
  106. #define MAX_DISTANCE_DEF (83.1)
  107. #define MAX_PING (0800)
  108. // =============================================================================
  109. //
  110. // OBSERVAÇõES IMPORTANTES:
  111. // #define INVALID_CHAT_BLOCK
  112. // Em caso de não quiser bloquear o texto em caso de texto inválido
  113. // Texto inválido, spam, flood, palavreado, ofensa, publicação. etc
  114. // Ping acima de 1 segundo (1000 ms) poderá ocorrer graves problemas de precisão no anti cheater.
  115. // Em caso de ping muito elevado aconselha-se o uso de SERVER_SIDE_DELAY elevado para maior precisão
  116. // SERVER_SIDE_DELAY equivale ao tempo de delay entre o uso de uma função registrada
  117. // que influencia no detectamento do anti cheater. Aconselhável 1 a 5 segundos.
  118. // Dependendo da conexão do servidor você coloca maior delay ou menor dealay
  119. // MAX_DISTANCE_DEF é essencial para busca e detecção de anti-teleport e air break
  120. // O número padrão foi calculado e não houve bugs por parte do sistema
  121. // A única coisa que pode influenciar será o sistema de SetPlayerPos. Mas o SERVER_SIDE_DELAY supriu isto com precisão
  122. // Este sistema apenas detecta cheaters. É aconselhavél a checagem de um administrador real antes de aplicar o banimento.
  123. // ========================================================================================================
  124. #define pFunction%0(%1) %0(%1); public%0(%1)
  125. #define Hook%0(%1) stock%0_pB(%1)
  126. // ---------------------------------------------
  127. // Nesta parte aparecem funções hookeadas
  128. // Elas são essenciais para ter controle server-side detalhado
  129. // Essencial para qualquer anti-hack. Controle minucioso
  130. // Para o funcionamento disto precisa do filterscript
  131. // Hookei apenas as mais importantes callbacks nativas da sa:mp.
  132. // Daria muito trabalho "hookear" todas
  133. // ---------------------------------------------
  134. Hook SetPlayerScore(playerid, value){
  135. return SetPVarInt(playerid, #registerScore, value), SetPlayerScore(playerid, value);
  136. }
  137. Hook PutPlayerInVehicle(playerid,vehicleid, seatid) {
  138. return SetPVarInt(playerid, #registerState, (gettime() - SERVER_SIDE_DELAY)), PutPlayerInVehicle(playerid, vehicleid, seatid);
  139. }
  140. Hook SetVehicleVelocity(vehicleid, Float: pX, Float: pY, Float: pZ) {
  141. return vehVelocity[vehicleid] = gettime(), SetVehicleVelocity(vehicleid, pX, pY, pZ);
  142. }
  143. Hook SetVehiclePos(vehicleid, Float: pX, Float: pY, Float: pZ) {
  144. for( new i = GetMaxPlayers() - 1; i > -1; --i ) {
  145. if( GetPlayerVehicleID(i) == vehicleid ) {
  146. SetPVarInt(i, #tPosSet, gettime());
  147. break;
  148. }
  149. }
  150. return SetVehiclePos(vehicleid, pX, pY, pZ);
  151. }
  152. Hook SetPlayerPos(playerid, Float: pX, Float: pY, Float: pZ) {
  153. return SetPVarInt(playerid, #tPosSet, gettime()), SetPlayerPos(playerid, pX, pY, pZ);
  154. }
  155. Hook TogglePlayerC(playerid, {bool, _}: control) {
  156. if(control) {
  157. static Float: pX, Float: pY, Float: pZ;
  158. GetPlayerPos(playerid, pX, pY, pZ);
  159. SetPVarFloat(playerid, "xPosControll", pX),
  160. SetPVarFloat(playerid, "yPosControll", pY),
  161. SetPVarFloat(playerid, "zPosControll", pZ);
  162. } else {
  163. SetPVarFloat(playerid, "xPosControll", 0.0);
  164. SetPVarFloat(playerid, "yPosControll", 0.0);
  165. SetPVarFloat(playerid, "zPosControll", 0.0);
  166. }
  167. TogglePlayerControllable(playerid, control);
  168. return SetPVarInt(playerid, "PlayerControllable", _:!control);
  169. }
  170. Hook SetPlayerHealth(playerid, Float:health) {
  171. return SetPVarFloat(playerid, #pHealth, health), SetPlayerHealth(playerid, health);
  172. }
  173. Hook SetPlayerArmour(playerid, Float:armour) {
  174. return SetPVarFloat(playerid, #pArmour, armour), SetPlayerArmour(playerid, armour);
  175. }
  176. Hook SetVehicleToRespawn(vehicleid) {
  177. return vehRespawn[vehicleid] = true, SetVehicleToRespawn(vehicleid);
  178. }
  179. isPlayerInWater_pB(playerid) { //Coords By Synchro
  180. static Float:fX, Float:fY, Float:fZ; GetPlayerPos(playerid, fX, fY, fZ);
  181. if((fX >= 2044.6 && fX <= 2192.984 && fY >= 1206.358 && fY <= 1376.552) && fZ < 0xA) return 1;
  182. else if((fX >= 2048.504 && fX <= 2185.174 && fY >= 1063.239 && fY <= 1202.49) && fZ < 0xA) return 1;
  183. else if((fX >= 2204.698 && fX <= 2204.698 && fY >= 1426.837 && fY <= 1430.705) && fZ < 0xA) return 1;
  184. else if((fX >= 2032.885 && fX <= 2114.887 && fY >= 1852.325 && fY <= 1991.575) && fZ < 0xC) return 1;
  185. else if((fX >= 2517.086 && fX <= 2606.897 && fY >= 2316.493 && fY <= 2420.93) && fZ < 0x16) return 1;
  186. else if((fX >= 2554.5996 && fX <= 2507.7683 && fY >= 1548.6178 && fY <= 1588.9154) && fZ < 0xF) return 1;
  187. else if((fX >= -2043.628 && fX <= -1973.561 && fY >= -980.9415 && fY <= -724.0283) && fZ < 0x20) return 1;
  188. else if((fX >= -2753.912 && fX <= -2665.071 && fY >= -522.3632 && fY <= -380.3444) && fZ < 0x05) return 1;
  189. else if((fX >= 1219.864 && fX <= 1292.118 && fY >= -2435.881 && fY <= -2325.344) && fZ < 0xF) return 1;
  190. else if((fX >= 1923.388 && fX <= 2010.854 && fY >= -1223.924 && fY <= -1168.656) && fZ < 0x16) return 1;
  191. else if((fX >= 1269.301 && fX <= 1314.935 && fY >= -837.0452 && fY <= -781.7769) && fZ < 0x5A) return 1;
  192. else if((fX >= 1087.3953 && fX <= 1102.3138 && fY >= -682.6734 && fY <= -663.0043) && fZ < 0x71) return 1;
  193. else if((fX >= 1268.6118 && fX <= 1291.8774 && fY >= -784.2910 && fY <= -764.6104) && fZ < 0x43D) return 1;
  194. else if(fZ < 0xF) return 1;
  195. return 0;
  196. }
  197. isPlayerUsingSwimAnim_pB(playerid) { // By Synchro
  198. if(IsPlayerInAnyVehicle(playerid) || GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return 0;
  199. static animlib[32], animname[32];
  200. GetAnimationName(GetPlayerAnimationIndex(playerid),animlib,32,animname,32);
  201. if(!strcmp(animlib, "SWIM", true) && !strcmp(animname, "SWIM_GLIDE", true)) return 1;
  202. else if(!strcmp(animlib, "SWIM", true) && !strcmp(animname, "SWIM_BREAST", true)) return 1;
  203. else if(!strcmp(animlib, "SWIM", true) && !strcmp(animname, "SWIM_CRAWL", true)) return 1;
  204. else if(!strcmp(animlib, "SWIM", true) && !strcmp(animname, "SWIM_DIVE_UNDER", true)) return 1;
  205. else if(!strcmp(animlib, "SWIM", true) && !strcmp(animname, "SWIM_DIVE_GLIDE", true)) return 1;
  206. else if(!strcmp(animlib, "SWIM", true) && !strcmp(animname, "SWIM_UNDER", true)) return 1;
  207. else if(!strcmp(animlib, "SWIM", true) && !strcmp(animname, "SWIM_TREAD", true)) return 1;
  208. return 0;
  209. }
  210. getPlayerSpeed_pB(playerid) {
  211. static Float: ST[3];
  212. GetVehicleVelocity(GetPlayerVehicleID(playerid), ST[0], ST[1], ST[2]);
  213. return floatround(floatmul(floatsqroot(floatadd(floatpower(ST[0], 2), floatpower(ST[1], 2))), 170.0));
  214. }
  215. #if !defined varGet
  216. #define varGet(%0) getproperty(0,%0)
  217. #endif
  218. #if !defined varSet
  219. #define varSet(%0,%1) setproperty(0, %0, %1)
  220. #endif
  221. public OnGameModeInit() {
  222. pOPC = funcidx(#ExOnPlayerConnect) != -1;
  223. pOPS = funcidx(#ExOnPlayerSpawn) != -1;
  224. pOPDI = funcidx(#ExOnPlayerDisconnect) != -1;
  225. pOPT = funcidx(#ExOnPlayerText) != -1;
  226. pOPD = funcidx(#ExOnPlayerDeath) != -1;
  227. pOVM = funcidx(#ExOnVehicleMod) != -1;
  228. pOPERCP = funcidx(#ExOnPlayerEnterRaceCP) != -1;
  229. pOPU = funcidx(#ExOnPlayerUpdate) != -1;
  230. pOPSC = funcidx(#ExOnPlayerStateChange) != -1;
  231. pOUVU = funcidx(#ExOnUnoccupiedVehicleUpdate) != -1;
  232. return CallLocalFunction(#ExOnGameModeInit, #);
  233. }
  234. #if defined _ALS_OnGameModeInit
  235. #undef OnGameModeInit
  236. #else
  237. #define _ALS_OnGameModeInit
  238. #endif
  239. #define OnGameModeInit ExOnGameModeInit
  240. forward ExOnGameModeInit();
  241. public OnPlayerConnect(playerid) {
  242. CallLocalFunction("registrarJogador_pB", "i", playerid);
  243. return (pOPC ? CallLocalFunction("ExOnPlayerConnect", "i", playerid) : 1);
  244. }
  245. #if defined _ALS_OnPlayerConnect
  246. #undef OnPlayerConnect
  247. #else
  248. #define _ALS_OnPlayerConnect
  249. #endif
  250. #define OnPlayerConnect ExOnPlayerConnect
  251. forward ExOnPlayerConnect(playerid);
  252. public OnPlayerSpawn(playerid) {
  253. if(!GetPVarInt(playerid, "pSpawned")) SetPVarInt(playerid, "pSpawned", true);
  254. SetPVarFloat(playerid, #pHealth, 100.0);
  255. SetPVarFloat(playerid, #pArmour, 0.0);
  256. SetPlayerHealth(playerid, 100.0);
  257. SetPlayerArmour(playerid, 0.0);
  258. return (pOPS ? CallLocalFunction("ExOnPlayerSpawn", "i", playerid) : 1);
  259. }
  260. #if defined _ALS_OnPlayerSpawn
  261. #undef OnPlayerSpawn
  262. #else
  263. #define _ALS_OnPlayerSpawn
  264. #endif
  265. #define OnPlayerSpawn ExOnPlayerSpawn
  266. forward ExOnPlayerSpawn(playerid);
  267. public OnPlayerDisconnect(playerid, reason) {
  268. // Não retire está parte. Isto serve para não enviar mensagens de desconecção quando o player é bot ddos
  269. if(GetPVarInt(playerid, #jogadorDisponivel)) return false;
  270. return (pOPDI ? CallLocalFunction("ExOnPlayerDisconnect", "is", playerid, reason) : 1);
  271. }
  272. #if defined _ALS_OnPlayerDisconnect
  273. #undef OnPlayerDisconnect
  274. #else
  275. #define _ALS_OnPlayerDisconnect
  276. #endif
  277. #define OnPlayerDisconnect ExOnPlayerDisconnect
  278. forward ExOnPlayerDisconnect(playerid,reason);
  279. new const palavreado[][24] = {
  280. "daputa", "babaca", "baitola", "piranha", "bicha", "bichona", "biscat", "bitch", "bix", "boiola", "boiolona", "buceta", "bucetudo", "cuzona", "bund", "burr", "fude", "cacet", "viad",
  281. "caral", "vadi", "carai", "rola", "chup", "idiot", "corno", "nocu", "eucu", "ocu", "cusa", "cusi", "cuza", "cuzinho", "piroca", "embecil", "fdp", "foda", "fode", "fuck", "fud",
  282. "hetard", "homo", "imbess", "jegu", "kacet", "karai", "karaleo", "kct", "kral", "krl", "noku", "lasarent", "lazarent", "mula", "otari", "pnc", "pereb", "penis","pint", "prosti",
  283. "punhet", "put", "retardado", "tnc", "viad", "viadi", "vsf", "vtnc", "sobe", "vogelz", "baranga", "vagab", "broxa", "ignorant", "comed", "ejacu", "prosti", "cachorr", "surub", "peni",
  284. "chup", "pau", "viad", "perere", "bucet", "bicha", "bixa", "gay", "desgra", "troxa", "tomanocu", "seucu"
  285. };
  286. public OnPlayerText(playerid, text[]) {
  287. /*--------------------------------------------------
  288. *
  289. * Anti Publicação de IP Inteligente
  290. * Usando OnPlayerText com manipulação de strings e outros
  291. * A precisão deste sistema está em torno de 95%
  292. *
  293. * Detecta: 127.0.0.1 | 1 2 7 . 0 0 1 etc
  294. -------------------------------------------------*/
  295. static szText[128], numerosNochat, pontosNochat, j;
  296. numerosNochat = -1, pontosNochat = -1, j = 0, szText[0] = EOS;
  297. for(new i; text[i]; i++) {
  298. if(text[i] >= '0' && '9' >= text[i] || (text[i] == '.' || text[i] == ':')) {
  299. if(text[i] == '.' || text[i] == ':') pontosNochat++;
  300. else numerosNochat++;
  301. if(numerosNochat >= 8 && pontosNochat >= 3) {
  302. CallLocalFunction("OnPlayerHacking", "ii", playerid, PLAYER_PUBLISH_TEXT);
  303. #if defined INVALID_CHAT_BLOCK
  304. return false;
  305. #else
  306. break;
  307. #endif
  308. }
  309. }
  310. switch(text[i]) {
  311. case '0':{ szText[j] = 'o'; j++; continue; }
  312. case '1':{ szText[j] = 'i'; j++; continue; }
  313. case '2':{ szText[j] = 'z'; j++; continue; }
  314. case '3':{ szText[j] = 'e'; j++; continue; }
  315. case '4':{ szText[j] = 'a'; j++; continue; }
  316. case '5':{ szText[j] = 's'; j++; continue; }
  317. case '6':{ szText[j] = 'g'; j++; continue; }
  318. case '7':{ szText[j] = 't'; j++; continue; }
  319. case '8':{ szText[j] = 'b'; j++; continue; }
  320. case 65 .. 90, 97 .. 122: { szText[j] = tolower(text[i]); j++; continue; }
  321. }
  322. }
  323. /*--------------------------------------------------
  324. *
  325. * Anti Palavreado Inteligente
  326. * Usando OnPlayerText com manipulação de strings e outros
  327. * A precisão deste sistema está em torno de 85%
  328. *
  329. * Detecta: buceta, b - u c |e t-a, buc 3 7 4 etc
  330. -------------------------------------------------*/
  331. for(new i = 0; i < sizeof(palavreado); i++) {
  332. if(strfind(szText, palavreado[i], false) != -1) {
  333. CallLocalFunction("OnPlayerHacking", "ii", playerid, PLAYER_OFFEND_TEXT);
  334. #if defined INVALID_CHAT_BLOCK
  335. return false;
  336. #else
  337. break;
  338. #endif
  339. }
  340. }
  341. /*--------------------------------------------------
  342. *
  343. * Anti Flood
  344. * Usando OnPlayerText com gettime e outros
  345. * A precisão deste sistema está em torno de 95%
  346. *
  347. -------------------------------------------------*/
  348. if((gettime() - GetPVarInt(playerid, #floodChat)) < 3) {
  349. CallLocalFunction("OnPlayerHacking", "ii", playerid, PLAYER_FLOOD_TEXT);
  350. #if defined INVALID_CHAT_BLOCK
  351. return false;
  352. #endif
  353. }
  354. SetPVarInt(playerid, #floodChat, gettime());
  355. return (pOPT ? CallLocalFunction("ExOnPlayerText", "is", playerid, text) : 1);
  356. }
  357. #if defined _ALS_OnPlayerText
  358. #undef OnPlayerText
  359. #else
  360. #define _ALS_OnPlayerText
  361. #endif
  362. #define OnPlayerText ExOnPlayerText
  363. forward ExOnPlayerText(playerid, text[]);
  364. public OnPlayerDeath(playerid,killerid,reason) {
  365. /*--------------------------------------------------
  366. *
  367. * Anti Fake Kill
  368. * Usando OnPlayerDeath com gettime e outros
  369. * A precisão deste sistema está dividido em partes
  370. *
  371. * PLAYER_DEATHFLOOD_LEVEL1 -> 070%
  372. * PLAYER_DEATHFLOOD_LEVEL2 -> 090%
  373. * PLAYER_DEATHFLOOD_LEVEL3 -> 100%
  374. *
  375. *
  376. -------------------------------------------------*/
  377. if(gettime() - GetPVarInt(playerid, #registerDeath) < 20) {
  378. if(GetPVarInt(playerid, #registerValDeath) > 15) {
  379. CallLocalFunction("OnPlayerHacking", "ii", playerid, PLAYER_DEATHFLOOD_LEVEL1);
  380. }
  381. if(gettime() - GetPVarInt(playerid, #registerDeath) < 2) {
  382. CallLocalFunction("OnPlayerHacking", "ii", playerid, PLAYER_DEATHFLOOD_LEVEL2);
  383. }
  384. if(gettime() - GetPVarInt(playerid, #registerDeath) < 5) {
  385. if(GetPVarInt(playerid, #registerValDeath) > 3) {
  386. CallLocalFunction("OnPlayerHacking", "ii", playerid, PLAYER_DEATHFLOOD_LEVEL3);
  387. }
  388. }
  389. }
  390. SetPVarInt(playerid, #registerDeath, gettime());
  391. SetPVarInt(playerid, #registerValDeath, GetPVarInt(playerid, #registerValDeath) +1);
  392. return (pOPD ? CallLocalFunction("ExOnPlayerDeath", "i", playerid) : 1);
  393. }
  394. #if defined _ALS_OnPlayerDeath
  395. #undef OnPlayerDeath
  396. #else
  397. #define _ALS_OnPlayerDeath
  398. #endif
  399. #define OnPlayerDeath ExOnPlayerDeath
  400. forward ExOnPlayerDeath(playerid, killerid, reason);
  401. public OnVehicleMod(playerid, vehicleid, componentid) {
  402. if(!GetPlayerInterior(playerid)) {
  403. CallLocalFunction("OnPlayerHacking", "ii", playerid, PLAYER_CPRACE_HACK);
  404. }
  405. return (pOVM ? CallLocalFunction("ExOnVehicleMod", "ddd", playerid, vehicleid, componentid) : 1);
  406. }
  407. #if defined _ALS_OnVehicleMod
  408. #undef OnVehicleMod
  409. #else
  410. #define _ALS_OnVehicleMod
  411. #endif
  412. #define OnVehicleMod ExOnVehicleMod
  413. forward ExOnVehicleMod(playerid,vehicleid,componentid);
  414. public OnPlayerEnterRaceCheckpoint(playerid) {
  415. if(IsPlayerInAnyVehicle(playerid)) {
  416. if(!getPlayerSpeed_pB(playerid)) {
  417. if(GetPVarInt(playerid, #checkHack) > 3) {
  418. CallLocalFunction("OnPlayerHacking", "ii", playerid, PLAYER_CPRACE_HACK);
  419. SetPVarInt(playerid, #checkHack, 0);
  420. }
  421. SetPVarInt(playerid, #checkHack, GetPVarInt(playerid, #checkHack)+1);
  422. }
  423. }
  424. return (pOPERCP ? CallLocalFunction("ExOnPlayerEnterRaceCP", "i", playerid) : 1);
  425. }
  426. #if defined _ALS_OnPlayerEnterRaceCP
  427. #undef OnPlayerEnterRaceCheckpoint
  428. #else
  429. #define _ALS_OnPlayerEnterRaceCP
  430. #endif
  431. #define OnPlayerEnterRaceCheckpoint ExOnPlayerEnterRaceCP
  432. forward ExOnPlayerEnterRaceCP(playerid);
  433. public OnPlayerUpdate(playerid) {
  434. if(!IsPlayerNPC(playerid)) {
  435. if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) {
  436. /*--------------------------------------------------
  437. *
  438. * Anti Speed Hack
  439. * Usando GetPlayerSpeedANTIHACK com variáveis
  440. * A precisão deste sistema fica em torno de 100%
  441. *
  442. -------------------------------------------------*/
  443. if(GetPVarInt(playerid, #checkSpeedtime)) {
  444. if(gettime() - GetPVarInt(playerid, #checkSpeedtime) > 1) {
  445. TogglePlayerControllable(playerid, true);
  446. SetPVarInt(playerid, "checkSpeedtime", 0);
  447. }
  448. }
  449. if(getPlayerSpeed_pB(playerid) > 260) {
  450. if((gettime() - vehVelocity[GetPlayerVehicleID(playerid)]) > 10) {
  451. TogglePlayerControllable(playerid, false);
  452. SetPVarInt(playerid, "checkSpeedtime", gettime());
  453. return CallLocalFunction("OnPlayerHacking", "ii", playerid, PLAYER_SPEED_HACK), true;
  454. }
  455. }
  456. /*--------------------------------------------------
  457. *
  458. * Anti Spider Car
  459. * Usando GetVehicleRotationQuat
  460. * A precisão deste sistema fica em torno de 75%
  461. *
  462. -------------------------------------------------*/
  463. static Float: pW, Float: pX, Float: pY, Float: pZ;
  464. GetVehicleRotationQuat(GetPlayerVehicleID(playerid), pW, pX, pY, pZ);
  465. pW = atan2(2 * ((pY * pZ) + (pX * pW)), (-(pX * pX) - (pY * pY) + (pZ * pZ) + (pW * pW)));
  466. // OBS: Inclinação de 5 graus. Construções mais inclinadas podem
  467. // fazer o veículo inclinar mais. Mas para evitar falsos reports deixe mais ou menos este valor
  468. if((85.0 < pW < 90.0) || (-85.0 > pW > -90.0)) {
  469. SetPVarInt(playerid, #spiderCar, GetPVarInt(playerid, #spiderCar) +1);
  470. if(GetPVarInt(playerid, #spiderCar) > 40) {
  471. CallLocalFunction("OnPlayerHacking", "ii", playerid, PLAYER_SPIDER_HACK);
  472. SetPVarInt(playerid, #spiderCar, 0);
  473. }
  474. }
  475. }
  476. /*--------------------------------------------------
  477. *
  478. * Anti Health/Armour Hack
  479. * Usando GetPlayer(Health/Armour) com variáveis server sided
  480. * A precisão deste sistema fica em torno de 100%
  481. *
  482. -------------------------------------------------*/
  483. static Float: pLife;
  484. GetPlayerHealth(playerid, pLife);
  485. if(pLife > GetPVarFloat(playerid, #pHealth)) {
  486. SetPlayerHealth(playerid, GetPVarFloat(playerid, #pHealth));
  487. CallLocalFunction("OnPlayerHacking", "ii", playerid, PLAYER_HEALTH_HACK);
  488. }
  489. GetPlayerArmour(playerid, pLife);
  490. if(pLife > GetPVarFloat(playerid, #pArmour)) {
  491. SetPlayerArmour(playerid, GetPVarFloat(playerid, #pArmour));
  492. CallLocalFunction("OnPlayerHacking", "ii", playerid, PLAYER_ARMOUR_HACK);
  493. }
  494. /*--------------------------------------------------
  495. *
  496. * Anti Player Bugger
  497. * Usando GetPlayerPos com variáveis server sided
  498. * A precisão deste sistema fica em torno de 99%
  499. * Desbuga o jogador bugado e envia mensagem aos administradores
  500. *
  501. -------------------------------------------------*/
  502. static Float: pX, Float: pY, Float:pZ;
  503. GetPlayerPos(playerid, pX, pY, pZ);
  504. if(pX > 0xdbb9f && pY > 0xdbb9f && pZ > 0xdbb9f) {
  505. SetTimerEx("verifBugger_pB", 250, false, "i", playerid);
  506. }
  507. /*--------------------------------------------------
  508. *
  509. * Anti Freeze Hack
  510. * Usando GetPlayerPos com variáveis server sided
  511. * A precisão deste sistema fica em torno de 90%
  512. *
  513. -------------------------------------------------*/
  514. else {
  515. // checar se realmente está está como MOVIMENTO FALSE
  516. if(!GetPVarInt(playerid, "PlayerControllable")) {
  517. GetPlayerPos(playerid, pX, pY, pZ);
  518. // Checar seus controle foram realmente bloqueados para diferentes de zero !
  519. if(GetPVarFloat(playerid,"xPosControll") && GetPVarFloat(playerid,"yPosControll") && GetPVarFloat(playerid,"zPosControll")) {
  520. if((GetPVarFloat(playerid,"xPosControll") != pX) || (GetPVarFloat(playerid,"yPosControll") != pY) || (GetPVarFloat(playerid,"zPosControll") != pZ)) {
  521. CallLocalFunction("OnPlayerHacking", "ii", playerid, PLAYER_FREEZE_HACK);
  522. // liberar jogador
  523. SetPVarInt(playerid, "PlayerControllable", 1);
  524. }
  525. }
  526. }
  527. GetPlayerPos(playerid, pX, pY, pZ);
  528. if(GetPVarFloat(playerid,"xposSet") != 0 && GetPVarFloat(playerid,"yposSet") != 0 && GetPVarFloat(playerid,"zposSet") != 0) {
  529. new Float:MAX_DISTANCE = MAX_DISTANCE_DEF;
  530. pX = GetPVarFloat(playerid,"xposSet") - pX;
  531. pY = GetPVarFloat(playerid,"yposSet") - pY;
  532. pZ = GetPVarFloat(playerid,"zposSet") - pZ;
  533. if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT && GetPlayerSurfingVehicleID(playerid) == INVALID_VEHICLE_ID) {
  534. MAX_DISTANCE = 7.0;
  535. }
  536. if((pX > MAX_DISTANCE || pX < -MAX_DISTANCE) || (pY > MAX_DISTANCE || pY < -MAX_DISTANCE) || (pZ > MAX_DISTANCE || pZ < -MAX_DISTANCE)) {
  537. if((gettime() - GetPVarInt(playerid, #tPosSet)) > 3 && GetPVarInt(playerid,"pSpawned")) {
  538. GetPlayerPos(playerid, pX, pY, pZ);
  539. SetTimerEx("checkPos_pB", 500, false, "ifff", playerid, pX, pY, pZ);
  540. }
  541. }
  542. MAX_DISTANCE = MAX_DISTANCE_DEF;
  543. }
  544. GetPlayerPos(playerid, pX, pY, pZ);
  545. SetPVarFloat(playerid,"xposSet", pX);
  546. SetPVarFloat(playerid,"yposSet", pY);
  547. SetPVarFloat(playerid,"zposSet", pZ);
  548. }
  549. /*--------------------------------------------------
  550. *
  551. * Anti Ping Alto
  552. * Usando GetPlayerScore com variáveis server sided
  553. * A precisão deste sistema fica em torno de 90%
  554. *
  555. -------------------------------------------------*/
  556. if(GetPlayerPing(playerid) > MAX_PING) {
  557. CallLocalFunction("OnPlayerHacking", "ii", playerid, PLAYER_HIGH_PING);
  558. }
  559. /*--------------------------------------------------
  560. *
  561. * Anti Score Hack
  562. * Usando GetPlayerScore com variáveis server sided
  563. * A precisão deste sistema fica em torno de 100%
  564. *
  565. -------------------------------------------------*/
  566. if(GetPlayerScore(playerid) > GetPVarInt(playerid, #registerScore)) {
  567. CallLocalFunction("OnPlayerHacking", "ii", playerid, PLAYER_SCORE_HACK);
  568. SetPlayerScore(playerid, GetPVarInt(playerid, #registerScore));
  569. }
  570. /*--------------------------------------------------
  571. *
  572. * Anti Player Speed Hack
  573. * Usando GetPlayerVelocity com variáveis server sided
  574. * A precisão deste sistema fica em torno de 95%
  575. *
  576. -------------------------------------------------*/
  577. if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT) {
  578. GetPlayerVelocity(playerid, pX, pY, pZ);
  579. if(floatround(floatsqroot(floatadd(floatpower(pX, 2), floatpower(pY, 2))) * 200) > 100) {
  580. if(!(GetPVarInt(playerid, #WarnsSpeed) % 50)) {
  581. CallLocalFunction("OnPlayerHacking", "ii", playerid, PLAYER_PSPEED_HACK);
  582. }
  583. SetPVarInt(playerid, #WarnsSpeed, (GetPVarInt(playerid, #WarnsSpeed) + 1));
  584. }
  585. }
  586. /*--------------------------------------------------
  587. *
  588. * Anti Fly Hack
  589. * Usando Posições e Animções.
  590. * A precisão deste sistema fica em torno de 85%
  591. *
  592. -------------------------------------------------*/
  593. if(!isPlayerInWater_pB(playerid) && isPlayerUsingSwimAnim_pB(playerid)) {
  594. if(!(GetPVarInt(playerid, "FlyTime") % 50)) {
  595. CallLocalFunction("OnPlayerHacking", "ii", playerid, PLAYER_FLY_HACK);
  596. SetPVarInt(playerid, "FlyTime", 0);
  597. }
  598. SetPVarInt(playerid, "FlyTime", (GetPVarInt(playerid, "FlyTime") + 1));
  599. } else if(isPlayerInWater_pB(playerid) && isPlayerUsingSwimAnim_pB(playerid)) {
  600. SetPVarInt(playerid, "FlyTime", 0);
  601. }
  602. SetPVarInt(playerid, #registerScore, GetPlayerScore(playerid));
  603. }
  604. return (pOPU ? CallLocalFunction("ExOnPlayerUpdate", "i", playerid) : 1);
  605. }
  606. #if defined _ALS_OnPlayerUpdate
  607. #undef OnPlayerUpdate
  608. #else
  609. #define _ALS_OnPlayerUpdate
  610. #endif
  611. #define OnPlayerUpdate ExOnPlayerUpdate
  612. forward ExOnPlayerUpdate(playerid);
  613. public OnPlayerStateChange(playerid, newstate, oldstate) {
  614. /*--------------------------------------------------
  615. *
  616. * Anti State Hack
  617. * Usando OnPlayerStateChange com gettime
  618. * A precisão deste sistema fica em torno de 95%
  619. *
  620. -------------------------------------------------*/
  621. if(newstate == PLAYER_STATE_DRIVER) {
  622. if((gettime() - GetPVarInt(playerid, #registerState)) < 2 && (gettime() - GetPVarInt(playerid, #tPosSet)) > 3) {
  623. CallLocalFunction("OnPlayerHacking", "ii", playerid, PLAYER_STATE_HACK);
  624. }
  625. SetPVarInt(playerid, #registerState, gettime());
  626. }
  627. SetPVarInt(playerid, #spiderCar, 0);
  628. return (pOPSC ? CallLocalFunction("ExOnPlayerStateChange", "idi", playerid, newstate, oldstate) : 1);
  629. }
  630. #if defined _ALS_OnPlayerStateChange
  631. #undef OnPlayerStateChange
  632. #else
  633. #define _ALS_OnPlayerStateChange
  634. #endif
  635. #define OnPlayerStateChange ExOnPlayerStateChange
  636. forward ExOnPlayerStateChange(playerid, newstate, oldstate);
  637. public OnUnoccupiedVehicleUpdate(vehicleid, playerid, passenger_seat) {
  638. /*--------------------------------------------------
  639. *
  640. * Anti Surfer Vehicle
  641. * Usando OnUnoccupiedVehicleUpdate com gettime e outros
  642. * A precisão deste sistema fica em torno de 85%
  643. *
  644. -------------------------------------------------*/
  645. GetVehiclePos(vehicleid, g_ucPos[0], g_ucPos[1], g_ucPos[2]);
  646. if(IsPlayerInRangeOfPoint(playerid, 1.0, g_ucPos[0], g_ucPos[1], g_ucPos[2])) {
  647. GetVehicleZAngle(vehicleid, g_ucPos[3]);
  648. if(g_diferencasAngle[vehicleid] != g_ucPos[3]) {
  649. if(!IsPlayerInAnyVehicle(playerid)) {
  650. GetPlayerPos(vehicleid, g_ucPos[1], g_ucPos[1], g_ucPos[3]);
  651. if(g_ucPos[3] > g_ucPos[2]) {
  652. SetPVarInt(playerid, #registrosUAF, GetPVarInt(playerid, #registrosUAF) +1);
  653. if(GetPVarInt(playerid, #registrosUAF) > 40) {
  654. CallLocalFunction("OnPlayerHacking", "ii", playerid, PLAYER_SURF_VEHICLE);
  655. }
  656. }
  657. }
  658. }
  659. g_diferencasAngle[vehicleid] = g_ucPos[3];
  660. return true;
  661. }
  662. /*--------------------------------------------------
  663. *
  664. * Anti Teleport Vehicle
  665. * Usando OnUnoccupiedVehicleUpdate com gettime e outros
  666. * A precisão deste sistema fica em torno de 85%
  667. *
  668. -------------------------------------------------*/
  669. else if(!IsPlayerInRangeOfPoint(playerid, 40.0, g_ucPos[0], g_ucPos[1], g_ucPos[2])) {
  670. if(!IsPlayerInAnyVehicle(playerid) && (gettime() - GetPVarInt(playerid, #tPosSet) > 3) && !vehRespawn[vehicleid]) {
  671. CallLocalFunction("OnPlayerHacking", "ii", playerid, PLAYER_CAR_TELEPORT);
  672. } else if(vehRespawn[vehicleid]) vehRespawn[vehicleid] = false;
  673. }
  674. return (pOUVU ? CallLocalFunction("ExOnUnoccupiedVehicleUpdate", "idi", vehicleid, playerid, passenger_seat) : 1);
  675. }
  676. #if defined _ALS_OnUnoccupiedVehicleUpdate
  677. #undef OnUnoccupiedVehicleUpdate
  678. #else
  679. #define _ALS_OnUnoccupiedVehicleUpdate
  680. #endif
  681. #define OnUnoccupiedVehicleUpdate ExOnUnoccupiedVehicleUpdate
  682. forward ExOnUnoccupiedVehicleUpdate(vehicleid, playerid, passenger_seat);
  683. pFunction checkPos_pB(i, Float: pX, Float: pY, Float: pZ) {
  684. if(gettime() - GetPVarInt(i, #airBreakSet) < 10)
  685. return false;
  686. /*--------------------------------------------------
  687. *
  688. * Anti Teleport Hack
  689. * Usando GetPlayerPos com variáveis server sided
  690. * A precisão deste sistema fica em torno de 95%
  691. *
  692. -------------------------------------------------*/
  693. if(IsPlayerInRangeOfPoint(i, 2.012837, pX, pY, pZ)) {
  694. CallLocalFunction("OnPlayerHacking", "ii", i, PLAYER_TELEPORT_HACK);
  695. }
  696. /*--------------------------------------------------
  697. *
  698. * Anti AirBreak Hack
  699. * Usando GetPlayerPos e SetPlayerPos com variáveis server sided
  700. * A precisão deste sistema fica em torno de 95%
  701. *
  702. -------------------------------------------------*/
  703. else {
  704. CallLocalFunction("OnPlayerHacking", "ii", i, PLAYER_AIRBREAK_HACK);
  705. SetPVarInt(i, #airBreakSet, gettime());
  706. }
  707. return true;
  708. }
  709. pFunction verifBugger_pB(playerid) {
  710. new Float: x, Float: y, Float: z;
  711. GetPlayerPos(playerid, x, y, z);
  712. if(x > 0xdbb9f && y > 0xdbb9f && z > 0xdbb9f) SetPlayerPos(playerid, GetPVarFloat(playerid,"xposSet"), GetPVarFloat(playerid,"yposSet"), GetPVarFloat(playerid,"zposSet"));
  713. else CallLocalFunction("OnPlayerHacking", "ii", playerid, PLAYER_BUGGER_HACK);
  714. return 1;
  715. }
  716. pFunction registerBot_pB(playerid) {
  717. /*--------------------------------------------------
  718. *
  719. * Anti DDos Bots
  720. * Usando GetPlayerPing/OnPlayerConnect com gettime e outros
  721. * A precisão deste sistema está dividido em partes
  722. *
  723. * PLAYER_BOT_LEVEL1 -> 70%
  724. * PLAYER_BOT_LEVEL2 -> 90%
  725. * PLAYER_BOT_LEVEL3 -> 100%
  726. *
  727. *
  728. -------------------------------------------------*/
  729. if(GetPlayerPing(playerid) != 0xFFFF && GetPlayerPing(playerid) != 0) SetPVarInt(playerid, #jogadorDisponivel, 1);
  730. if(IsPlayerConnected(playerid) && GetPlayerPing(playerid) == 0xFFFF) {
  731. static tmpip[20];
  732. GetPlayerIp(playerid, tmpip, 20);
  733. if(0x1c5 > (gettime() - varGet(tmpip))) {
  734. tmpip[(strlen(tmpip) - 1)] = 'x';
  735. if(varGet(tmpip) > 3) {
  736. return CallLocalFunction("OnPlayerHacking", "ii", playerid, PLAYER_BOT_LEVEL3);
  737. }
  738. CallLocalFunction("OnPlayerHacking", "ii", playerid, PLAYER_BOT_LEVEL2);
  739. }
  740. CallLocalFunction("OnPlayerHacking", "ii", playerid, PLAYER_BOT_LEVEL1);
  741. SetTimerEx("registerBot_pB", 700, false, #i , playerid);
  742. }
  743. return false;
  744. }
  745. pFunction registrarJogador_pB(playerid) {
  746. static tmpip[20];
  747. g_diferencasAngle[playerid] = 0;
  748. GetPlayerIp(playerid, tmpip, 20);
  749. varSet(tmpip, gettime()); ++connect;
  750. if(connect == MAX_PLAYERS - 1) {
  751. for(connect = 0; databaseIP[connect][0]; connect++) continue;
  752. }
  753. SetTimerEx("resetBot_pB", 50000, false, "i", connect);
  754. tmpip[strlen(tmpip)-1] = 'x';
  755. format(databaseIP[connect], 20, tmpip);
  756. varSet(tmpip, varGet(tmpip) +1);
  757. SetPVarInt(playerid, #tPosSet, gettime());
  758. return SetTimerEx("registerBot_pB", 700, false, #i , playerid);
  759. }
  760. pFunction resetBot_pB(botid) {
  761. varSet(databaseIP[botid], 0);
  762. return databaseIP[botid][0] = EOS;
  763. }
  764. #define SetPlayerScore SetPlayerScore_pB
  765. #define PutPlayerInVehicle PutPlayerInVehicle_pB
  766. #define SetPlayerArmour SetPlayerArmour_pB
  767. #define SetPlayerHealth SetPlayerHealth_pB
  768. #define TogglePlayerControllable TogglePlayerC_pB
  769. #define SetPlayerPos SetPlayerPos_pB
  770. #define SetVehiclePos SetVehiclePos_pB
  771. #define SetVehicleVelocity SetVehicleVelocity_pB
  772. #define SetVehicleToRespawn SetVehicleToRespawn_pB
  773. forward OnPlayerHacking(playerid, hackid);