Guest User

Panoulis

a guest
Sep 9th, 2010
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.11 KB | None | 0 0
  1.  
  2. /*Headshot system by Johnson_boy
  3.  
  4. Using this script you can enable "Boom Headshots", which means an instant kill when shooting to head with sniper.
  5. This script has been created by Johnson_boy.
  6. You are allowed to use this on your server, and modefy it to fit your needs.
  7. You are NOT allowed to remove the credits and share as yours.
  8. If you use this on your server, please place any kind of credits on your gamemode about this script.
  9. It shouldn't be too much for this.
  10. */
  11.  
  12. #include <a_samp>
  13.  
  14. #define SERVER_MAX_PLAYERS 20 //Change to max players of your server
  15.  
  16. //define SHOWPATH if you want the path of bullet to be shown
  17. #define SHOWPATH
  18.  
  19. new RecentlyShot[SERVER_MAX_PLAYERS];
  20.  
  21. public OnFilterScriptInit()
  22. {
  23.     print("\n\n__________________________________________________________________");
  24.     print(" Boom Headshot System by Johnson_boy loaded!");
  25.     print(" Copyright Johnson_boy 2010");
  26.     print("__________________________________________________________________\n\n");
  27.     return 1;
  28. }
  29.  
  30. public OnFilterScriptExit()
  31. {
  32.     print("\n\n__________________________________________________________________");
  33.     print(" Boom Headshot System by Johnson_boy unloaded!");
  34.     print(" Copyright Johnson_boy 2010");
  35.     print("__________________________________________________________________\n\n");
  36.     return 1;
  37. }
  38.  
  39. public OnPlayerConnect(playerid) {
  40.     SendClientMessage(playerid, 0xFFFFFFFF, "This server is using Johnson_boy's Headshot script v2b");
  41.     return 1;
  42. }
  43.  
  44. public OnPlayerSpawn(playerid)
  45. {
  46.     GivePlayerWeapon(playerid, 34, 15);
  47.     RecentlyShot[playerid] = 0;
  48.     return 1;
  49. }
  50.  
  51. public OnPlayerUpdate(playerid)
  52. {
  53.  
  54.     return 1;
  55. }
  56.  
  57. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  58. {
  59.     if(newkeys & KEY_FIRE && newkeys & KEY_HANDBRAKE) {
  60.         if(RecentlyShot[playerid] == 0) {
  61.             RecentlyShot[playerid] = 1;
  62.             SetTimerEx("AntiSpam", 1000, false, "d", playerid);
  63.             if(GetPlayerWeapon(playerid) == 34) {
  64.                 new Float:blahx, Float:blahy, Float:blahz;
  65.                 HeadshotCheck(playerid, blahx, blahy, blahz);
  66.                 return 1;
  67.             }
  68.             return 1;
  69.         }
  70.         return 1;
  71.     }
  72.     return 1;
  73. }
  74.  
  75. forward AntiSpam(playerid);
  76. public AntiSpam(playerid) {
  77.     RecentlyShot[playerid] = 0;
  78.     return 1;
  79. }
  80.  
  81. stock PlayerName(playerid) {
  82.     new name[24];
  83.     GetPlayerName(playerid, name, sizeof(name));
  84.     return name;
  85. }
  86.  
  87. stock HeadshotCheck(playerid, &Float:x, &Float:y, &Float:z)
  88. {
  89.     new Float:fx,Float:fy,Float:fz;
  90.     GetPlayerCameraFrontVector(playerid, fx, fy, fz);
  91.  
  92.     new Float:cx,Float:cy,Float:cz;
  93.     GetPlayerCameraPos(playerid, cx, cy, cz);
  94.  
  95.     for(new Float:i = 0.0; i < 50; i = i + 0.5)
  96.     {
  97.         x = fx * i + cx;
  98.         y = fy * i + cy;
  99.         z = fz * i + cz;
  100.  
  101.         #if defined SHOWPATH
  102.         CreatePickup(1239, 4, x, y, z, -1);
  103.         #endif
  104.  
  105.         for(new player = 0; player < SERVER_MAX_PLAYERS; player ++)
  106.         {
  107.             if(IsPlayerConnected(playerid))
  108.             {
  109.                 if(player != playerid)
  110.                 {
  111.                     if(GetPlayerSpecialAction(player) == SPECIAL_ACTION_DUCK) //CROUCHING
  112.                     {
  113.                         if(IsPlayerInRangeOfPoint(player, 0.3, x, y, z))
  114.                         {
  115.                             new string[128];
  116.                             format(string, sizeof(string), "Headshot: %s was shot to head by %s", PlayerName(player), PlayerName(playerid));
  117.                             SendClientMessageToAll(0xFF9900AA, string);
  118.  
  119.                             GameTextForPlayer(playerid, "~r~HEADSHOT!", 2000, 6);
  120.                             GameTextForPlayer(player, "~r~HEADSHOT!", 2000, 6);
  121.  
  122.                             SetPlayerHealth(player, 0.0);
  123.                             CallRemoteFunction("OnPlayerDeath", "ddd", player, playerid, 34);
  124.                         }
  125.                     }
  126.                     else //NOT CROUCHING
  127.                     {
  128.                         if(IsPlayerInRangeOfPoint(player, 0.3, x, y, z - 0.7))
  129.                         {
  130.                             new string[128];
  131.                             format(string, sizeof(string), "Headshot: %s was shot to head by %s", PlayerName(player), PlayerName(playerid));
  132.                             SendClientMessageToAll(0xFF9900AA, string);
  133.  
  134.                             GameTextForPlayer(playerid, "~r~HEADSHOT!", 2000, 6);
  135.                             GameTextForPlayer(player, "~r~HEADSHOT!", 2000, 6);
  136.  
  137.                             SetPlayerHealth(player, 0.0);
  138.                             CallRemoteFunction("OnPlayerDeath", "ddd", player, playerid, 34);
  139.                         }
  140.                     }
  141.                 }
  142.             }
  143.         }
  144.     }
  145.     return 1;
  146. }
Advertisement
Add Comment
Please, Sign In to add comment