Advertisement
DraKiNs

[FS] Anti Bug Cars SA:MP

Jun 26th, 2011
503
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.21 KB | None | 0 0
  1. #include <a_samp>
  2. #define HOLDING(%0) \
  3.     ((newkeys & (%0)) == (%0))
  4. #define RELEASED(%0) \
  5.     (((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
  6. #define PRESSED(%0) \
  7.     (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
  8.  
  9. #include <a_npc>
  10.  
  11. public OnGameModeInit()
  12. {
  13.     ConnectNPC("BotCars","BugCars");
  14. }
  15. public OnPlayerSpawn(playerid)
  16. {
  17.     SetBotInPos("BotCars",0.0,0.0,0.0);
  18. }
  19. stock SetBotInPos(botname[],Float:x,Float:y,Float:z)
  20. {
  21.     for(new id = 0; id < 500 ; id ++)
  22.     {
  23.         if(IsPlayerNPC(id))
  24.         {
  25.             new playername[24];
  26.             GetPlayerName(id,playername,24);
  27.             if(!strcmp(playername,botname,true))
  28.                 SetPlayerPos(id,x,y,z);
  29.         }
  30.     }
  31. }
  32. stock PutBotInVehicle(botname[],vehicleid)
  33. {
  34.     for(new id = 0; id < 500 ; id ++)
  35.     {
  36.         if(IsPlayerNPC(id))
  37.         {
  38.             new playername[24];
  39.             GetPlayerName(id,playername,24);
  40.             if(!strcmp(playername,botname,true))
  41.                 PutPlayerInVehicle(id, vehicleid, 0);
  42.         }
  43.     }
  44. }
  45.  
  46.  
  47. stock GetCarAimingPlayer(playerid)
  48. {
  49.         new Float:X1, Float:Y1, Float:Z1, Float:X2, Float:Y2, Float:Z2,Float:A;
  50.         GetPlayerPos(playerid, X1, Y1, Z1);
  51.         GetPlayerFacingAngle(playerid, A);
  52.         for(new v = 0; v < 8000; v++)
  53.         {
  54.             GetVehiclePos(v, X2, Y2, Z2);
  55.             new Float:Raius = floatsqroot(floatpower(floatabs(X1-X2), 2) + floatpower(floatabs(Y1-Y2), 2));
  56.             if(Raius < 100)
  57.             {
  58.                 X1 += (Raius * floatsin(-A, degrees));
  59.                 Y1 += (Raius * floatcos(-A, degrees));
  60.                 Raius = floatsqroot(floatpower(floatabs(X1-X2), 2) + floatpower(floatabs(Y1-Y2), 2));
  61.                 if(Raius < 0.5) return v;
  62.             }
  63.         }
  64.         return -1;
  65. }
  66.  
  67. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  68. {
  69.     new Float:HealthCar,bool:PlayerAtirou;
  70.     if(newkeys & KEY_FIRE || oldkeys & KEY_FIRE && PlayerAtirou == false)
  71.     {
  72.         new mirando = GetCarAimingPlayer(playerid);
  73.         if(mirando != -1)
  74.         {
  75.             PutBotInVehicle("BotCars",mirando);
  76.             GetVehicleHealth(mirando,HealthCar);
  77.             SetVehicleHealth(mirando,HealthCar-13);
  78.             PlayerAtirou = true;
  79.         }
  80.         if(PlayerAtirou == true)
  81.         {
  82.             SetBotInPos("BotCars",0.0,0.0,0.0);
  83.             PlayerAtirou = false;
  84.         }
  85.     }
  86.     return 1;
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement