Advertisement
Guest User

Dark-Trigardon.eu Anticheat

a guest
Jun 29th, 2012
446
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 66.26 KB | None | 0 0
  1. /* Anticheatsystem by Dark-Trigardon
  2.  *  Version:     0.1b
  3.  *  Build:       008
  4.  *  Date:        23.02.2012
  5.  *  Last Edited: Tion
  6. */
  7.  
  8. #include <a_samp>
  9.  
  10. // Activate this to use "silent mode", means no message to all clients and let clients crash instand of kicking.
  11. //  Noone will notice the anticheat and it all seems like a big mystery, why all of them crash while cheating :)
  12. //#define SILENT_MODE
  13.  
  14. // Define this if you use it in debug mode
  15. //#define DEBUG_MODE
  16.  
  17. // When you define this, the script will proof more recource-friendlier... But a little bit badder :)
  18. //#define SAVE_RECOURCES
  19.  
  20. /* Set this higher when all players were kicked without reason -> lag-kick-bug */
  21. #define FREETIME_MONEY          2
  22. #define FREETIME_HEALTH         4
  23. #define FREETIME_ARMOUR         4
  24. #define FREETIME_TELEPORT       4
  25. #define FREETIME_WEAPON         4
  26.  
  27. /* The default dialog-id for the gui, when there a bugs with gui's, change this */
  28. #define DIALOG_ID               1483
  29.  
  30. /* ===================================================================================================================================
  31.  *  DO NOT EDIT AFTER HERE • DO NOT EDIT AFTER HERE • DO NOT EDIT AFTER HERE • DO NOT EDIT AFTER HERE • DO NOT EDIT AFTER HERE • DO NO
  32.  *  T EDIT AFTER HERE DO NOT EDIT AFTER HERE • DO NOT EDIT AFTER HERE • DO NOT EDIT AFTER HERE • DO NOT EDIT AFTER HERE • DO NOT EDIT
  33.  *  AFTER HERE • DO NOT EDIT AFTER HERE • DO NOT EDIT AFTER HERE • DO NOT EDIT AFTER HERE • DO NOT EDIT AFTER HERE • DO NOT EDIT AFTER
  34.  *  HERE • DO NOT EDIT AFTER HERE • DO NOT EDIT AFTER HERE • DO NOT EDIT AFTER HERE • DO NOT EDIT AFTER HERE • DO NOT EDIT AFTER HERE
  35.  * ===================================================================================================================================
  36. */
  37.  
  38. /*
  39.  * States for each cheat
  40. */
  41.  
  42. #define CHEAT_STATUS_OFF            0 // No action
  43. #define CHEAT_STATUS_UNDO           1 // Just took him away his money / guns / jetpack / remove from vehicle / ...
  44. #define CHEAT_STATUS_WARN           2 // Give him a warn, after x warn's -> Kick / Ban
  45. #define CHEAT_STATUS_KICK           3 // Kick him
  46. #define CHEAT_STATUS_BAN            4 // Ban him, he can be unbanned in the ACP
  47.  
  48. /*
  49.  * Intern dialog-ID's, useless, because it's all in 1 dialog
  50. */
  51.  
  52. #define SUBDIALOG_MAIN              1
  53. #define SUBDIALOG_CONFIG            2
  54. #define SUBDIALOG_CONFIG_EDIT       3
  55. #define SUBDIALOG_CONFIG_EXTENDET   4
  56. #define SUBDIALOG_BAN               5
  57.  
  58. #define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  59.  
  60. enum apInfo
  61. {
  62.     bool:apConnected,
  63.     apFreeTime,
  64.     apMoney,
  65.     apSpamMessages,
  66.     Float:apHealth,
  67.     Float:apArmour,
  68.     Float:apPosition[3],
  69.     Float:apAngle,
  70.     apLastSpawned,
  71.     apWeapons[13],
  72.     apAmmo[13],
  73.     apMuted,
  74.     apWarns,
  75.     apSpawnClass,
  76.     apUnkillableTime
  77. }
  78.  
  79. new DTAC_Player[MAX_PLAYERS][apInfo];
  80.  
  81. enum acConfig
  82. {
  83.     money,
  84.     driveby,
  85.     spam,
  86.     armour,
  87.     heal,
  88.     jetpack,
  89.     speed,
  90.     weapon,
  91.     teleport,
  92.     spawnkill,
  93.     quickturn, // 180° turn
  94.     joypad,
  95.     /* extendet config */
  96.     maxwarns,
  97.     bool:savewarns,
  98.     spawnprotecttime
  99. }
  100.  
  101. new DTAC_Config[acConfig];
  102.  
  103. enum servSpawnClasses
  104. {
  105.     team,
  106.     skin,
  107.     Float:spawnx,
  108.     Float:spawny,
  109.     Float:spawnz,
  110.     Float:spawna,
  111.     weapons[3],
  112.     ammo[3]
  113. }
  114.  
  115. new SpawnClasses[300][servSpawnClasses];
  116.  
  117. new UpdateTimer;
  118.  
  119. public OnFilterScriptInit()
  120. {
  121.     print("+------------------------------------+");
  122.     print("|   Anticheat by Dark-Trigardon.eu   |");
  123.     print("+------------------------------------+");
  124.     print(" AC: Initialisiering ...");
  125.     ParseCurrentSettings();
  126.  
  127.     for(new i = 0; i < MAX_PLAYERS; i++)
  128.     {
  129.         if(IsPlayerConnected(i))
  130.         {
  131.             // He is connected -> Set his connected-state to "1" and get his money
  132.             DTAC_Player[i][apConnected] = true;
  133.             DTAC_Player[i][apMoney] = GetPlayerMoney(i);
  134.             DTAC_Player[i][apFreeTime] = 3; // 3 seconds, just let the anticheat load all and start then testing :)
  135.             DTAC_Player[i][apSpamMessages] = 0;
  136.             GetPlayerHealth(i, DTAC_Player[i][apHealth]);
  137.             GetPlayerArmour(i, DTAC_Player[i][apArmour]);
  138.             GetPlayerPos(i, DTAC_Player[i][apPosition][0], DTAC_Player[i][apPosition][1], DTAC_Player[i][apPosition][2]);
  139.             GetPlayerFacingAngle(i, DTAC_Player[i][apAngle]);
  140.             DTAC_Player[i][apLastSpawned] = 0;
  141.             DTAC_Player[i][apWarns] = 0;
  142.             DTAC_Player[i][apMuted] = 0;
  143.         }
  144.     }
  145.    
  146.     UpdateTimer = SetTimer("OnAnticheatUpdate", 1000, true);
  147.     return 1;
  148. }
  149.  
  150. public OnFilterScriptExit()
  151. {
  152.     print(" AC: Decontermining ...");
  153.     SaveCurrentSettings();
  154.     KillTimer(UpdateTimer);
  155.     return 1;
  156. }
  157.  
  158. public OnPlayerConnect(playerid)
  159. {
  160.     new playername[MAX_PLAYER_NAME], string[128]; // String wird ein paar mal benutzt, muss deswegen vereinzelt > 128 sein
  161.     GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
  162.    
  163.     format(string, 128, "DT_Anticheat/%s.ban", playername);
  164.     if(fexist(string))
  165.     {
  166.         #if defined SILENT_MODE
  167.             CrashPlayer(playerid);
  168.         #else
  169.             SendClientMessage(playerid, 0xFF0000FF, "DTAC DE: Du bist von diesem Server gebannt.");
  170.             SendClientMessage(playerid, 0xFF0000FF, "DTAC EN: You are banned from this server.");
  171.             SendClientMessage(playerid, 0xFF0000FF, "DTAC FR: Vous etes banni de ce serveur.");
  172.             SendClientMessage(playerid, 0xFF0000FF, "DTAC SP: Usted esta prohibido de este servidor.");
  173.             Kick(playerid);
  174.         #endif
  175.     }
  176.     format(string, 128, "%s connected to the server", playername);
  177.     DTAC_Player[playerid][apConnected] = true;
  178.  
  179.     DTAC_Player[playerid][apMuted] = 0;
  180.    
  181.     ResetPlayerMoney(playerid);
  182.     DTAC_Player[playerid][apMoney] = 0;
  183.     return 1;
  184. }
  185.  
  186. public OnPlayerDisconnect(playerid, reason)
  187. {
  188.     DTAC_Player[playerid][apConnected] = false;
  189.     return 1;
  190. }
  191.  
  192. public OnPlayerSpawn(playerid)
  193. {
  194.     // Anti-Teleportbug
  195.     DTAC_Player[playerid][apFreeTime] = FREETIME_TELEPORT;
  196.    
  197.     // Health
  198.     DTAC_Player[playerid][apUnkillableTime] = DTAC_Config[spawnprotecttime];
  199.     if(DTAC_Config[spawnkill] == CHEAT_STATUS_UNDO)
  200.         DTAC_Player[playerid][apHealth] = 65534.0;
  201.     else
  202.         DTAC_Player[playerid][apHealth] = 100.0;
  203.     SetPlayerHealth(playerid, DTAC_Player[playerid][apHealth]);
  204.    
  205.     // Weapons
  206.     for(new i = 0; i < 13; i++)
  207.     {
  208.         DTAC_Player[playerid][apWeapons][i] = -1;
  209.         DTAC_Player[playerid][apAmmo][i] = -1;
  210.     }
  211.  
  212.     // Spawn-Weapons
  213.     _AC_ResetPlayerWeapons(playerid);
  214.     new spawnclass = DTAC_Player[playerid][apSpawnClass];
  215.     for(new i = 0; i < 3; i++)
  216.     {
  217.         new weaponid = SpawnClasses[spawnclass][weapons][i];
  218.         new weaponammo = SpawnClasses[spawnclass][ammo][i];
  219.         new weaponslot = GetWeaponSlot(weaponid);
  220.         if(weaponslot < 0 || weaponslot > 12) continue;
  221.         DTAC_Player[playerid][apWeapons][weaponslot] = weaponid;
  222.         DTAC_Player[playerid][apAmmo][weaponslot] = weaponammo;
  223.     }
  224.     return 1;
  225. }
  226.  
  227. public OnPlayerDeath(playerid, killerid, reason)
  228. {
  229.     if(playerid == killerid) return false;
  230.     /* DriveBy */
  231.     if(DTAC_Config[driveby] > CHEAT_STATUS_OFF)
  232.     {
  233.         new string[128], name[32];
  234.         GetPlayerName(playerid, name, 32);
  235.         if(IsPlayerInAnyVehicle(killerid))
  236.         {
  237.             switch(DTAC_Config[driveby])
  238.             {
  239.                 case CHEAT_STATUS_UNDO:
  240.                 {
  241.                     /* Should we respawn him here ??? */
  242.                 }
  243.                 case CHEAT_STATUS_WARN:
  244.                 {
  245.                     WarnPlayer(playerid, 1, "driveby");
  246.                 }
  247.                 case CHEAT_STATUS_KICK:
  248.                 {
  249.                     #if defined SILENT_MODE
  250.                         CrashPlayer(playerid);
  251.                     #else
  252.                         format(string, 128, "%s has been banned due driveby", name);
  253.                         SendClientMessageToAll(0xFF0000FF, string);
  254.                         Kick(playerid);
  255.                     #endif
  256.                 }
  257.                 case CHEAT_STATUS_BAN:
  258.                 {
  259.                     BanPlayer(playerid);
  260.                     #if defined SILENT_MODE
  261.                         CrashPlayer(playerid);
  262.                     #else
  263.                         format(string, 128, "%s has been banned due driveby", name);
  264.                         SendClientMessageToAll(0xFF0000FF, string);
  265.                         Kick(playerid);
  266.                     #endif
  267.                 }
  268.             }
  269.         }
  270.     }
  271.     if(DTAC_Player[playerid][apUnkillableTime] >= 1 && DTAC_Config[spawnkill] >= CHEAT_STATUS_OFF)
  272.     {
  273.         new string[128], name[32];
  274.         GetPlayerName(playerid, name, 32);
  275.         switch(DTAC_Config[spawnkill])
  276.         {
  277.             case CHEAT_STATUS_WARN:
  278.             {
  279.                 WarnPlayer(killerid, 1, "spawn kill");
  280.             }
  281.             case CHEAT_STATUS_KICK:
  282.             {
  283.                 #if defined SILENT_MODE
  284.                     CrashPlayer(playerid);
  285.                 #else
  286.                     format(string, 128, "%s has been kicked due spawnkill", name);
  287.                     SendClientMessageToAll(0xFF0000FF, string);
  288.                     Kick(playerid);
  289.                 #endif
  290.             }
  291.             case CHEAT_STATUS_BAN:
  292.             {
  293.                 BanPlayer(playerid);
  294.                 #if defined SILENT_MODE
  295.                     CrashPlayer(playerid);
  296.                 #else
  297.                     format(string, 128, "%s has been banned due spawnkill", name);
  298.                     SendClientMessageToAll(0xFF0000FF, string);
  299.                     Kick(playerid);
  300.                 #endif
  301.             }
  302.         }
  303.     }
  304.     return 1;
  305. }
  306.  
  307. public OnPlayerCommandText(playerid, cmdtext[])
  308. {
  309.     if(strcmp(cmdtext, "/dtac", true) == 0)
  310.     {
  311.         if(!IsPlayerAdmin(playerid)) return false;
  312.         SetPVarInt(playerid, "dtac_dialog", SUBDIALOG_MAIN);
  313.         ShowPlayerDialog(playerid, DIALOG_ID, DIALOG_STYLE_LIST, "Anticheat", "Config\nBansystem", "Ok", "Exit");
  314.         return true;
  315.     }
  316.     return 0;
  317. }
  318.  
  319. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) // SUBDIALOG_CONFIG
  320. {
  321.     if(dialogid != DIALOG_ID) return false;
  322.     if(!IsPlayerAdmin(playerid)) return false;
  323.     dialogid = GetPVarInt(playerid, "dtac_dialog");
  324.     if(dialogid == SUBDIALOG_MAIN)
  325.     {
  326.         if(!response) return false;
  327.         if(listitem == 0)
  328.         {
  329.             SetPVarInt(playerid, "dtac_dialog", SUBDIALOG_CONFIG);
  330.             ShowPlayerDialog(playerid, DIALOG_ID, DIALOG_STYLE_LIST, "Anticheat / Config", "Toogle systemstate\nChange extendet propertys", "Ok", "Exit");
  331.         }
  332.         else if(listitem == 1)
  333.         {
  334.             SetPVarInt(playerid, "dtac_dialog", SUBDIALOG_BAN);
  335.             ShowPlayerDialog(playerid, DIALOG_ID, DIALOG_STYLE_MSGBOX, "Anticheat / Ban", "Comming soon", "Ok", "Exit");
  336.         }
  337.     }
  338.     else if(dialogid == SUBDIALOG_CONFIG)
  339.     {
  340.         if(!response) return false;
  341.         if(listitem == 0)
  342.         {
  343.             new string[512]; // We need such a big string ;)
  344.  
  345.             switch(DTAC_Config[money])
  346.             {
  347.                 case CHEAT_STATUS_OFF:
  348.                 {
  349.                     format(string, sizeof(string), "{FFFFFF}Money ( {FF0000}off{FFFFFF} )\n");
  350.                 }
  351.                 case CHEAT_STATUS_UNDO:
  352.                 {
  353.                     format(string, sizeof(string), "{FFFFFF}Money ( {00FF00}restore{FFFFFF} )\n");
  354.                 }
  355.                 case CHEAT_STATUS_WARN:
  356.                 {
  357.                     format(string, sizeof(string), "{FFFFFF}Money ( {0000FF}warn{FFFFFF} )\n");
  358.                 }
  359.                 case CHEAT_STATUS_KICK:
  360.                 {
  361.                     format(string, sizeof(string), "{FFFFFF}Money ( {0000FF}kick{FFFFFF} )\n");
  362.                 }
  363.                 case CHEAT_STATUS_BAN:
  364.                 {
  365.                     format(string, sizeof(string), "{FFFFFF}Money ( {0000FF}ban{FFFFFF} )\n");
  366.                 }
  367.                 default:
  368.                 {
  369.                     format(string, sizeof(string), "{FFFFFF}Money ( {FF00FF}???{FFFFFF} )\n");
  370.                 }
  371.             }
  372.             switch(DTAC_Config[driveby])
  373.             {
  374.                 case CHEAT_STATUS_OFF:
  375.                 {
  376.                     format(string, sizeof(string), "%s{FFFFFF}Driveby ( {FF0000}off{FFFFFF} )\n", string);
  377.                 }
  378.                 case CHEAT_STATUS_UNDO:
  379.                 {
  380.                     format(string, sizeof(string), "%s{FFFFFF}Driveby ( {FF0000}ignore{FFFFFF} )\n", string);
  381.                 }
  382.                 case CHEAT_STATUS_WARN:
  383.                 {
  384.                     format(string, sizeof(string), "%s{FFFFFF}Driveby ( {0000FF}warn{FFFFFF} )\n", string);
  385.                 }
  386.                 case CHEAT_STATUS_KICK:
  387.                 {
  388.                     format(string, sizeof(string), "%s{FFFFFF}Driveby ( {0000FF}kick{FFFFFF} )\n", string);
  389.                 }
  390.                 case CHEAT_STATUS_BAN:
  391.                 {
  392.                     format(string, sizeof(string), "%s{FFFFFF}Driveby ( {0000FF}ban{FFFFFF} )\n", string);
  393.                 }
  394.                 default:
  395.                 {
  396.                     format(string, sizeof(string), "%s{FFFFFF}Driveby ( {FF00FF}???{FFFFFF} )\n", string);
  397.                 }
  398.             }
  399.             switch(DTAC_Config[spam])
  400.             {
  401.                 case CHEAT_STATUS_OFF:
  402.                 {
  403.                     format(string, sizeof(string), "%s{FFFFFF}Spam ( {FF0000}off{FFFFFF} )\n", string);
  404.                 }
  405.                 case CHEAT_STATUS_UNDO:
  406.                 {
  407.                     format(string, sizeof(string), "%s{FFFFFF}Spam ( {FF0000}mute{FFFFFF} )\n", string);
  408.                 }
  409.                 case CHEAT_STATUS_WARN:
  410.                 {
  411.                     format(string, sizeof(string), "%s{FFFFFF}Spam ( {0000FF}warn{FFFFFF} )\n", string);
  412.                 }
  413.                 case CHEAT_STATUS_KICK:
  414.                 {
  415.                     format(string, sizeof(string), "%s{FFFFFF}Spam ( {0000FF}kick{FFFFFF} )\n", string);
  416.                 }
  417.                 case CHEAT_STATUS_BAN:
  418.                 {
  419.                     format(string, sizeof(string), "%s{FFFFFF}Spam ( {0000FF}ban{FFFFFF} )\n", string);
  420.                 }
  421.                 default:
  422.                 {
  423.                     format(string, sizeof(string), "%s{FFFFFF}Spam ( {FF00FF}???{FFFFFF} )\n", string);
  424.                 }
  425.             }
  426.             switch(DTAC_Config[heal])
  427.             {
  428.                 case CHEAT_STATUS_OFF:
  429.                 {
  430.                     format(string, sizeof(string), "%s{FFFFFF}Heal ( {FF0000}off{FFFFFF} )\n", string);
  431.                 }
  432.                 case CHEAT_STATUS_UNDO:
  433.                 {
  434.                     format(string, sizeof(string), "%s{FFFFFF}Heal ( {00FF00}restore{FFFFFF} )\n", string);
  435.                 }
  436.                 case CHEAT_STATUS_WARN:
  437.                 {
  438.                     format(string, sizeof(string), "%s{FFFFFF}Heal ( {0000FF}warn{FFFFFF} )\n", string);
  439.                 }
  440.                 case CHEAT_STATUS_KICK:
  441.                 {
  442.                     format(string, sizeof(string), "%s{FFFFFF}Heal ( {0000FF}kick{FFFFFF} )\n", string);
  443.                 }
  444.                 case CHEAT_STATUS_BAN:
  445.                 {
  446.                     format(string, sizeof(string), "%s{FFFFFF}Heal ( {0000FF}ban{FFFFFF} )\n", string);
  447.                 }
  448.                 default:
  449.                 {
  450.                     format(string, sizeof(string), "%s{FFFFFF}Heal ( {FF00FF}???{FFFFFF} )\n", string);
  451.                 }
  452.             }
  453.             switch(DTAC_Config[armour])
  454.             {
  455.                 case CHEAT_STATUS_OFF:
  456.                 {
  457.                     format(string, sizeof(string), "%s{FFFFFF}Armour ( {FF0000}off{FFFFFF} )\n", string);
  458.                 }
  459.                 case CHEAT_STATUS_UNDO:
  460.                 {
  461.                     format(string, sizeof(string), "%s{FFFFFF}Armour ( {00FF00}restore{FFFFFF} )\n", string);
  462.                 }
  463.                 case CHEAT_STATUS_WARN:
  464.                 {
  465.                     format(string, sizeof(string), "%s{FFFFFF}Armour ( {0000FF}warn{FFFFFF} )\n", string);
  466.                 }
  467.                 case CHEAT_STATUS_KICK:
  468.                 {
  469.                     format(string, sizeof(string), "%s{FFFFFF}Armour ( {0000FF}kick{FFFFFF} )\n", string);
  470.                 }
  471.                 case CHEAT_STATUS_BAN:
  472.                 {
  473.                     format(string, sizeof(string), "%s{FFFFFF}Armour ( {0000FF}ban{FFFFFF} )\n", string);
  474.                 }
  475.                 default:
  476.                 {
  477.                     format(string, sizeof(string), "%s{FFFFFF}Armour ( {FF00FF}???{FFFFFF} )\n", string);
  478.                 }
  479.             }
  480.             switch(DTAC_Config[jetpack])
  481.             {
  482.                 case CHEAT_STATUS_OFF:
  483.                 {
  484.                     format(string, sizeof(string), "%s{FFFFFF}Jetpack ( {FF0000}off{FFFFFF} )\n", string);
  485.                 }
  486.                 case CHEAT_STATUS_UNDO:
  487.                 {
  488.                     format(string, sizeof(string), "%s{FFFFFF}Jetpack ( {00FF00}restore{FFFFFF} )\n", string);
  489.                 }
  490.                 case CHEAT_STATUS_WARN:
  491.                 {
  492.                     format(string, sizeof(string), "%s{FFFFFF}Jetpack ( {0000FF}warn{FFFFFF} )\n", string);
  493.                 }
  494.                 case CHEAT_STATUS_KICK:
  495.                 {
  496.                     format(string, sizeof(string), "%s{FFFFFF}Jetpack ( {0000FF}kick{FFFFFF} )\n", string);
  497.                 }
  498.                 case CHEAT_STATUS_BAN:
  499.                 {
  500.                     format(string, sizeof(string), "%s{FFFFFF}Jetpack ( {0000FF}ban{FFFFFF} )\n", string);
  501.                 }
  502.                 default:
  503.                 {
  504.                     format(string, sizeof(string), "%s{FFFFFF}Jetpack ( {FF00FF}???{FFFFFF} )\n", string);
  505.                 }
  506.             }
  507.             switch(DTAC_Config[weapon])
  508.             {
  509.                 case CHEAT_STATUS_OFF:
  510.                 {
  511.                     format(string, sizeof(string), "%s{FFFFFF}Weapon ( {FF0000}off{FFFFFF} )\n", string);
  512.                 }
  513.                 case CHEAT_STATUS_UNDO:
  514.                 {
  515.                     format(string, sizeof(string), "%s{FFFFFF}Weapon ( {00FF00}restore{FFFFFF} )\n", string);
  516.                 }
  517.                 case CHEAT_STATUS_WARN:
  518.                 {
  519.                     format(string, sizeof(string), "%s{FFFFFF}Weapon ( {0000FF}warn{FFFFFF} )\n", string);
  520.                 }
  521.                 case CHEAT_STATUS_KICK:
  522.                 {
  523.                     format(string, sizeof(string), "%s{FFFFFF}Weapon ( {0000FF}kick{FFFFFF} )\n", string);
  524.                 }
  525.                 case CHEAT_STATUS_BAN:
  526.                 {
  527.                     format(string, sizeof(string), "%s{FFFFFF}Weapon ( {0000FF}ban{FFFFFF} )\n", string);
  528.                 }
  529.                 default:
  530.                 {
  531.                     format(string, sizeof(string), "%s{FFFFFF}Weapon ( {FF00FF}???{FFFFFF} )\n", string);
  532.                 }
  533.             }
  534.             switch(DTAC_Config[spawnkill])
  535.             {
  536.                 case CHEAT_STATUS_OFF:
  537.                 {
  538.                     format(string, sizeof(string), "%s{FFFFFF}Spawnprotection ( {FF0000}off{FFFFFF} )\n", string);
  539.                 }
  540.                 case CHEAT_STATUS_UNDO:
  541.                 {
  542.                     format(string, sizeof(string), "%s{FFFFFF}Spawnprotection ( {00FF00}unkillable{FFFFFF} )\n", string);
  543.                 }
  544.                 case CHEAT_STATUS_WARN:
  545.                 {
  546.                     format(string, sizeof(string), "%s{FFFFFF}Spawnprotection ( {0000FF}warn{FFFFFF} )\n", string);
  547.                 }
  548.                 case CHEAT_STATUS_KICK:
  549.                 {
  550.                     format(string, sizeof(string), "%s{FFFFFF}Spawnprotection ( {0000FF}kick{FFFFFF} )\n", string);
  551.                 }
  552.                 case CHEAT_STATUS_BAN:
  553.                 {
  554.                     format(string, sizeof(string), "%s{FFFFFF}Spawnprotection ( {0000FF}ban{FFFFFF} )\n", string);
  555.                 }
  556.                 default:
  557.                 {
  558.                     format(string, sizeof(string), "%s{FFFFFF}Spawnprotection ( {FF00FF}???{FFFFFF} )\n", string);
  559.                 }
  560.             }
  561.             switch(DTAC_Config[quickturn])
  562.             {
  563.                 case CHEAT_STATUS_OFF:
  564.                 {
  565.                     format(string, sizeof(string), "%s{FFFFFF}Quickturn ( {FF0000}off{FFFFFF} )\n", string);
  566.                 }
  567.                 case CHEAT_STATUS_UNDO:
  568.                 {
  569.                     format(string, sizeof(string), "%s{FFFFFF}Quickturn ( {00FF00}restore{FFFFFF} )\n", string);
  570.                 }
  571.                 case CHEAT_STATUS_WARN:
  572.                 {
  573.                     format(string, sizeof(string), "%s{FFFFFF}Quickturn ( {0000FF}warn{FFFFFF} )\n", string);
  574.                 }
  575.                 case CHEAT_STATUS_KICK:
  576.                 {
  577.                     format(string, sizeof(string), "%s{FFFFFF}Quickturn ( {0000FF}kick{FFFFFF} )\n", string);
  578.                 }
  579.                 case CHEAT_STATUS_BAN:
  580.                 {
  581.                     format(string, sizeof(string), "%s{FFFFFF}Quickturn ( {0000FF}ban{FFFFFF} )\n", string);
  582.                 }
  583.                 default:
  584.                 {
  585.                     format(string, sizeof(string), "%s{FFFFFF}Quickturn ( {FF00FF}???{FFFFFF} )\n", string);
  586.                 }
  587.             }
  588.             switch(DTAC_Config[joypad])
  589.             {
  590.                 case CHEAT_STATUS_OFF:
  591.                 {
  592.                     format(string, sizeof(string), "%s{FFFFFF}Joypad ( {FF0000}off{FFFFFF} )\n", string);
  593.                 }
  594.                 case CHEAT_STATUS_UNDO:
  595.                 {
  596.                     format(string, sizeof(string), "%s{FFFFFF}Joypad ( {00FF00}tell him to turn off{FFFFFF} )\n", string);
  597.                 }
  598.                 case CHEAT_STATUS_WARN:
  599.                 {
  600.                     format(string, sizeof(string), "%s{FFFFFF}Joypad ( {0000FF}warn{FFFFFF} )\n", string);
  601.                 }
  602.                 case CHEAT_STATUS_KICK:
  603.                 {
  604.                     format(string, sizeof(string), "%s{FFFFFF}Joypad ( {0000FF}kick{FFFFFF} )\n", string);
  605.                 }
  606.                 case CHEAT_STATUS_BAN:
  607.                 {
  608.                     format(string, sizeof(string), "%s{FFFFFF}Joypad ( {0000FF}ban{FFFFFF} )\n", string);
  609.                 }
  610.                 default:
  611.                 {
  612.                     format(string, sizeof(string), "%s{FFFFFF}Joypad ( {FF00FF}???{FFFFFF} )\n", string);
  613.                 }
  614.             }
  615.             SetPVarInt(playerid, "dtac_dialog", SUBDIALOG_CONFIG_EDIT);
  616.             ShowPlayerDialog(playerid, DIALOG_ID, DIALOG_STYLE_LIST, "Anticheat / Config / Set Modes", string, "Change", "Exit");
  617.         }
  618.         else if(listitem == 1)
  619.         {
  620.             // Extendet configuration
  621.             SetPVarInt(playerid, "dtac_dialog", SUBDIALOG_CONFIG_EXTENDET);
  622.             new string[150]; // Blame, string is at least 129 chars >.<
  623.  
  624.             format(string, 128, "{FFFFFF}Max. Warns: {FF0000}%d{FFFFFF}\n", DTAC_Config[maxwarns]);
  625.             if(DTAC_Config[savewarns])
  626.                 format(string, 128, "%s{FFFFFF}Save Warns: {FF0000}true{FFFFFF}\n", string);
  627.             else
  628.                 format(string, 128, "%s{FFFFFF}Save Warns: {FF0000}false{FFFFFF}\n", string);
  629.             format(string, 128, "%s{FFFFFF}Spawn-Protection time: {FF0000}%d{FFFFFF}", string, DTAC_Config[spawnprotecttime]);
  630.        
  631.             ShowPlayerDialog(playerid, DIALOG_ID, DIALOG_STYLE_LIST, "Anticheat / Config / Extendet", string, "Ok", "Exit");
  632.         }
  633.        
  634.     }
  635.     else if(dialogid == SUBDIALOG_CONFIG_EDIT)
  636.     {
  637.         if(!response) return false;
  638.         switch(listitem)
  639.         {
  640.             case 0:
  641.             {
  642.                 DTAC_Config[money]++;
  643.                 if(DTAC_Config[money] > 4)
  644.                     DTAC_Config[money] = 0;
  645.             }
  646.             case 1:
  647.             {
  648.                 DTAC_Config[driveby]++;
  649.                 if(DTAC_Config[driveby] > 4)
  650.                     DTAC_Config[driveby] = 0;
  651.             }
  652.             case 2:
  653.             {
  654.                 DTAC_Config[spam]++;
  655.                 if(DTAC_Config[spam] > 4)
  656.                     DTAC_Config[spam] = 0;
  657.             }
  658.             case 3:
  659.             {
  660.                 DTAC_Config[heal]++;
  661.                 if(DTAC_Config[heal] > 4)
  662.                     DTAC_Config[heal] = 0;
  663.             }
  664.             case 4:
  665.             {
  666.                 DTAC_Config[armour]++;
  667.                 if(DTAC_Config[armour] > 4)
  668.                     DTAC_Config[armour] = 0;
  669.             }
  670.             case 5:
  671.             {
  672.                 DTAC_Config[jetpack]++;
  673.                 if(DTAC_Config[jetpack] > 4)
  674.                     DTAC_Config[jetpack] = 0;
  675.             }
  676.             case 6:
  677.             {
  678.                 DTAC_Config[weapon]++;
  679.                 if(DTAC_Config[weapon] > 4)
  680.                     DTAC_Config[weapon] = 0;
  681.             }
  682.             case 7:
  683.             {
  684.                 DTAC_Config[spawnkill]++;
  685.                 if(DTAC_Config[spawnkill] > 4)
  686.                     DTAC_Config[spawnkill] = 0;
  687.             }
  688.             case 8:
  689.             {
  690.                 DTAC_Config[quickturn]++;
  691.                 if(DTAC_Config[quickturn] > 4)
  692.                     DTAC_Config[quickturn] = 0;
  693.             }
  694.             case 9:
  695.             {
  696.                 DTAC_Config[joypad]++;
  697.                 if(DTAC_Config[joypad] > 4)
  698.                     DTAC_Config[joypad] = 0;
  699.             }
  700.         }
  701.         // "Bugusing" / show the dialog again
  702.         SetPVarInt(playerid, "dtac_dialog", SUBDIALOG_CONFIG);
  703.         OnDialogResponse(playerid, DIALOG_ID, true, 0, "");
  704.     }
  705.     else if(dialogid == SUBDIALOG_CONFIG_EXTENDET)
  706.     {
  707.         if(!response) return false;
  708.         switch(listitem)
  709.         {
  710.             case 0:
  711.             {
  712.                 DTAC_Config[maxwarns]++;
  713.                 if(DTAC_Config[maxwarns] > 5)
  714.                     DTAC_Config[maxwarns] = 2;
  715.             }
  716.             case 1:
  717.             {
  718.                 DTAC_Config[savewarns] = DTAC_Config[savewarns] == false;
  719.             }
  720.             case 2:
  721.             {
  722.                 DTAC_Config[spawnprotecttime]++;
  723.                 if(DTAC_Config[spawnprotecttime] > 5)
  724.                     DTAC_Config[spawnprotecttime] = 0;
  725.             }
  726.         }
  727.         // "Bugusing" / show the dialog again
  728.         SetPVarInt(playerid, "dtac_dialog", SUBDIALOG_CONFIG);
  729.         OnDialogResponse(playerid, DIALOG_ID, true, 1, "");
  730.     }
  731.     else if(dialogid == SUBDIALOG_BAN)
  732.     {
  733.         if(!response) return false;
  734.     }
  735.     return false;
  736. }
  737.  
  738. public OnPlayerRequestClass(playerid, classid)
  739. {
  740.     DTAC_Player[playerid][apSpawnClass] = classid;
  741. }
  742.  
  743. public OnPlayerText(playerid, text[])
  744. {
  745.     new string[128];
  746.     if(DTAC_Player[playerid][apMuted] >= 1)
  747.     {
  748.         format(string, 128, "You were muted, %d seconds left !", DTAC_Player[playerid][apMuted]);
  749.         SendClientMessage(playerid, 0xFF0000FF, string);
  750.         return false;
  751.     }
  752.     else
  753.     {
  754.         DTAC_Player[playerid][apSpamMessages]++;
  755.         return true;
  756.     }
  757. }
  758.  
  759. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  760. {
  761.     return 1;
  762. }
  763.  
  764. // To read from the config-File
  765. forward ParseCurrentSettings();
  766. public ParseCurrentSettings()
  767. {
  768.     LogText("Load configuration ...");
  769.     new File:configfile;
  770.     new line[128]; // TODO: Set higher if doesn't read config correct
  771.     new ini_key[64], ini_value[64];
  772.     new index;
  773.    
  774.     ResetConfig();
  775.  
  776.     configfile = fopen("DT_AntiCheat/config.ini", io_read);
  777.     if(!configfile) return false; // File does not exists
  778.    
  779.     while(fread(configfile, line) != 0)
  780.     {
  781.         // First, remove the "\r\n"
  782.         line[strlen(line) - 2] = 0;
  783.         // Let's start parsing :)
  784.         index = str_find(line, sizeof(line), '=', 0);
  785.         if(line[0] == 0) continue; // Empty line
  786.         if((line[0] == '#') || (line[0] == '/' && line[1] == '/')) continue; // It's a commented line
  787.         if(index == 0 || index == -1) continue; // No "=" in the line, so that's an invalid line. Go to the next line.
  788.         sub_str(line, ini_key, 0, index);
  789.         sub_str(line, ini_value, index + 1, sizeof(line));
  790.         if(strcmp(ini_key, "money", true) == 0)         { LogText(" Loading Money ..."); DTAC_Config[money] = strval(ini_value); }
  791.         if(strcmp(ini_key, "driveby", true) == 0)       { LogText(" Loading DriveBy ..."); DTAC_Config[driveby] = strval(ini_value); }
  792.         if(strcmp(ini_key, "spam", true) == 0)          { LogText(" Loading Spam ..."); DTAC_Config[spam] = strval(ini_value); }
  793.         if(strcmp(ini_key, "heal", true) == 0)          { LogText(" Loading Heal ..."); DTAC_Config[heal] = strval(ini_value); }
  794.         if(strcmp(ini_key, "armour", true) == 0)        { LogText(" Loading Armour ..."); DTAC_Config[armour] = strval(ini_value); }
  795.         if(strcmp(ini_key, "jetpack", true) == 0)       { LogText(" Loading Jetpack ..."); DTAC_Config[jetpack] = strval(ini_value); }
  796.         if(strcmp(ini_key, "speedhack", true) == 0)     { LogText(" Loading Speedhack ..."); DTAC_Config[speed] = strval(ini_value); }
  797.         if(strcmp(ini_key, "weapon", true) == 0)        { LogText(" Loading Weapon ..."); DTAC_Config[weapon] = strval(ini_value); }
  798.         if(strcmp(ini_key, "teleport", true) == 0)      { LogText(" Loading Teleport ..."); DTAC_Config[teleport] = strval(ini_value); }
  799.         if(strcmp(ini_key, "spawnkill", true) == 0)     { LogText(" Loading Spawnkill ..."); DTAC_Config[spawnkill] = strval(ini_value); }
  800.         if(strcmp(ini_key, "quickturn", true) == 0)     { LogText(" Loading 180° - Turn ..."); DTAC_Config[quickturn] = strval(ini_value); }
  801.         if(strcmp(ini_key, "maxwarns", true) == 0)      { DTAC_Config[maxwarns] = strval(ini_value); }
  802.         if(strcmp(ini_key, "savewarns", true) == 0)     { DTAC_Config[savewarns] = strval(ini_value) == 1; }
  803.         if(strcmp(ini_key, "protecttime", true) == 0)   { DTAC_Config[spawnprotecttime] = strval(ini_value); }
  804.     }
  805.     fclose(configfile);
  806.     return true;
  807. }
  808.  
  809. forward SaveCurrentSettings();
  810. public SaveCurrentSettings()
  811. {
  812.     LogText("Save configuration ...");
  813.     new File:configfile, string[128];
  814.     configfile = fopen("DT_AntiCheat/config.ini", io_write);
  815.     LogText(" Save Money ...");
  816.     format(string, 128, "money=%d\r\n", DTAC_Config[money]);                    fwrite(configfile, string);
  817.     LogText(" Save DriveBy ...");
  818.     format(string, 128, "driveby=%d\r\n", DTAC_Config[driveby]);                fwrite(configfile, string);
  819.     LogText(" Save Spam ...");
  820.     format(string, 128, "spam=%d\r\n", DTAC_Config[spam]);                      fwrite(configfile, string);
  821.     LogText(" Save Heal ...");
  822.     format(string, 128, "heal=%d\r\n", DTAC_Config[heal]);                      fwrite(configfile, string);
  823.     LogText(" Save Armour ...");
  824.     format(string, 128, "armour=%d\r\n", DTAC_Config[armour]);                  fwrite(configfile, string);
  825.     LogText(" Save Jetpack ...");
  826.     format(string, 128, "jetpack=%d\r\n", DTAC_Config[jetpack]);                fwrite(configfile, string);
  827.     LogText(" Save Speedhack ...");
  828.     format(string, 128, "speedhack=%d\r\n", DTAC_Config[speed]);                fwrite(configfile, string);
  829.     LogText(" Save Weapon ...");
  830.     format(string, 128, "weapon=%d\r\n", DTAC_Config[weapon]);                  fwrite(configfile, string);
  831.     LogText(" Save Teleport ...");
  832.     format(string, 128, "teleport=%d\r\n", DTAC_Config[teleport]);              fwrite(configfile, string);
  833.     LogText(" Save Spawnkill ...");
  834.     format(string, 128, "spawnkill=%d\r\n", DTAC_Config[spawnkill]);            fwrite(configfile, string);
  835.     LogText(" Save 180° - Turn ...");
  836.     format(string, 128, "quickturn=%d\r\n", DTAC_Config[quickturn]);            fwrite(configfile, string);
  837.  
  838.     LogText(" Save extendet stuff ...");
  839.     format(string, 128, "maxwarns=%d\r\n", DTAC_Config[maxwarns]);              fwrite(configfile, string);
  840.     format(string, 128, "savewarns=%d\r\n", DTAC_Config[savewarns] ? 1 : 0);    fwrite(configfile, string);
  841.     format(string, 128, "protecttime=%d\r\n", DTAC_Config[spawnprotecttime]);   fwrite(configfile, string);
  842.     fclose(configfile);
  843.     //
  844. }
  845.  
  846. // To set the config to default
  847. forward ResetConfig();
  848. public ResetConfig()
  849. {
  850.     DTAC_Config[money] = CHEAT_STATUS_UNDO;
  851.     DTAC_Config[driveby] = CHEAT_STATUS_WARN;
  852.     DTAC_Config[spam] = CHEAT_STATUS_WARN;
  853.     DTAC_Config[armour] = CHEAT_STATUS_UNDO;
  854.     DTAC_Config[heal] = CHEAT_STATUS_UNDO;
  855.     DTAC_Config[jetpack] = CHEAT_STATUS_KICK;
  856.     DTAC_Config[speed] = CHEAT_STATUS_KICK;
  857.     DTAC_Config[weapon] = CHEAT_STATUS_KICK;
  858.     DTAC_Config[teleport] = CHEAT_STATUS_WARN;
  859.     DTAC_Config[spawnkill] = CHEAT_STATUS_WARN;
  860.     DTAC_Config[quickturn] = CHEAT_STATUS_WARN;
  861.     DTAC_Config[joypad] = CHEAT_STATUS_OFF;
  862.  
  863.     DTAC_Config[maxwarns] = 3;
  864.     DTAC_Config[savewarns] = false;
  865.     DTAC_Config[spawnprotecttime] = 5; // 5 seconds
  866.     return true;
  867. }
  868.  
  869. // I miss this in SAMP, so hrer it is, "character" = The char to find, "count" = The first char (0) ? The second (1) ? The third (2) ?
  870. forward str_find(string[], lenght, character, count);
  871. public str_find(string[], lenght, character, count)
  872. {
  873.     //return strfind(string, character, true);
  874.     new charcounter = 0;
  875.     for(new i = 0; i < lenght; i++)
  876.     {
  877.         if(string[i] == 0) break; // EOS
  878.         if(string[i] == character)
  879.         {
  880.             if(charcounter == count)
  881.                 return i;
  882.             charcounter++;
  883.         }
  884.     }
  885.     return -1;
  886. }
  887.  
  888. forward sub_str(string[], target[], from, to);
  889. public sub_str(string[], target[], from, to)
  890. {
  891.     /*new charcounter = 0;
  892.     for(new i = from; i <= to; i++)
  893.     {
  894.         target[charcounter] = string[i];
  895.         charcounter++;
  896.     }
  897.     target[charcounter] = 0;*/
  898.     strmid(target, string, from, to, (to - from) + 1);
  899.     return true;
  900. }
  901.  
  902. // I took this from my last Anticheat
  903. forward IsDrivebyVehicle(vehiclemodel);
  904. public IsDrivebyVehicle(vehiclemodel)
  905. {
  906.     if(vehiclemodel == 425) { return true; } // Hunter
  907.     if(vehiclemodel == 432) { return true; } // Rhino
  908.     if(vehiclemodel == 447) { return true; } // Seasparrow
  909.     if(vehiclemodel == 472) { return true; } // Not shure, I think Coastguard can shoot ?!?
  910.     if(vehiclemodel == 520) { return true; } // Hydra
  911.     return false;
  912. }
  913.  
  914. forward IsAPlane(vehiclemodel);
  915. public IsAPlane(vehiclemodel)
  916. {
  917.    if(vehiclemodel == 460)  { return true; }
  918.    if(vehiclemodel == 476)  { return true; }
  919.    if(vehiclemodel == 511)  { return true; }
  920.    if(vehiclemodel == 512)  { return true; }
  921.    if(vehiclemodel == 513)  { return true; }
  922.    if(vehiclemodel == 519)  { return true; }
  923.    if(vehiclemodel == 520)  { return true; }
  924.    if(vehiclemodel == 533)  { return true; }
  925.    if(vehiclemodel == 553)  { return true; }
  926.    if(vehiclemodel == 577)  { return true; }
  927.    if(vehiclemodel == 592)  { return true; }
  928.    if(vehiclemodel == 593)  { return true; }
  929.    return false;
  930. }
  931.  
  932. forward IsABike(vehiclemodel);
  933. public IsABike(vehiclemodel)
  934. {
  935.    if(vehiclemodel == 448)  { return true; }
  936.    if(vehiclemodel == 461)  { return true; }
  937.    if(vehiclemodel == 462)  { return true; }
  938.    if(vehiclemodel == 463)  { return true; }
  939.    if(vehiclemodel == 468)  { return true; }
  940.    if(vehiclemodel == 471)  { return true; }
  941.    if(vehiclemodel == 481)  { return true; }
  942.    if(vehiclemodel == 509)  { return true; }
  943.    if(vehiclemodel == 510)  { return true; }
  944.    if(vehiclemodel == 521)  { return true; }
  945.    if(vehiclemodel == 522)  { return true; }
  946.    if(vehiclemodel == 523)  { return true; }
  947.    if(vehiclemodel == 281)  { return true; }
  948.    if(vehiclemodel == 586)  { return true; }
  949.    return false;
  950. }
  951.  
  952. forward IsATrain(vehiclemodel);
  953. public IsATrain(vehiclemodel)
  954. {
  955.    if(vehiclemodel == 537)  { return true; }
  956.    if(vehiclemodel == 538)  { return true; }
  957.    if(vehiclemodel == 569)  { return true; }
  958.    if(vehiclemodel == 570)  { return true; }
  959.    if(vehiclemodel == 590)  { return true; }
  960.    return false;
  961. }
  962.  
  963. forward LogText(text[]);
  964. public LogText(text[])
  965. {
  966.     new year, month, day, hour, minute, second, string[128];
  967.     getdate(year, month, day);
  968.     gettime(hour, minute, second);
  969.     format(string, 128, "<%d.%d.%d %d:%d> %s\r\n", day, month, year, hour, minute, text);
  970.     new File:logfile = fopen("DT_AntiCheat/log.txt", io_append);
  971.     fwrite(logfile, text);
  972.     fclose(logfile);
  973.     printf(text);
  974.     return true;
  975. }
  976.  
  977. forward WarnPlayer(playerid, warns, reason[]);
  978. public WarnPlayer(playerid, warns, reason[])
  979. {
  980.     new string[128];
  981.     DTAC_Player[playerid][apWarns] += warns;
  982.     if(DTAC_Player[playerid][apWarns] >= 3)
  983.     {
  984.         #if defined SILENT_MODE
  985.             CrashPlayer(playerid);
  986.         #else
  987.             format(string, 128, "AC: You have beenkicked, reason: %s", reason);
  988.             SendClientMessage(playerid, 0xFFFF00, string);
  989.             Kick(playerid);
  990.         #endif
  991.     }
  992.     else
  993.     {
  994.         #if defined SILENT_MODE
  995.  
  996.         #else
  997.             format(string, 128, "AC: You got a warning, reason: %s", reason);
  998.             SendClientMessage(playerid, 0xFFFF00, string);
  999.         #endif
  1000.     }
  1001.     return true;
  1002. }
  1003.  
  1004. forward CrashPlayer(playerid);
  1005. public CrashPlayer(playerid)
  1006. {
  1007.     new rand = random(3);
  1008.     switch(rand)
  1009.     {
  1010.         // Wrong Skin -> SAMP crash
  1011.         case 0: { return SetPlayerSkin(playerid, -1); }
  1012.         // Division through zero -> nullpointer at client
  1013.         case 1: { return SetPlayerVelocity(playerid, (5.0/0), (5.0/0), (5.0/0)); }
  1014.         // To much speed ( 16777215 m/s ) -> crash
  1015.         case 2: { return SetPlayerVelocity(playerid, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF); }
  1016.     }
  1017.     return true;
  1018. }
  1019.  
  1020. forward BanPlayer(playerid);
  1021. public BanPlayer(playerid)
  1022. {
  1023.     new string[128], name[32];
  1024.     GetPlayerName(playerid, name, 32);
  1025.     format(string, 128, "DT_Anticheat/%s.ban", name);
  1026.     new File:file = fopen(string, io_write);
  1027.     format(string, 128, "time=%d", GetTimestamp());
  1028.     fwrite(file, string);
  1029.     fclose(file);
  1030.     return true;
  1031. }
  1032.  
  1033. forward GetWeaponSlot(weaponid);
  1034. public GetWeaponSlot(weaponid)
  1035. {
  1036.     switch(weaponid)
  1037.     {
  1038.         case  0: return  0;
  1039.         case  1: return  0;
  1040.         case  2: return  1;
  1041.         case  3: return  1;
  1042.         case  4: return  1;
  1043.         case  5: return  1;
  1044.         case  6: return  1;
  1045.         case  7: return  1;
  1046.         case  8: return  1;
  1047.         case  9: return  1;
  1048.         case 10: return 10;
  1049.         case 11: return 10;
  1050.         case 12: return 10;
  1051.         case 13: return 10;
  1052.         case 14: return 10;
  1053.         case 15: return 10;
  1054.         case 16: return  8;
  1055.         case 17: return  8;
  1056.         case 18: return  8;
  1057.         case 22: return  2;
  1058.         case 23: return  2;
  1059.         case 24: return  2;
  1060.         case 25: return  3;
  1061.         case 26: return  3;
  1062.         case 27: return  3;
  1063.         case 28: return  4;
  1064.         case 29: return  4;
  1065.         case 30: return  5;
  1066.         case 31: return  5;
  1067.         case 32: return  4;
  1068.         case 33: return  6;
  1069.         case 34: return  6;
  1070.         case 35: return  7;
  1071.         case 36: return  7;
  1072.         case 37: return  7;
  1073.         case 38: return  7;
  1074.         case 39: return  8;
  1075.         case 40: return 12;
  1076.         case 41: return  9;
  1077.         case 42: return  9;
  1078.         case 43: return  9;
  1079.         case 44: return 11;
  1080.         case 45: return 11;
  1081.         case 46: return 11;
  1082.         default: return -1;
  1083.     }
  1084.     return -1; // to prevent a warning ^^
  1085. }
  1086.  
  1087. forward GetTimestamp();
  1088. public GetTimestamp()
  1089. {
  1090.     new _sek, _min, _hour, _day, _month, _year, _timestamp;
  1091.     getdate(_year, _month, _day);
  1092.     gettime(_hour, _min, _sek);
  1093.     _timestamp = _sek;
  1094.     _timestamp += _min * 60;
  1095.     _timestamp += _hour * 60 * 60;
  1096.     _timestamp += _day * 60 * 60 * 24;
  1097.     _timestamp += _month * 60 * 60 * 24 * 31;
  1098.     _timestamp += (_year - 1980) * 60 * 60 * 24 * 31 * 12;
  1099.     return _timestamp;
  1100. }
  1101.  
  1102. forward FormTimestamp(form[], timestamp, returnvar[], returnsize);
  1103. public FormTimestamp(form[], timestamp, returnvar[], returnsize)
  1104. {
  1105.     new count = 0;
  1106.     format(returnvar, returnsize, "");
  1107.     new _year, _month, _day, _hour, _min, _sec;
  1108.     while(timestamp >= 32140800)    { _year++;  timestamp -= 32140800; }
  1109.     while(timestamp >= 2678400)     { _month++; timestamp -= 2678400; }
  1110.     while(timestamp >= 86400)       { _day++;   timestamp -= 86400; }
  1111.     while(timestamp >= 3600)        { _hour++;  timestamp -= 3600; }
  1112.     while(timestamp >= 60)          { _min++;   timestamp -= 60; }
  1113.     _sec = timestamp;
  1114.    
  1115.     while(form[count])
  1116.     {
  1117.         if(form[count] == 's')
  1118.         {
  1119.             format(returnvar, returnsize, "%s%d", returnvar, _sec);
  1120.         }
  1121.         else if(form[count] == 'S')
  1122.         {
  1123.             if(_sec < 10)
  1124.                 format(returnvar, returnsize, "%s0%d", returnvar, _sec);
  1125.             else
  1126.                 format(returnvar, returnsize, "%s%d", returnvar, _sec);
  1127.         }
  1128.         else if(form[count] == 'm')
  1129.         {
  1130.             format(returnvar, returnsize, "%s%d", returnvar, _min);
  1131.         }
  1132.         else if(form[count] == 'M')
  1133.         {
  1134.             if(_min < 10)
  1135.                 format(returnvar, returnsize, "%s0%d", returnvar, _min);
  1136.             else
  1137.                 format(returnvar, returnsize, "%s%d", returnvar, _min);
  1138.         }
  1139.         else if(form[count] == 'h')
  1140.         {
  1141.             format(returnvar, returnsize, "%s%d", returnvar, _hour);
  1142.         }
  1143.         else if(form[count] == 'H')
  1144.         {
  1145.             if(_hour < 10)
  1146.                 format(returnvar, returnsize, "%s0%d", returnvar, _hour);
  1147.             else
  1148.                 format(returnvar, returnsize, "%s%d", returnvar, _hour);
  1149.         }
  1150.         else if(form[count] == 'd')
  1151.         {
  1152.             format(returnvar, returnsize, "%s%d", returnvar, _day);
  1153.         }
  1154.         else if(form[count] == 'D')
  1155.         {
  1156.             if(_day < 10)
  1157.                 format(returnvar, returnsize, "%s0%d", returnvar, _day);
  1158.             else
  1159.                 format(returnvar, returnsize, "%s%d", returnvar, _day);
  1160.         }
  1161.         else if(form[count] == 'z')
  1162.         {
  1163.             format(returnvar, returnsize, "%s%d", returnvar, _month);
  1164.         }
  1165.         else if(form[count] == 'Z')
  1166.         {
  1167.             if(_month < 10)
  1168.                 format(returnvar, returnsize, "%s0%d", returnvar, _month);
  1169.             else
  1170.                 format(returnvar, returnsize, "%s%d", returnvar, _month);
  1171.         }
  1172.         else if(form[count] == 'y')
  1173.         {
  1174.             format(returnvar, returnsize, "%s%d", returnvar, _year);
  1175.         }
  1176.         else if(form[count] == 'Y')
  1177.         {
  1178.             if(_year < 10)
  1179.                 format(returnvar, returnsize, "%s0%d", returnvar, _year);
  1180.             else
  1181.                 format(returnvar, returnsize, "%s%d", returnvar, _year);
  1182.         }
  1183.         else
  1184.             format(returnvar, returnsize, "%s%s", returnvar, form[count]);
  1185.         count++;
  1186.     }
  1187.     return true;
  1188. }
  1189.  
  1190. /********************************************************************************************/
  1191. /*                         THE HOOKED CALLBACKS FROM EVERY GM / FS                          */
  1192. /********************************************************************************************/
  1193. forward _AC_GivePlayerMoney(playerid, themoney);
  1194. forward _AC_ResetPlayerMoney(playerid);
  1195.  
  1196. public _AC_GivePlayerMoney(playerid, themoney)
  1197. {
  1198.     DTAC_Player[playerid][apFreeTime] = FREETIME_MONEY;
  1199.     DTAC_Player[playerid][apMoney] += themoney;
  1200.     GivePlayerMoney(playerid, themoney);
  1201.     return true;
  1202. }
  1203.  
  1204. public _AC_ResetPlayerMoney(playerid)
  1205. {
  1206.     DTAC_Player[playerid][apFreeTime] = FREETIME_MONEY;
  1207.     DTAC_Player[playerid][apMoney] = 0;
  1208.     ResetPlayerMoney(playerid);
  1209.     return true;
  1210. }
  1211.  
  1212. forward _AC_SetPlayerPos(playerid, Float:x, Float:y, Float:z);
  1213. forward _AC_SetPlayerPosFindZ(playerid, Float:x, Float:y, Float:z);
  1214. forward _AC_SetPlayerVelocity(playerid, Float:x, Float:y, Float:z);
  1215. forward _AC_SetVehicleVelocity(vehicleid, Float:x, Float:y, Float:z);
  1216. forward _AC_SetVehiclePos(vehicleid, Float:x, Float:y, Float:z);
  1217.  
  1218. public _AC_SetPlayerPos(playerid, Float:x, Float:y, Float:z)
  1219. {
  1220.     DTAC_Player[playerid][apFreeTime] = FREETIME_TELEPORT;
  1221.     DTAC_Player[playerid][apPosition][0] = x;
  1222.     DTAC_Player[playerid][apPosition][1] = y;
  1223.     DTAC_Player[playerid][apPosition][2] = z;
  1224.     SetPlayerPos(playerid, x, y, z);
  1225.     return true;
  1226. }
  1227.  
  1228. public _AC_SetPlayerPosFindZ(playerid, Float:x, Float:y, Float:z)
  1229. {
  1230.     DTAC_Player[playerid][apFreeTime] = FREETIME_TELEPORT;
  1231.     DTAC_Player[playerid][apPosition][0] = x;
  1232.     DTAC_Player[playerid][apPosition][1] = y;
  1233.     DTAC_Player[playerid][apPosition][2] = 0.0;
  1234.     SetPlayerPosFindZ(playerid, x, y, z);
  1235.     return true;
  1236. }
  1237.  
  1238. public _AC_SetPlayerVelocity(playerid, Float:x, Float:y, Float:z)
  1239. {
  1240.     DTAC_Player[playerid][apFreeTime] = FREETIME_TELEPORT;
  1241.     DTAC_Player[playerid][apPosition][0] += x;
  1242.     DTAC_Player[playerid][apPosition][1] += y;
  1243.     DTAC_Player[playerid][apPosition][2] += z;
  1244.     SetPlayerVelocity(playerid, x, y, z);
  1245.     return true;
  1246. }
  1247.  
  1248. public _AC_SetVehicleVelocity(vehicleid, Float:x, Float:y, Float:z)
  1249. {
  1250.     for(new i = 0; i < MAX_PLAYERS; i++)
  1251.     {
  1252.         if(IsPlayerConnected(i) && IsPlayerInVehicle(i, vehicleid))
  1253.         {
  1254.             DTAC_Player[i][apFreeTime] = FREETIME_TELEPORT;
  1255.             DTAC_Player[i][apPosition][0] += x;
  1256.             DTAC_Player[i][apPosition][1] += y;
  1257.             DTAC_Player[i][apPosition][2] += z;
  1258.         }
  1259.     }
  1260.     SetVehicleVelocity(vehicleid, x, y, z);
  1261.     return true;
  1262. }
  1263.  
  1264. public _AC_SetVehiclePos(vehicleid, Float:x, Float:y, Float:z)
  1265. {
  1266.     for(new i = 0; i < MAX_PLAYERS; i++)
  1267.     {
  1268.         if(IsPlayerConnected(i) && IsPlayerInVehicle(i, vehicleid))
  1269.         {
  1270.             DTAC_Player[i][apFreeTime] = FREETIME_TELEPORT;
  1271.             DTAC_Player[i][apPosition][0] = x;
  1272.             DTAC_Player[i][apPosition][1] = y;
  1273.             DTAC_Player[i][apPosition][2] = z;
  1274.         }
  1275.     }
  1276.     SetVehiclePos(vehicleid, x, y, z);
  1277.     return true;
  1278. }
  1279.  
  1280. forward _AC_SetPlayerHealth(playerid, Float:health);
  1281. forward _AC_SetPlayerArmour(playerid, Float:setarmour);
  1282.  
  1283. public _AC_SetPlayerHealth(playerid, Float:health)
  1284. {
  1285.     DTAC_Player[playerid][apHealth] = health;
  1286.     DTAC_Player[playerid][apFreeTime] = FREETIME_HEALTH;
  1287.     SetPlayerHealth(playerid, health);
  1288.     return true;
  1289. }
  1290.  
  1291. public _AC_SetPlayerArmour(playerid, Float:setarmour)
  1292. {
  1293.     DTAC_Player[playerid][apArmour] = setarmour;
  1294.     DTAC_Player[playerid][apFreeTime] = FREETIME_HEALTH;
  1295.     SetPlayerArmour(playerid, setarmour);
  1296.     return true;
  1297. }
  1298.  
  1299. forward _AC_GivePlayerWeapon(playerid, weaponid, ammo2);
  1300. forward _AC_ResetPlayerWeapons(playerid);
  1301.  
  1302. public _AC_GivePlayerWeapon(playerid, weaponid, ammo2)
  1303. {
  1304.     new weaponslot = GetWeaponSlot(weaponid);
  1305.     if(weaponslot < 0 || weaponslot > 12) return false;
  1306.     DTAC_Player[playerid][apFreeTime] = FREETIME_WEAPON;
  1307.     DTAC_Player[playerid][apWeapons][weaponslot] = weaponid;
  1308.     if(DTAC_Player[playerid][apAmmo][weaponslot] == -1 || DTAC_Player[playerid][apAmmo][weaponslot] == 0)
  1309.         DTAC_Player[playerid][apAmmo][weaponslot] = ammo2;
  1310.     else
  1311.         DTAC_Player[playerid][apAmmo][weaponslot] += ammo2;
  1312.     GivePlayerWeapon(playerid, weaponid, ammo2);
  1313.     return true;
  1314. }
  1315.  
  1316. public _AC_ResetPlayerWeapons(playerid)
  1317. {
  1318.     ResetPlayerWeapons(playerid);
  1319.     for(new i = 0; i < 13; i++)
  1320.     {
  1321.         DTAC_Player[playerid][apWeapons][i] = -1;
  1322.         DTAC_Player[playerid][apAmmo][i] = -1;
  1323.     }
  1324.     return true;
  1325. }
  1326.  
  1327. forward _AC_AddPlayerClass(skin2, Float:SpawnX, Float:SpawnY, Float:SpawnZ, Float:SpawnA, weapon1, ammo1, weapon2, ammo2, weapon3, ammo3);
  1328. forward _AC_AddPlayerClassEx(teamid, skin2, Float:SpawnX, Float:SpawnY, Float:SpawnZ, Float:SpawnA, weapon1, ammo1, weapon2, ammo2, weapon3, ammo3);
  1329.  
  1330. public _AC_AddPlayerClass(skin2, Float:SpawnX, Float:SpawnY, Float:SpawnZ, Float:SpawnA, weapon1, ammo1, weapon2, ammo2, weapon3, ammo3)
  1331. {
  1332.     new id = AddPlayerClass(skin2, SpawnX, SpawnY, SpawnZ, SpawnA, weapon1, ammo1, weapon2, ammo2, weapon3, ammo3);
  1333.     SpawnClasses[id][team] = -1;
  1334.     SpawnClasses[id][skin] = skin2;
  1335.     SpawnClasses[id][spawnx] = SpawnX;
  1336.     SpawnClasses[id][spawny] = SpawnY;
  1337.     SpawnClasses[id][spawny] = SpawnZ;
  1338.     SpawnClasses[id][spawna] = SpawnA;
  1339.     SpawnClasses[id][weapons][0] = weapon1;
  1340.     SpawnClasses[id][ammo][0] = ammo1;
  1341.     SpawnClasses[id][weapons][1] = weapon2;
  1342.     SpawnClasses[id][ammo][1] = ammo2;
  1343.     SpawnClasses[id][weapons][2] = weapon3;
  1344.     SpawnClasses[id][ammo][2] = ammo3;
  1345.     return id;
  1346. }
  1347.  
  1348. public _AC_AddPlayerClassEx(teamid, skin2, Float:SpawnX, Float:SpawnY, Float:SpawnZ, Float:SpawnA, weapon1, ammo1, weapon2, ammo2, weapon3, ammo3)
  1349. {
  1350.     new id = AddPlayerClassEx(teamid, skin2, SpawnX, SpawnY, SpawnZ, SpawnA, weapon1, ammo1, weapon2, ammo2, weapon3, ammo3);
  1351.     SpawnClasses[id][team] = teamid;
  1352.     SpawnClasses[id][skin] = skin2;
  1353.     SpawnClasses[id][spawnx] = SpawnX;
  1354.     SpawnClasses[id][spawny] = SpawnY;
  1355.     SpawnClasses[id][spawny] = SpawnZ;
  1356.     SpawnClasses[id][spawna] = SpawnA;
  1357.     SpawnClasses[id][weapons][0] = weapon1;
  1358.     SpawnClasses[id][ammo][0] = ammo1;
  1359.     SpawnClasses[id][weapons][1] = weapon2;
  1360.     SpawnClasses[id][ammo][1] = ammo2;
  1361.     SpawnClasses[id][weapons][2] = weapon3;
  1362.     SpawnClasses[id][ammo][2] = ammo3;
  1363.     return id;
  1364. }
  1365.  
  1366. /********************************************************************************************/
  1367. /*                                   THE CERNEL FUNCTION                                    */
  1368. /********************************************************************************************/
  1369.  
  1370. forward OnAnticheatUpdate();
  1371. public OnAnticheatUpdate()
  1372. {
  1373.     new Float:tmpx, Float:tmpy, Float:tmpz, Float:tmpa, Float: distance;
  1374.     new Float:tmphp, Float:tmparmour, tmpmoney;
  1375.     new bool:tmplostmoney;
  1376.     new string[128], name[32];
  1377.     new vehicleid;
  1378.     new keyleft, keyright, keys;
  1379.     for(new playerid = 0; playerid < MAX_PLAYERS; playerid++)
  1380.     {
  1381.         if(!IsPlayerConnected(playerid)) continue;
  1382.         if(DTAC_Player[playerid][apFreeTime] >= 1)
  1383.         {
  1384.             DTAC_Player[playerid][apFreeTime]--;
  1385.             // To prevent kick when running and beeing in "free mode"
  1386.             GetPlayerPos(playerid, DTAC_Player[playerid][apPosition][0], DTAC_Player[playerid][apPosition][1], DTAC_Player[playerid][apPosition][2]);
  1387.             continue;
  1388.         }
  1389.        
  1390.         if(DTAC_Player[playerid][apUnkillableTime] >= 1)
  1391.         {
  1392.             DTAC_Player[playerid][apUnkillableTime]--;
  1393.             if(DTAC_Config[spawnkill] == CHEAT_STATUS_UNDO)
  1394.             {
  1395.                 DTAC_Player[playerid][apHealth] = 65534.0;
  1396.                 SetPlayerHealth(playerid, 65534.0);
  1397.                 if(DTAC_Player[playerid][apUnkillableTime] == 0)
  1398.                 {
  1399.                     DTAC_Player[playerid][apHealth] = 100.0;
  1400.                     SetPlayerHealth(playerid, 100.0);
  1401.                 }
  1402.             }
  1403.         }
  1404.        
  1405.         tmplostmoney = false;
  1406.         GetPlayerPos(playerid, tmpx, tmpy, tmpz);
  1407.         if(IsPlayerInAnyVehicle(playerid))
  1408.             GetVehicleZAngle(GetPlayerVehicleID(playerid), tmpa);
  1409.         else
  1410.             GetPlayerFacingAngle(playerid, tmpa);
  1411.         GetPlayerHealth(playerid, tmphp);
  1412.         GetPlayerArmour(playerid, tmparmour);
  1413.         tmpmoney = GetPlayerMoney(playerid);
  1414.         GetPlayerKeys(playerid, keys, keyleft, keyright);
  1415.  
  1416.         new Float:distancex, Float:distancey, Float:distancez;
  1417.         if(DTAC_Player[playerid][apPosition][0] > tmpx)
  1418.             distancex = DTAC_Player[playerid][apPosition][0] - tmpx;
  1419.         else
  1420.             distancex = tmpx - DTAC_Player[playerid][apPosition][0];
  1421.         if(DTAC_Player[playerid][apPosition][1] > tmpy)
  1422.             distancey = DTAC_Player[playerid][apPosition][1] - tmpy;
  1423.         else
  1424.             distancey = tmpy - DTAC_Player[playerid][apPosition][1];
  1425.         if(DTAC_Player[playerid][apPosition][2] > tmpz)
  1426.             distancez = DTAC_Player[playerid][apPosition][2] - tmpz;
  1427.         else
  1428.             distancez = tmpz - DTAC_Player[playerid][apPosition][2];
  1429.         distance = floatsqroot(distancex * distancex + distancey * distancey + distancez * distancez);
  1430.        
  1431.         GetPlayerName(playerid, name, 32);
  1432.        
  1433.         if(IsPlayerInAnyVehicle(playerid))
  1434.             vehicleid = GetPlayerVehicleID(playerid);
  1435.         else if(GetPlayerSurfingVehicleID(playerid) != INVALID_VEHICLE_ID)
  1436.             vehicleid = GetPlayerSurfingVehicleID(playerid);
  1437.         else
  1438.             vehicleid = INVALID_VEHICLE_ID;
  1439.            
  1440.         /* Money hack */
  1441.         if(DTAC_Config[money] > CHEAT_STATUS_OFF)
  1442.         {
  1443.             if(DTAC_Player[playerid][apMoney] > tmpmoney)
  1444.             {
  1445.                 // He lost Money :)
  1446.                 tmplostmoney = true;
  1447.                 DTAC_Player[playerid][apMoney] = tmpmoney;
  1448.                 ResetPlayerMoney(playerid);
  1449.                 GivePlayerMoney(playerid, tmpmoney);
  1450.             }
  1451.             else if(DTAC_Player[playerid][apMoney] < tmpmoney)
  1452.             {
  1453.                 // Cheat Oo
  1454.                 format(string, 128, "%s tryes to cheat ( Money cheat )", name);
  1455.                 LogText(string);
  1456.                 switch(DTAC_Config[money])
  1457.                 {
  1458.                     case CHEAT_STATUS_UNDO:
  1459.                     {
  1460.                         ResetPlayerMoney(playerid);
  1461.                         GivePlayerMoney(playerid, DTAC_Player[playerid][apMoney]);
  1462.                     }
  1463.                     case CHEAT_STATUS_WARN:
  1464.                     {
  1465.                         WarnPlayer(playerid, 1, "Money cheat");
  1466.                         ResetPlayerMoney(playerid);
  1467.                         GivePlayerMoney(playerid, DTAC_Player[playerid][apMoney]);
  1468.                     }
  1469.                     case CHEAT_STATUS_KICK:
  1470.                     {
  1471.                         #if defined SILENT_MODE
  1472.                             CrashPlayer(playerid);
  1473.                         #else
  1474.                             format(string, 128, "%s has been kicked due cheating ( money cheat )", name);
  1475.                             SendClientMessageToAll(0xFF0000FF, string);
  1476.                             Kick(playerid);
  1477.                         #endif
  1478.                     }
  1479.                     case CHEAT_STATUS_BAN:
  1480.                     {
  1481.                         BanPlayer(playerid);
  1482.                         #if defined SILENT_MODE
  1483.                             CrashPlayer(playerid);
  1484.                         #else
  1485.                             format(string, 128, "%s has been banned due cheating ( money cheat )", name);
  1486.                             SendClientMessageToAll(0xFF0000FF, string);
  1487.                             Kick(playerid);
  1488.                         #endif
  1489.                     }
  1490.                 }
  1491.             }
  1492.         }
  1493.         /* spam */
  1494.         if(DTAC_Config[spam] > CHEAT_STATUS_OFF)
  1495.         {
  1496.             if(DTAC_Player[playerid][apMuted] >= 1) DTAC_Player[playerid][apMuted]--;
  1497.             if(DTAC_Player[playerid][apSpamMessages] >= 3)
  1498.             {
  1499.                 DTAC_Player[playerid][apSpamMessages] = 0;
  1500.                 DTAC_Player[playerid][apMuted] += DTAC_Player[playerid][apSpamMessages] * 20;
  1501.             }
  1502.             DTAC_Player[playerid][apSpamMessages]--;
  1503.         }
  1504.         /* health */
  1505.         if(DTAC_Config[heal] > CHEAT_STATUS_OFF)
  1506.         {
  1507.             if(tmphp > DTAC_Player[playerid][apHealth])
  1508.             {
  1509.                 if(tmplostmoney)
  1510.                 {
  1511.                     // Healed on a vending machine or a bs
  1512.                     SetPlayerHealth(playerid, tmphp);
  1513.                 }
  1514.                 else
  1515.                 {
  1516.                     // Cheater !
  1517.                     format(string, 128, "%s tryes to cheat ( health cheat / has %.1f, should have %.1f )", name, tmphp, DTAC_Player[playerid][apHealth]);
  1518.                     LogText(string);
  1519.                     switch(DTAC_Config[heal])
  1520.                     {
  1521.                         case CHEAT_STATUS_UNDO:
  1522.                         {
  1523.                             SetPlayerHealth(playerid, DTAC_Player[playerid][apHealth]);
  1524.                         }
  1525.                         case CHEAT_STATUS_WARN:
  1526.                         {
  1527.                             WarnPlayer(playerid, 1, "heal cheat");
  1528.                             SetPlayerHealth(playerid, DTAC_Player[playerid][apHealth]);
  1529.                         }
  1530.                         case CHEAT_STATUS_KICK:
  1531.                         {
  1532.                             #if defined SILENT_MODE
  1533.                                 CrashPlayer(playerid);
  1534.                             #else
  1535.                                 format(string, 128, "%s has been kicked due cheating ( heal cheat )", name);
  1536.                                 SendClientMessageToAll(0xFF0000FF, string);
  1537.                                 Kick(playerid);
  1538.                             #endif
  1539.                         }
  1540.                         case CHEAT_STATUS_BAN:
  1541.                         {
  1542.                             BanPlayer(playerid);
  1543.                             #if defined SILENT_MODE
  1544.                                 CrashPlayer(playerid);
  1545.                             #else
  1546.                                 format(string, 128, "%s has been banned due cheating ( heal cheat )", name);
  1547.                                 SendClientMessageToAll(0xFF0000FF, string);
  1548.                                 Kick(playerid);
  1549.                             #endif
  1550.                         }
  1551.                     }
  1552.                 }
  1553.             }
  1554.             else if(tmphp < DTAC_Player[playerid][apHealth])
  1555.             {
  1556.                 DTAC_Player[playerid][apHealth] = tmphp;
  1557.             }
  1558.         }
  1559.         /* armour */
  1560.         if(DTAC_Config[armour] > CHEAT_STATUS_OFF)
  1561.         {
  1562.             if(tmparmour > DTAC_Player[playerid][apArmour])
  1563.             {
  1564.                 if(tmplostmoney)
  1565.                 {
  1566.                     // Healed on a vending machine or a bs
  1567.                     SetPlayerArmour(playerid, tmparmour);
  1568.                 }
  1569.                 else
  1570.                 {
  1571.                     // Cheater !
  1572.                     format(string, 128, "%s tryes to cheat ( armour cheat )", name);
  1573.                     LogText(string);
  1574.                     switch(DTAC_Config[heal])
  1575.                     {
  1576.                         case CHEAT_STATUS_UNDO:
  1577.                         {
  1578.                             SetPlayerArmour(playerid, DTAC_Player[playerid][apArmour]);
  1579.                         }
  1580.                         case CHEAT_STATUS_WARN:
  1581.                         {
  1582.                             WarnPlayer(playerid, 1, "armour cheat");
  1583.                             SetPlayerArmour(playerid, DTAC_Player[playerid][apArmour]);
  1584.                         }
  1585.                         case CHEAT_STATUS_KICK:
  1586.                         {
  1587.                             #if defined SILENT_MODE
  1588.                                 CrashPlayer(playerid);
  1589.                             #else
  1590.                                 format(string, 128, "%s has been kicked due cheating ( armour cheat )", name);
  1591.                                 SendClientMessageToAll(0xFF0000FF, string);
  1592.                                 Kick(playerid);
  1593.                             #endif
  1594.                         }
  1595.                         case CHEAT_STATUS_BAN:
  1596.                         {
  1597.                             BanPlayer(playerid);
  1598.                             #if defined SILENT_MODE
  1599.                                 CrashPlayer(playerid);
  1600.                             #else
  1601.                                 format(string, 128, "%s has been banned due cheating ( armour cheat )", name);
  1602.                                 SendClientMessageToAll(0xFF0000FF, string);
  1603.                                 Kick(playerid);
  1604.                             #endif
  1605.                         }
  1606.                     }
  1607.                 }
  1608.             }
  1609.             else if(tmparmour < DTAC_Player[playerid][apArmour])
  1610.             {
  1611.                 DTAC_Player[playerid][apArmour] = tmparmour;
  1612.             }
  1613.         }
  1614.         /* Jetpack */
  1615.         if(DTAC_Config[jetpack] > CHEAT_STATUS_OFF)
  1616.         {
  1617.             if(GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_USEJETPACK)
  1618.             {
  1619.                 format(string, 128, "%s tryes to cheat ( jetpack cheat )", name);
  1620.                 LogText(string);
  1621.                 switch(DTAC_Config[jetpack])
  1622.                 {
  1623.                     case CHEAT_STATUS_UNDO:
  1624.                     {
  1625.                         SetPlayerSpecialAction(playerid, SPECIAL_ACTION_NONE);
  1626.                     }
  1627.                     case CHEAT_STATUS_WARN:
  1628.                     {
  1629.                         WarnPlayer(playerid, 1, "jetpack cheat");
  1630.                         SetPlayerSpecialAction(playerid, SPECIAL_ACTION_NONE);
  1631.                     }
  1632.                     case CHEAT_STATUS_KICK:
  1633.                     {
  1634.                         #if defined SILENT_MODE
  1635.                             CrashPlayer(playerid);
  1636.                         #else
  1637.                             format(string, 128, "%s has been kicked due cheating ( jetpack cheat )", name);
  1638.                             SendClientMessageToAll(0xFF0000FF, string);
  1639.                             Kick(playerid);
  1640.                         #endif
  1641.                     }
  1642.                     case CHEAT_STATUS_BAN:
  1643.                     {
  1644.                         BanPlayer(playerid);
  1645.                         #if defined SILENT_MODE
  1646.                             CrashPlayer(playerid);
  1647.                         #else
  1648.                             format(string, 128, "%s has been banned due cheating ( armour cheat )", name);
  1649.                             SendClientMessageToAll(0xFF0000FF, string);
  1650.                             Kick(playerid);
  1651.                         #endif
  1652.                     }
  1653.                 }
  1654.             }
  1655.         }
  1656.         /* Speed */
  1657.         if(DTAC_Config[speed] > CHEAT_STATUS_OFF)
  1658.         {
  1659.             //new Float:tmpx, Float:tmpy, Float:tmpz;
  1660.             if(vehicleid != INVALID_VEHICLE_ID)
  1661.             {
  1662.                 if(IsAPlane(GetVehicleModel(vehicleid)) && distance >= 150)
  1663.                 {
  1664.                     format(string, 128, "%s trys to cheat ( plane, speedhack, %.1f m/s )", name, distance);
  1665.                     LogText(string);
  1666.                     switch(DTAC_Config[speed])
  1667.                     {
  1668.                         case CHEAT_STATUS_UNDO:
  1669.                         {
  1670.                             SetPlayerPos(playerid, DTAC_Player[playerid][apPosition][0], DTAC_Player[playerid][apPosition][1], DTAC_Player[playerid][apPosition][2]);
  1671.                         }
  1672.                         case CHEAT_STATUS_WARN:
  1673.                         {
  1674.                             WarnPlayer(playerid, 1, "airbreak / speedhack / flyhack cheat");
  1675.                         }
  1676.                         case CHEAT_STATUS_KICK:
  1677.                         {
  1678.                             #if defined SILENT_MODE
  1679.                                 CrashPlayer(playerid);
  1680.                             #else
  1681.                                 format(string, 128, "%s has been kicked due cheating ( airbreak / speedhack / flyhack cheat )", name);
  1682.                                 SendClientMessageToAll(0xFF0000FF, string);
  1683.                                 Kick(playerid);
  1684.                             #endif
  1685.                         }
  1686.                         case CHEAT_STATUS_BAN:
  1687.                         {
  1688.                             BanPlayer(playerid);
  1689.                             #if defined SILENT_MODE
  1690.                                 CrashPlayer(playerid);
  1691.                             #else
  1692.                                 format(string, 128, "%s has been banned due cheating ( airbreak / speedhack / flyhack cheat )", name);
  1693.                                 SendClientMessageToAll(0xFF0000FF, string);
  1694.                                 Kick(playerid);
  1695.                             #endif
  1696.                         }
  1697.                     }
  1698.                 }
  1699.                 else if(IsABike(GetVehicleModel(vehicleid)) && distance >= 100)
  1700.                 {
  1701.                     format(string, 128, "%s trys to cheat ( bike, speedhack, %.1f m/s )", name, distance);
  1702.                     LogText(string);
  1703.                     switch(DTAC_Config[speed])
  1704.                     {
  1705.                         case CHEAT_STATUS_UNDO:
  1706.                         {
  1707.                             SetPlayerPos(playerid, DTAC_Player[playerid][apPosition][0], DTAC_Player[playerid][apPosition][1], DTAC_Player[playerid][apPosition][2]);
  1708.                         }
  1709.                         case CHEAT_STATUS_WARN:
  1710.                         {
  1711.                             WarnPlayer(playerid, 1, "airbreak / speedhack / flyhack cheat");
  1712.                         }
  1713.                         case CHEAT_STATUS_KICK:
  1714.                         {
  1715.                             #if defined SILENT_MODE
  1716.                                 CrashPlayer(playerid);
  1717.                             #else
  1718.                                 format(string, 128, "%s has been kicked due cheating ( airbreak / speedhack / flyhack cheat )", name);
  1719.                                 SendClientMessageToAll(0xFF0000FF, string);
  1720.                                 Kick(playerid);
  1721.                             #endif
  1722.                         }
  1723.                         case CHEAT_STATUS_BAN:
  1724.                         {
  1725.                             BanPlayer(playerid);
  1726.                             #if defined SILENT_MODE
  1727.                                 CrashPlayer(playerid);
  1728.                             #else
  1729.                                 format(string, 128, "%s has been banned due cheating ( airbreak / speedhack / flyhack cheat )", name);
  1730.                                 SendClientMessageToAll(0xFF0000FF, string);
  1731.                                 Kick(playerid);
  1732.                             #endif
  1733.                         }
  1734.                     }
  1735.                 }
  1736.                 else if(IsATrain(GetVehicleModel(vehicleid)) && distance >= 100)
  1737.                 {
  1738.                     format(string, 128, "%s trys to cheat ( train, speedhack, %.1f m/s )", name, distance);
  1739.                     LogText(string);
  1740.                     switch(DTAC_Config[speed])
  1741.                     {
  1742.                         case CHEAT_STATUS_UNDO:
  1743.                         {
  1744.                             SetPlayerPos(playerid, DTAC_Player[playerid][apPosition][0], DTAC_Player[playerid][apPosition][1], DTAC_Player[playerid][apPosition][2]);
  1745.                         }
  1746.                         case CHEAT_STATUS_WARN:
  1747.                         {
  1748.                             WarnPlayer(playerid, 1, "airbreak / speedhack / flyhack cheat");
  1749.                         }
  1750.                         case CHEAT_STATUS_KICK:
  1751.                         {
  1752.                             #if defined SILENT_MODE
  1753.                                 CrashPlayer(playerid);
  1754.                             #else
  1755.                                 format(string, 128, "%s has been kicked due cheating ( airbreak / speedhack / flyhack cheat )", name);
  1756.                                 SendClientMessageToAll(0xFF0000FF, string);
  1757.                                 Kick(playerid);
  1758.                             #endif
  1759.                         }
  1760.                         case CHEAT_STATUS_BAN:
  1761.                         {
  1762.                             BanPlayer(playerid);
  1763.                             #if defined SILENT_MODE
  1764.                                 CrashPlayer(playerid);
  1765.                             #else
  1766.                                 format(string, 128, "%s has been banned due cheating ( airbreak / speedhack / flyhack cheat )", name);
  1767.                                 SendClientMessageToAll(0xFF0000FF, string);
  1768.                                 Kick(playerid);
  1769.                             #endif
  1770.                         }
  1771.                     }
  1772.                 }
  1773.                 else if(distance >= 80)
  1774.                 {
  1775.                     format(string, 128, "%s trys to cheat ( other car, speedhack, %.1f m/s )", name, distance);
  1776.                     LogText(string);
  1777.                     switch(DTAC_Config[speed])
  1778.                     {
  1779.                         case CHEAT_STATUS_UNDO:
  1780.                         {
  1781.                             SetPlayerPos(playerid, DTAC_Player[playerid][apPosition][0], DTAC_Player[playerid][apPosition][1], DTAC_Player[playerid][apPosition][2]);
  1782.                         }
  1783.                         case CHEAT_STATUS_WARN:
  1784.                         {
  1785.                             WarnPlayer(playerid, 1, "airbreak / speedhack / flyhack cheat");
  1786.                         }
  1787.                         case CHEAT_STATUS_KICK:
  1788.                         {
  1789.                             #if defined SILENT_MODE
  1790.                                 CrashPlayer(playerid);
  1791.                             #else
  1792.                                 format(string, 128, "%s has been kicked due cheating (, airbreak / speedhack / flyhack cheat )", name);
  1793.                                 SendClientMessageToAll(0xFF0000FF, string);
  1794.                                 Kick(playerid);
  1795.                             #endif
  1796.                         }
  1797.                         case CHEAT_STATUS_BAN:
  1798.                         {
  1799.                             BanPlayer(playerid);
  1800.                             #if defined SILENT_MODE
  1801.                                 CrashPlayer(playerid);
  1802.                             #else
  1803.                                 format(string, 128, "%s has been banned due cheating ( airbreak / speedhack / flyhack cheat )", name);
  1804.                                 SendClientMessageToAll(0xFF0000FF, string);
  1805.                                 Kick(playerid);
  1806.                             #endif
  1807.                         }
  1808.                     }
  1809.                 }
  1810.             }
  1811.             else
  1812.             {
  1813.                 if(distance >= 15)
  1814.                 {
  1815.                     format(string, 128, "%s trys to cheat ( onfoot, airbreak, %.1f m/s )", name, distance);
  1816.                     LogText(string);
  1817.                     switch(DTAC_Config[speed])
  1818.                     {
  1819.                         case CHEAT_STATUS_UNDO:
  1820.                         {
  1821.                             SetPlayerPos(playerid, DTAC_Player[playerid][apPosition][0], DTAC_Player[playerid][apPosition][1], DTAC_Player[playerid][apPosition][2]);
  1822.                         }
  1823.                         case CHEAT_STATUS_WARN:
  1824.                         {
  1825.                             WarnPlayer(playerid, 1, "airbreak / speedhack / flyhack cheat");
  1826.                         }
  1827.                         case CHEAT_STATUS_KICK:
  1828.                         {
  1829.                             #if defined SILENT_MODE
  1830.                                 CrashPlayer(playerid);
  1831.                             #else
  1832.                                 format(string, 128, "%s has been kicked due cheating ( airbreak / speedhack / flyhack cheat )", name);
  1833.                                 SendClientMessageToAll(0xFF0000FF, string);
  1834.                                 Kick(playerid);
  1835.                             #endif
  1836.                         }
  1837.                         case CHEAT_STATUS_BAN:
  1838.                         {
  1839.                             BanPlayer(playerid);
  1840.                             #if defined SILENT_MODE
  1841.                                 CrashPlayer(playerid);
  1842.                             #else
  1843.                                 format(string, 128, "%s has been banned due cheating ( airbreak / speedhack / flyhack cheat )", name);
  1844.                                 SendClientMessageToAll(0xFF0000FF, string);
  1845.                                 Kick(playerid);
  1846.                             #endif
  1847.                         }
  1848.                     }
  1849.                 }
  1850.             }
  1851.         }
  1852.         /* Weapon */
  1853.         if(DTAC_Config[weapon] > CHEAT_STATUS_OFF)
  1854.         {
  1855.             #if defined SAVE_RECOURCES
  1856.                 new weaponid = GetPlayerWeapon(playerid);
  1857.                 new weaponslot = GetWeaponSlot(weaponid);
  1858.                 if(weaponslot != 0 && weaponslot != -1 && weaponid != 0 && weaponid != -1)
  1859.                 {
  1860.                     if(weaponid != DTAC_Player[playerid][apWeapons][weaponslot] && weaponid != 46)
  1861.                     {
  1862.                         format(string, 128, "%s trys to cheat ( weapon: %d )", name, weaponid);
  1863.                         LogText(string);
  1864.                         switch(DTAC_Config[weapon])
  1865.                         {
  1866.                             case CHEAT_STATUS_UNDO:
  1867.                             {
  1868.                                 _AC_ResetPlayerWeapons(playerid);
  1869.                             }
  1870.                             case CHEAT_STATUS_WARN:
  1871.                             {
  1872.                                 WarnPlayer(playerid, 1, "weapon cheat");
  1873.                                 _AC_ResetPlayerWeapons(playerid);
  1874.                             }
  1875.                             case CHEAT_STATUS_KICK:
  1876.                             {
  1877.                                 #if defined SILENT_MODE
  1878.                                     CrashPlayer(playerid);
  1879.                                 #else
  1880.                                     format(string, 128, "%s has been kicked due cheating ( weapon cheat )", name);
  1881.                                     SendClientMessageToAll(0xFF0000FF, string);
  1882.                                     Kick(playerid);
  1883.                                 #endif
  1884.                             }
  1885.                             case CHEAT_STATUS_BAN:
  1886.                             {
  1887.                                 BanPlayer(playerid);
  1888.                                 #if defined SILENT_MODE
  1889.                                     CrashPlayer(playerid);
  1890.                                 #else
  1891.                                     format(string, 128, "%s has been banned due cheating ( weapon cheat )", name);
  1892.                                     SendClientMessageToAll(0xFF0000FF, string);
  1893.                                     Kick(playerid);
  1894.                                 #endif
  1895.                             }
  1896.                         }
  1897.                     }
  1898.                 }
  1899.             #else
  1900.                 new weaponid, ammoamount;
  1901.                 for(new i = 0; i < 13; i++)
  1902.                 {
  1903.                     GetPlayerWeaponData(playerid, i, weaponid, ammoamount);
  1904.                     if(weaponid == 0 && DTAC_Player[playerid][apWeapons][i] != 0)
  1905.                     {
  1906.                         DTAC_Player[playerid][apWeapons][i] = 0;
  1907.                         DTAC_Player[playerid][apAmmo][i] = 0;
  1908.                     }
  1909.                     else if(weaponid != 0 && DTAC_Player[playerid][apWeapons][i] == 0 || weaponid != 0 && DTAC_Player[playerid][apWeapons][i] == 1)
  1910.                     {
  1911.                         if(weaponid == 46)
  1912.                         {
  1913.                             DTAC_Player[playerid][apWeapons][i] = 46;
  1914.                         }
  1915.                         else
  1916.                         {
  1917.                             format(string, 128, "%s trys to cheat ( weapon: %d )", name, weaponid);
  1918.                             LogText(string);
  1919.                             switch(DTAC_Config[weapon])
  1920.                             {
  1921.                                 case CHEAT_STATUS_UNDO:
  1922.                                 {
  1923.                                     _AC_ResetPlayerWeapons(playerid);
  1924.                                 }
  1925.                                 case CHEAT_STATUS_WARN:
  1926.                                 {
  1927.                                     WarnPlayer(playerid, 1, "weapon cheat");
  1928.                                     _AC_ResetPlayerWeapons(playerid);
  1929.                                 }
  1930.                                 case CHEAT_STATUS_KICK:
  1931.                                 {
  1932.                                     #if defined SILENT_MODE
  1933.                                         CrashPlayer(playerid);
  1934.                                     #else
  1935.                                         format(string, 128, "%s has been kicked due cheating ( weapon cheat )", name);
  1936.                                         SendClientMessageToAll(0xFF0000FF, string);
  1937.                                         Kick(playerid);
  1938.                                     #endif
  1939.                                 }
  1940.                                 case CHEAT_STATUS_BAN:
  1941.                                 {
  1942.                                     BanPlayer(playerid);
  1943.                                     #if defined SILENT_MODE
  1944.                                         CrashPlayer(playerid);
  1945.                                     #else
  1946.                                         format(string, 128, "%s has been banned due cheating ( weapon cheat )", name);
  1947.                                         SendClientMessageToAll(0xFF0000FF, string);
  1948.                                         Kick(playerid);
  1949.                                     #endif
  1950.                                 }
  1951.                             } // end switch
  1952.                         }
  1953.                     }
  1954.                 }
  1955.             #endif
  1956.         }
  1957.         /* quickturn */
  1958.         if(DTAC_Config[quickturn] > CHEAT_STATUS_OFF && IsPlayerInAnyVehicle(playerid))
  1959.         {
  1960.             new Float:anglechange = DTAC_Player[playerid][apAngle] - tmpa;
  1961.             if(anglechange < 0.0) anglechange += 360.0;
  1962.             else if(anglechange > 360.0) anglechange -= 360.0;
  1963.             if(anglechange == 180.0)
  1964.             {
  1965.                 format(string, 128, "%s trys to cheat ( fastturn: %.1f° )", name, anglechange);
  1966.                 LogText(string);
  1967.                 switch(DTAC_Config[weapon])
  1968.                 {
  1969.                     case CHEAT_STATUS_UNDO:
  1970.                     {
  1971.                         SetVehicleZAngle(GetPlayerVehicleID(playerid), DTAC_Player[playerid][apAngle]);
  1972.                     }
  1973.                     case CHEAT_STATUS_WARN:
  1974.                     {
  1975.                         WarnPlayer(playerid, 1, "weapon cheat");
  1976.                         SetVehicleZAngle(GetPlayerVehicleID(playerid), DTAC_Player[playerid][apAngle]);
  1977.                     }
  1978.                     case CHEAT_STATUS_KICK:
  1979.                     {
  1980.                         #if defined SILENT_MODE
  1981.                             CrashPlayer(playerid);
  1982.                         #else
  1983.                             format(string, 128, "%s has been kicked due cheating ( fastturn )", name);
  1984.                             SendClientMessageToAll(0xFF0000FF, string);
  1985.                             Kick(playerid);
  1986.                         #endif
  1987.                     }
  1988.                     case CHEAT_STATUS_BAN:
  1989.                     {
  1990.                         BanPlayer(playerid);
  1991.                         #if defined SILENT_MODE
  1992.                             CrashPlayer(playerid);
  1993.                         #else
  1994.                             format(string, 128, "%s has been banned due cheating ( fastturn )", name);
  1995.                             SendClientMessageToAll(0xFF0000FF, string);
  1996.                             Kick(playerid);
  1997.                         #endif
  1998.                     }
  1999.                 } // end switch
  2000.             }
  2001.         }
  2002.         /* joypad */
  2003.         if(DTAC_Config[joypad] > CHEAT_STATUS_OFF)
  2004.         {
  2005.             if((keyleft != 128 && keyleft != 0 && keyleft != -128) || (keyright != 128 && keyright != 0 && keyright != -128))
  2006.             {
  2007.                 switch(DTAC_Config[joypad])
  2008.                 {
  2009.                     case CHEAT_STATUS_UNDO:
  2010.                     {
  2011.                         SendClientMessage(playerid, 0xFF0000FF, "Please turn off your Joypad");
  2012.                     }
  2013.                     case CHEAT_STATUS_WARN:
  2014.                     {
  2015.                         WarnPlayer(playerid, 1, "joypad");
  2016.                     }
  2017.                     case CHEAT_STATUS_KICK:
  2018.                     {
  2019.                         #if defined SILENT_MODE
  2020.                             CrashPlayer(playerid);
  2021.                         #else
  2022.                             format(string, 128, "%s has been kicked due using joypad", name);
  2023.                             SendClientMessageToAll(0xFF0000FF, string);
  2024.                             Kick(playerid);
  2025.                         #endif
  2026.                     }
  2027.                     case CHEAT_STATUS_BAN:
  2028.                     {
  2029.                         BanPlayer(playerid);
  2030.                         #if defined SILENT_MODE
  2031.                             CrashPlayer(playerid);
  2032.                         #else
  2033.                             format(string, 128, "%s has been banned due using joypad", name);
  2034.                             SendClientMessageToAll(0xFF0000FF, string);
  2035.                             Kick(playerid);
  2036.                         #endif
  2037.                     }
  2038.                 }
  2039.             }
  2040.         }
  2041.         if(IsPlayerInAnyVehicle(playerid))
  2042.             GetVehicleZAngle(GetPlayerVehicleID(playerid), DTAC_Player[playerid][apAngle]);
  2043.         else
  2044.             GetPlayerFacingAngle(playerid, DTAC_Player[playerid][apAngle]);
  2045.         GetPlayerPos(playerid, DTAC_Player[playerid][apPosition][0], DTAC_Player[playerid][apPosition][1], DTAC_Player[playerid][apPosition][2]);
  2046.     }
  2047.     return true;
  2048. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement