BDGAME

Easy System By OnPlayerTakeDamage HeadShot

May 26th, 2014
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.50 KB | None | 0 0
  1. /*
  2.     CREDITS: OTACON
  3.     I'm Otacon ¬¬
  4. */
  5. #include <a_samp>
  6. #include <zcmd>
  7. #include <sscanf2>
  8.  
  9. #define ArmaHeadShot (34) //Sniper Rifle
  10. #define COLOR_PURPLE 0xC2A2DAAA
  11. new bool:ActivarHeadShot[MAX_PLAYERS]=false;
  12. new bool:PlayerHeadShot[MAX_PLAYERS]=false;
  13.  
  14. COMMAND:headshot(playerid, params[]) {
  15.     new string[128], name[MAX_PLAYER_NAME+1];
  16.     GetPlayerName(playerid, name, sizeof(name));
  17.     if(GetPlayerWeapon(issuerid) != ArmaHeadShot) return SendClientMessage(playerid, -1, "[!] You do not have the gun headshot system!");
  18.     switch(ActivarHeadShot[playerid]) {
  19.         case false: {
  20.             ActivarHeadShot[playerid] = true;
  21.             format(string, sizeof(string), "* %s system activate headshot.", name);
  22.             ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  23.         }
  24.         case true: {
  25.             ActivarHeadShot[playerid] = false;
  26.             format(string, sizeof(string), "* %s system disables headshot.", name);
  27.             ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  28.         }
  29.     }
  30.     return 1;
  31. }
  32.  
  33. public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
  34. {
  35.     if(issuerid != INVALID_PLAYER_ID) {
  36.         if(ActivarHeadShot[issuerid] == true && GetPlayerWeapon(issuerid) == ArmaHeadShot && PlayerHeadShot[playerid] == false) {
  37.             SetPlayerHealth(playerid, (0.0));
  38.             PlayerHeadShot[playerid] = true;
  39.             GameTextForPlayer(playerid, "realized HeadShot.", 3000, 1);
  40.         }
  41.     }
  42.     return 1;
  43. }
  44.  
  45. public OnPlayerDeath(playerid, killerid, reason)
  46. {
  47.     if(PlayerHeadShot[playerid] == true) {
  48.         PlayerHeadShot[playerid] = false;
  49.     }
  50.     return 1;
  51. }
  52.  
  53. forward ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5);
  54. public ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5)
  55. {
  56.     if(IsPlayerConnected(playerid))
  57.     {
  58.         new Float:posx, Float:posy, Float:posz;
  59.         new Float:oldposx, Float:oldposy, Float:oldposz;
  60.         new Float:tempposx, Float:tempposy, Float:tempposz;
  61.         GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  62.         for(new i = 0; i < MAX_PLAYERS; i++)
  63.         {
  64.             if(IsPlayerConnected(i) && (GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i)))
  65.             {
  66.                 GetPlayerPos(i, posx, posy, posz);
  67.                 tempposx = (oldposx -posx);
  68.                 tempposy = (oldposy -posy);
  69.                 tempposz = (oldposz -posz);
  70.                 if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16))) // If the player is within 16 meters
  71.                 {
  72.                     SendClientMessage(i, col1, string);
  73.                 }
  74.                 else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8))) // within 8 meters
  75.                 {
  76.                     SendClientMessage(i, col2, string);
  77.                 }
  78.                 else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4))) //4 meters
  79.                 {
  80.                     SendClientMessage(i, col3, string);
  81.                 }
  82.                 else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2))) //2 meters
  83.                 {
  84.                     SendClientMessage(i, col4, string);
  85.                 }
  86.                 else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi))) //1 meter
  87.                 {
  88.                     SendClientMessage(i, col5, string);
  89.                 }
  90.             }
  91.             else
  92.             {
  93.                 SendClientMessage(i, col1, string);
  94.             }
  95.         }
  96.     }
  97.     return 1;
  98. }
  99. /*
  100.     CREDITS: OTACON
  101.     I'm Otacon ¬¬
  102. */
Advertisement
Add Comment
Please, Sign In to add comment