Guest User

Simple Chicken Running Detector

a guest
May 19th, 2013
373
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.46 KB | None | 0 0
  1. /*
  2.  
  3.     Simple Chicken Run Detector - Edgar
  4.  
  5. */
  6.  
  7. #include <a_samp>
  8. #include <foreach>
  9.  
  10. #define FILTERSCRIPT
  11. #define COLOR_LIGHTRED 0xFF6347FF
  12.  
  13. public OnFilterScriptInit()
  14. {
  15.     print("\n--------------------------------------");
  16.     print(" Chicken Run Detector Loaded-Edgar");
  17.     print("--------------------------------------\n");
  18.     return 1;
  19. }
  20.  
  21. public OnFilterScriptExit()
  22. {
  23.     print("\n--------------------------------------");
  24.     print(" Chicken Run Detector Unloaded-Edgar");
  25.     print("--------------------------------------\n");
  26.     return 1;
  27. }
  28.  
  29. public OnPlayerConnect(playerid)
  30. {
  31.     SetTimerEx("ChickenRun", 1000, true, "i", playerid);
  32.     return 1;
  33. }
  34.  
  35. forward ChickenRun(playerid);
  36. public ChickenRun(playerid)
  37. {
  38.     foreach(Player, i)
  39.     {
  40.         if(IsPlayerNearPlayer(i, playerid, 10))
  41.         {
  42.             new Float:Velocity[3];
  43.             GetPlayerVelocity(i, Velocity[0], Velocity[1], Velocity[2]);
  44.             if(Velocity[0] > 10 && Velocity[1] > 10)
  45.             {
  46.                 TogglePlayerControllable(i, false);
  47.                 SetTimerEx("Unfreeze", 1000, false, "i", i);
  48.                 GameTextForPlayer(playerid, "Stop Chicken Running!", 3000, 1);
  49.             }
  50.         }
  51.     }
  52. }
  53.  
  54. forward Unfreeze(playerid);
  55. public Unfreeze(playerid)
  56. {
  57.     TogglePlayerControllable(playerid, true);
  58. }
  59.  
  60. stock IsPlayerNearPlayer(playerid, targetid, Float:radius)
  61. {
  62.     new Float:x, Float:y, Float:z;
  63.     GetPlayerPos(targetid, x, y, z);
  64.     if(IsPlayerInRangeOfPoint(playerid, radius ,x, y, z))
  65.     {
  66.         return 1;
  67.     }
  68.     return 0;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment