Guest User

Fix SA-MP bugs

a guest
Jul 18th, 2012
729
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 7.17 KB | None | 0 0
  1. /*
  2.     Данный FS исправляет/запрещает использовать баги SA-MP:
  3.     Данная версия скрипта включает в себя:
  4.     BannyHop fix
  5.     SpawnMoney fix
  6.     DialogCrush fix
  7.     DialogColor fix
  8.     +C fix
  9.     Slide fix
  10.     Sprint fix
  11.     Knife Bug fix
  12.     Knife Kill fix
  13.    
  14.     Автор FS: Kamox
  15.     Skype: k.amox
  16.     Mail: [email protected]
  17.    
  18.     Дата: 17.07.2012г
  19. */
  20.  
  21. #include <a_samp>
  22.  
  23. #define FREEZE_TIME 3000
  24.  
  25. enum fixInfo
  26. {
  27.     bool:fixBannyHop,
  28.     bool:fixSpawnMoney,
  29.     bool:fixDialogCrush,
  30.     bool:fixDialogColor,
  31.     bool:fixCBug,
  32.     bool:fixSlideBug,
  33.     bool:fixSprintBug,
  34.     bool:fixKnifeBug,
  35.     bool:fixKnifeKill
  36. }
  37.  
  38. new FixInfo[fixInfo] =
  39. {
  40.     true, //BannyHop fix (Бег с прыжками)
  41.     true, //SpawnMoney fix (При спавне снимает $100)
  42.     true, //DialogCrush fix (Можно положить сервер вводя в диалоговое окно символ '%')
  43.     true, //DialogColor fix (Можно менять цвет текста встявляя коды цветов "{33CCFF}")
  44.     true, //C Bug fix (Баг со стрельбой с дигла)
  45.     true, //Slide fix (Езда с диглом)
  46.     true, //Sprint Bug fix (Быстрый бег многократным нажатием пробела)
  47.     true, //KnifeBug fix (Баг с ножом, когда у одного игрока видно, что другой игрок лежит)
  48.     true  //KnifeKill fix (Этим багом можно убить игрока ножом на ходу
  49. };
  50.  
  51. public OnFilterScriptInit()
  52. {
  53.     print("\n--------------------------------------");
  54.     print(" Fix script by Kamox");
  55.     print("--------------------------------------\n");
  56.     return 1;
  57. }
  58.  
  59. public OnPlayerConnect(playerid)
  60. {
  61.     SetPVarInt(playerid, "BHTime", -1);
  62.     SetPVarInt(playerid, "MoneyTime", -1);
  63.     SetPVarInt(playerid, "CBugTime", -1);
  64.     SetPVarInt(playerid, "UnfreezeTime", -1);
  65.     SetPVarInt(playerid, "SlideTime", -1);
  66.     SetPVarInt(playerid, "SprintCount", -1);
  67.     SetPVarInt(playerid, "SprintTime", -1);
  68.     SetPVarInt(playerid, "KnifeTime", -1);
  69.     SetPVarInt(playerid, "KnifePlayer", INVALID_PLAYER_ID);
  70.     return 1;
  71. }
  72.  
  73. public OnPlayerSpawn(playerid)
  74. {
  75.     if(FixInfo[fixSpawnMoney] && GetPVarInt(playerid, "MoneyTime") != -1)
  76.     {
  77.         if(GetTickCount() > GetPVarInt(playerid, "MoneyTime"))
  78.         {
  79.             GivePlayerMoney(playerid, 100);
  80.         }
  81.     }
  82.     SetPVarInt(playerid, "MoneyTime", -1);
  83.     return 1;
  84. }
  85.  
  86. public OnPlayerDeath(playerid, killerid, reason)
  87. {
  88.     if(FixInfo[fixSpawnMoney])
  89.     {
  90.         SetPVarInt(playerid, "MoneyTime", GetTickCount() + 2000);
  91.     }
  92.     return 1;
  93. }
  94.  
  95. stock BugFreezePlayer(playerid, time)
  96. {
  97.     SetPVarInt(playerid, "UnfreezeTime", time);
  98.     TogglePlayerControllable(playerid, 0);
  99.     return true;
  100. }
  101.  
  102. stock GetPlayerSpeed(playerid)
  103. {
  104.     new Float:X, Float:Y, Float:Z;
  105.     GetPlayerVelocity(playerid, X, Y, Z);
  106.     return floatround( floatsqroot( X * X + Y * Y + Z * Z ) * 170.0 );
  107. }
  108.  
  109. stock CheckDialogColor(text[], first, end)
  110. {
  111.     if(text[first] != '{' || text[end] != '}') return false;
  112.     for(new i = first; i <= end; i ++)
  113.     {
  114.         if(text[i] >= '0' && text[i] <= '9') continue;
  115.         if(text[i] >= 'a' && text[i] <= 'f') continue;
  116.         if(text[i] >= 'A' && text[i] <= 'F') continue;
  117.         return false;
  118.     }
  119.     strdel(text, first, end + 1);
  120.     return true;
  121. }
  122.  
  123. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  124. {
  125.     if(FixInfo[fixBannyHop])
  126.     {
  127.         new tick = GetTickCount();
  128.         if(oldkeys & KEY_SPRINT)
  129.         {
  130.             SetPVarInt(playerid, "BHTime", tick + 250);
  131.         }
  132.         if(newkeys & KEY_JUMP)
  133.         {
  134.             if(tick < GetPVarInt(playerid, "BHTime"))
  135.             {
  136.                 ClearAnimations(playerid);
  137.                 BugFreezePlayer(playerid, tick + FREEZE_TIME);
  138.             }
  139.             SetPVarInt(playerid, "BHTime", -1);
  140.         }
  141.     }
  142.     if(FixInfo[fixKnifeBug] || FixInfo[fixKnifeKill])
  143.     {
  144.         if(newkeys & KEY_FIRE && oldkeys & 128)
  145.         {
  146.             if(GetPlayerWeapon(playerid) == 4)
  147.             {
  148.                 if(GetPlayerAnimationIndex(playerid) == 747)
  149.                 {
  150.                     new knifeid = GetPlayerTargetPlayer(playerid);
  151.                     if(knifeid != INVALID_PLAYER_ID)
  152.                     {
  153.                         if(FixInfo[fixKnifeKill] && GetPlayerSpeed(playerid) > 10)
  154.                         {
  155.                             ClearAnimations(playerid);
  156.                             ClearAnimations(knifeid);
  157.                         }
  158.                         else if(FixInfo[fixKnifeBug])
  159.                         {
  160.                             new time = GetPlayerPing(playerid) + GetPlayerPing(knifeid);
  161.                             SetPVarInt(knifeid, "KnifePlayer", playerid);
  162.                             SetPVarInt(knifeid, "KnifeTime", GetTickCount() + time);
  163.                         }
  164.                     }
  165.                 }
  166.             }
  167.         }
  168.     }
  169.     if(FixInfo[fixSprintBug])
  170.     {
  171.         if(newkeys & KEY_SPRINT)
  172.         {
  173.             new tick = GetTickCount();
  174.             if(GetPVarInt(playerid, "SprintTime") == -1 || tick < GetPVarInt(playerid, "SprintTime"))
  175.             {
  176.                 if(GetPlayerSpeed(playerid) > 15)
  177.                 {
  178.                     if(GetPVarInt(playerid, "SprintCount") >= 5)
  179.                     {
  180.                         SetPVarInt(playerid, "SprintCount", -1);
  181.                         SetPVarInt(playerid, "SprintTime", -1);
  182.                         BugFreezePlayer(playerid, tick + FREEZE_TIME);
  183.                     }
  184.                     else
  185.                     {
  186.                         SetPVarInt(playerid, "SprintCount", GetPVarInt(playerid, "SprintCount") + 1);
  187.                         SetPVarInt(playerid, "SprintTime", tick + 200);
  188.                     }
  189.                 }
  190.             }
  191.             else if(tick - GetPVarInt(playerid, "SprintTime") > 1000)
  192.             {
  193.                 SetPVarInt(playerid, "SprintCount", -1);
  194.                 SetPVarInt(playerid, "SprintTime", -1);
  195.             }
  196.         }
  197.     }
  198.     if(FixInfo[fixCBug])
  199.     {
  200.         if(GetPlayerWeapon(playerid) > 21)
  201.         {
  202.             new tick = GetTickCount();
  203.             if(oldkeys & KEY_FIRE) SetPVarInt(playerid, "CBugTime", tick + 500);
  204.             if(newkeys & KEY_CROUCH)
  205.             {
  206.                 if(tick < GetPVarInt(playerid, "CBugTime"))
  207.                 {
  208.                     SetPlayerArmedWeapon(playerid, 0);
  209.                     BugFreezePlayer(playerid, tick + FREEZE_TIME);
  210.                 }
  211.                 SetPVarInt(playerid, "CBugTime", -1);
  212.             }
  213.         }
  214.     }
  215.     if(FixInfo[fixSlideBug])
  216.     {
  217.         new tick = GetTickCount();
  218.         new FIRE_WEAPON = GetPlayerWeapon(playerid) > 21;
  219.         if(oldkeys & KEY_SPRINT && FIRE_WEAPON)
  220.         {
  221.             new keys, ud, lr;
  222.             GetPlayerKeys(playerid, keys, ud, lr);
  223.             if(ud != 0 || lr != 0)
  224.             {
  225.                 SetPVarInt(playerid, "SlideTime", tick + 500);
  226.             }
  227.         }
  228.         if( (newkeys & KEY_FIRE || newkeys & 128) && FIRE_WEAPON )
  229.         {
  230.             if(tick < GetPVarInt(playerid, "SlideTime"))
  231.             {
  232.                 SetPlayerArmedWeapon(playerid, 0);
  233.                 BugFreezePlayer(playerid, tick + FREEZE_TIME);
  234.             }
  235.             SetPVarInt(playerid, "SlideTime", -1);
  236.         }
  237.     }
  238.     return 1;
  239. }
  240.  
  241. public OnPlayerUpdate(playerid)
  242. {
  243.     if(GetPVarInt(playerid, "UnfreezeTime") != -1)
  244.     {
  245.         if(GetTickCount() > GetPVarInt(playerid, "UnfreezeTime"))
  246.         {
  247.             SetPVarInt(playerid, "UnfreezeTime", -1);
  248.             TogglePlayerControllable(playerid, 1);
  249.         }
  250.     }
  251.     if(GetPVarInt(playerid, "KnifeTime") != -1)
  252.     {
  253.         if(GetPlayerAnimationIndex(playerid) == 745)
  254.         {
  255.             SetPVarInt(playerid, "KnifeTime", -1);
  256.             SetPVarInt(playerid, "KnifePlayer", INVALID_PLAYER_ID);
  257.         }
  258.         else if(GetTickCount() > GetPVarInt(playerid, "KnifeTime"))
  259.         {
  260.             SetPVarInt(playerid, "KnifeTime", -1);
  261.             SetPVarInt(playerid, "KnifePlayer", INVALID_PLAYER_ID);
  262.             ClearAnimations(playerid);
  263.         }
  264.     }
  265.     return 1;
  266. }
  267.  
  268. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  269. {
  270.     for(new i, s = strlen(inputtext); i < s; i ++)
  271.     {
  272.         if(FixInfo[fixDialogCrush] && inputtext[i] == '%') inputtext[i] = '#';
  273.         if(FixInfo[fixDialogColor] && inputtext[i] == '{') CheckDialogColor(inputtext, i, i + 7);
  274.     }
  275.     return 1;
  276. }
Advertisement
Add Comment
Please, Sign In to add comment