Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.19 KB | None | 0 0
  1. #include <a_samp>
  2. #include <ForEachPlayer>
  3. #include <GDFPTL>
  4.  
  5. #define PRESSED(%0) \
  6.     (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
  7.  
  8. #define RELEASED(%0) \
  9.     (((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
  10.  
  11. static ShootingWithSniper[MAX_PLAYERS];
  12. static LastSniperShot[MAX_PLAYERS];
  13.  
  14. public OnFilterScriptInit()
  15. {
  16.     for(new i = 0; i < MAX_PLAYERS; i++)
  17.         if(IsPlayerConnected(i) && !IsPlayerNPC(i))
  18.             AddPlayer(i);
  19.     return 1;
  20. }
  21.  
  22. public OnPlayerConnect(playerid)
  23. {
  24.     ShootingWithSniper[playerid] = false;
  25.     LastSniperShot[playerid] = GetTickCount();
  26.     return 1;
  27. }
  28.  
  29. public OnPlayerStateChange(playerid, newstate, oldstate)
  30. {
  31.     ShootingWithSniper[playerid] = false;
  32.     return 1;
  33. }
  34.  
  35. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  36. {
  37.     if(!IsPlayerNPC(playerid) && PRESSED(KEY_FIRE) && GetPlayerState(playerid) == PLAYER_STATE_ONFOOT && GetPlayerWeapon(playerid) == 34)
  38.         ShootingWithSniper[playerid] = true;
  39.     else if(RELEASED(KEY_FIRE))
  40.         ShootingWithSniper[playerid] = false;
  41.     return 1;
  42. }
  43.  
  44. public OnPlayerUpdate(playerid)
  45. {
  46.     new t = GetTickCount();
  47.     if(ShootingWithSniper[playerid] && (t - LastSniperShot[playerid]) > 800)
  48.     {
  49.         new
  50.             worldid = GetPlayerVirtualWorld(playerid),
  51.             Float:x1,
  52.             Float:y1,
  53.             Float:z1,
  54.             Float:x2,
  55.             Float:y2,
  56.             Float:z2,
  57.             Float:distance,
  58.             Float:cvx,
  59.             Float:cvy,
  60.             Float:cvz,
  61.             Float:cx,
  62.             Float:cy,
  63.             Float:cz;
  64.  
  65.         GetPlayerCameraPos(playerid, cx, cy, cz);
  66.         GetPlayerCameraFrontVector(playerid, cvx, cvy, cvz);
  67.         GetPlayerPos(playerid, x1, y1, z1);
  68.         LastSniperShot[playerid] = t;
  69.  
  70.         ForEachPlayer(i)
  71.         {
  72.             if(i != playerid && GetPlayerVirtualWorld(i) == worldid && IsPlayerInRangeOfPoint(i, 150.0, x1, y1, z1))
  73.             {
  74.                 GetPlayerPos(i, x2, y2, z2);
  75.                 z2 = z2 + 0.675;
  76.                 GetDistanceFromPointToLine(distance, cvx, cvy, cvz, cx, cy, cz, x2, y2, z2);
  77.                 if(distance < 0.25)
  78.                 {
  79.                     SetPlayerHealth(i, 0.0);
  80.                     SetPlayerArmour(i, 0.0);
  81.                     GameTextForPlayer(playerid, "~y~BOOM!!!~n~~r~Headshot!", 2000, 4);
  82.                     GameTextForPlayer(i, "~y~BOOM!!!~n~~r~Headshot!", 2000, 4);
  83.                     return 1;
  84.                 }
  85.             }
  86.         }
  87.     }
  88.     return 1;
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement