Advertisement
MX_Master

Untitled

Aug 31st, 2011
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.66 KB | None | 0 0
  1. #define pwcKickForWeaponCheat   1   // кикать ли за любой чит оружия?
  2. #define pwcCheatReportToCheater 1   // сообщать ли читеру о его чите?
  3. #define pwcTempWeaponId         0   // проверочное оружие (ИД)
  4.  
  5. enum playerWeaponCheck_enum
  6. {
  7.     pwcStarted,         // флаг - работает ли проверка оружия для игрока прямо сейчас
  8.     pwcWeaponId,        // ИД оружия, который был у игрока до начала проверки
  9.     pwcCheatsDetected,  // кол-во обнаруженных попыток чита на оружие для игрока
  10.     pwcDelayTimer       // таймер отложенной проверки
  11. }
  12.  
  13. stock playerWeaponCheck[MAX_PLAYERS][playerWeaponCheck_enum];
  14.  
  15.  
  16.  
  17.  
  18. // запускает проверку на чит оружия для указанного игрока
  19. forward startPlayerWeaponCheck ( playerid );
  20. public startPlayerWeaponCheck ( playerid )
  21. {
  22.     if ( ! IsPlayerConnected(playerid) ) return 0;
  23.  
  24.     playerWeaponCheck[playerid][pwcWeaponId] = GetPlayerWeapon(playerid);
  25.  
  26.     // если сейчас у игрока проверочное оружие, то отложим проверку на 1 сек
  27.     if ( playerWeaponCheck[playerid][pwcWeaponId] == pwcTempWeaponId )
  28.     {
  29.         playerWeaponCheck[playerid][pwcDelayTimer] = SetTimerEx( "startPlayerWeaponCheck", 1000, 1, "i", playerid );
  30.         return 0;
  31.     }
  32.  
  33.     playerWeaponCheck[playerid][pwcStarted] = 1;
  34.     SetPlayerArmedWeapon( playerid, pwcTempWeaponId );
  35.  
  36.     return 1;
  37. }
  38.  
  39. // останавливает проверку на чит оружия
  40. stock stopWeaponCheck ( playerid )
  41. {
  42.     playerWeaponCheck[playerid][pwcStarted] =           0;
  43.     playerWeaponCheck[playerid][pwcCheatsDetected] =    0;
  44.  
  45.     if ( playerWeaponCheck[playerid][pwcDelayTimer] )
  46.         KillTimer(playerWeaponCheck[playerid][pwcDelayTimer]);
  47. }
  48.  
  49.  
  50.  
  51.  
  52. public OnPlayerConnect ( playerid )
  53. {
  54.     stopWeaponCheck(playerid);
  55.     return 1;
  56. }
  57.  
  58. public OnPlayerDisconnect ( playerid, reason )
  59. {
  60.     stopWeaponCheck(playerid);
  61.     return 1;
  62. }
  63.  
  64. public OnPlayerUpdate ( playerid )
  65. {
  66.     // если для игрока запущена проверка чита на оружие
  67.     if ( playerWeaponCheck[playerid][pwcStarted] )
  68.     {
  69.         // узнаем текущее оружие
  70.         new curWeaponId = GetPlayerWeapon(playerid);
  71.  
  72.         // если текущее оружие изменилось
  73.         if ( curWeaponId != playerWeaponCheck[playerid][pwcWeaponId] )
  74.         {
  75.             playerWeaponCheck[playerid][pwcStarted] = 0; // выключим проверку
  76.             SetPlayerArmedWeapon( playerid, playerWeaponCheck[playerid][pwcWeaponId] ); // вернем прежнее оружие
  77.  
  78.             // если текущее оружие оказалось не таким, каким выставил его сервер
  79.             if ( curWeaponId != pwcTempWeaponId )
  80.             {
  81.                 playerWeaponCheck[playerid][pwcCheatsDetected]++; // кол-во читов +1
  82.  
  83.                 #if defined pwcCheatReportToCheater && pwcCheatReportToCheater == 1
  84.                     // инфо самому игроку
  85.                     SendClientMessage( playerid, 0xFF0000FF, "Server detected you are using weapon cheats!" );
  86.                 #endif
  87.  
  88.                 #if defined pwcKickForWeaponCheat && pwcKickForWeaponCheat == 1
  89.                     // наказать, если нужно
  90.                     Kick(playerid);
  91.                 #endif
  92.             }
  93.         }
  94.     }
  95.  
  96.     return 1;
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement