1. //Easy, look you use OnPlayerUpdate(playerid)
  2. //So mine is like this, It's kinda simple and easy
  3.  
  4. new SpeedHacking[MAX_PLAYERS];
  5. #define SpeedCheck(%0,%1,%2,%3,%4) floatround(floatsqroot(%4?(%0*%0+%1*%1+%2*%2):(%0*%0+%1*%1) ) *%3*1.6)
  6. //=================================================================================================//
  7. //Under OnPlayerUpdate
  8. public OnPlayerUpdate(playerid)
  9. {
  10. //Anti SpeedHack
  11. if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
  12. {
  13. if(GetPlayerVehicleID(playerid) != 578 || GetPlayerVehicleID(playerid) != 520 || GetPlayerVehicleID(playerid) != 578 || 425)
  14. {
  15. if(PlayerInfo[playerid][pAdmin] < 10)
  16. {
  17. if(GetVehicleSpeed(GetPlayerVehicleID(playerid), 0) > 250)
  18. {
  19. SpeedHacking[playerid] =1;
  20. CheatsDetected(playerid);
  21. return 1;
  22. }
  23. }
  24. }
  25. }
  26. //OTHER CODES
  27. return 1;
  28. }
  29. //=================================================================================================//
  30. //Now lets go to the stock CheatsDetected
  31. //Stock CheatsDeteceed
  32. stock CheatsDetected(playerid)
  33. {
  34. new string[128];
  35. if(SpeedHacking[playerid] == 1)
  36. {
  37. new pName[MAX_PLAYER_NAME];
  38. GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
  39. format(string,sizeof(string),"[ANTI CHEAT] Anti-Cheat has banned %s(%d). [Reason: Cheats Detected]",pName,playerid);
  40. SendClientMessageToAll(COLOR_PINK,string);
  41.  
  42. format(string,sizeof(string),"1[ANTI CHEAT] Anti-Cheat has banned %s(%d). [Reason: Cheats Detected]",pName,playerid);
  43. IRC_GroupSay(gGroupID,IRC_CHANNEL,string);
  44. IRC_GroupSay(gGroupID,IRC_ADMINCHANNEL,string);
  45.  
  46. format(string, sizeof(string), "~r~BANNED!");
  47. GameTextForPlayer(playerid, string, 3000, 1);
  48.  
  49. new INI:File = INI_Open(UserPath(playerid));
  50. INI_SetTag(File,"Player's Data");
  51. INI_WriteString(File,"BanReason","Cheats Detected");
  52. INI_WriteString(File,"Reason","Speed Hacks");
  53. INI_Close(File);
  54. PlayerInfo[playerid][pBanned] =1;
  55.  
  56. SetTimerEx("KickPlayer",1000,false,"i",playerid);
  57. return 1;
  58. }
  59. return 1;
  60. }
  61. //=================================================================================================//
  62. //In o.3x Kick(playerid); has proirity over all codes, so you have to make a timer for it
  63. //like this so it posts all the codes needed before the kick
  64.  
  65. forward KickPlayer(ID);
  66. public KickPlayer(ID)
  67. {
  68. Kick(ID);
  69. return 1;
  70. }
  71. //=================================================================================================//
  72. //Now lets come to OnPlayerConnect part
  73. //So I'm using Y_INI as you see
  74. if(fexist(UserPath(playerid)))
  75. {
  76. INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  77. if(PlayerInfo[playerid][pBanned] == 1)
  78. {
  79. format(string,sizeof(string),"[BANNED] You are currently banned from the server. [Reason: %s]",PlayerInfo[playerid][pBanReason]);
  80. SendClientMessage(playerid, COLOR_RED,string);
  81. SendClientMessage(playerid, COLOR_RED,"[BANNED] Please Ban Appeal on our forums at www.SERVER.net");
  82. SetTimerEx("KickPlayer",1000,false,"i",playerid);
  83. return 1;
  84. }
  85. ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"{FF0000}SERVER","{FFFFFF}Welcome back to the server! \n Type your password below to login.","Login","Quit");
  86. }
  87. //=================================================================================================//
  88. //Vehicle speed
  89. stock GetVehicleSpeed(vehicleid, get3d)
  90. {
  91. new Float:x, Float:y, Float:z;
  92. GetVehicleVelocity(vehicleid, x, y, z);
  93. return SpeedCheck(x, y, z, 100.0, get3d);
  94. }