Advertisement
DraKiNs

[INC] OnPlayerShootPlayer v1

Sep 4th, 2011
965
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.38 KB | None | 0 0
  1. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. //             OnPlayerShootPlayer
  4. //  Author: Bruno da Silva (thanks Allan Jader and Robson)
  5. //       www.ips-team.blogspot.com
  6. //
  7. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  8.  
  9. new
  10. Float:primeHealth[MAX_PLAYERS],
  11. Float:ultimaDiferenca[MAX_PLAYERS];
  12.  
  13. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  14. {
  15.     static animacaoAtual[32];
  16.     GetAnimationName(GetPlayerAnimationIndex(playerid), animacaoAtual, 32, animacaoAtual, 32);
  17.  
  18.     if(strfind(animacaoAtual, "GUN_STAND", true) != -1 || strfind(animacaoAtual, "COLT45_FIRE", true) != -1) {
  19.         static
  20.             Float:xPos,
  21.             Float:yPos,
  22.             Float:zPos,
  23.             Float:distancia,
  24.             Float:aPos;
  25.  
  26.         new
  27.             Float:xPlayer,
  28.             Float:yPlayer,
  29.             Float:zPlayer,
  30.             Float:diferenceHealth;
  31.  
  32.         GetPlayerPos(playerid, xPos, yPos, zPos);
  33.         GetPlayerFacingAngle(playerid, aPos);
  34.  
  35.         for(new i = 0; i != MAX_PLAYERS; ++i) if(IsPlayerInRangeOfPoint(i, 200.0, xPos, yPos, zPos) &&  i != playerid) {
  36.             GetPlayerPos(i, xPlayer, yPlayer, zPlayer);
  37.  
  38.             distancia = floatsqroot(floatpower(floatabs(xPos-xPlayer), 2) + floatpower(floatabs(yPos-yPlayer), 2));
  39.             if(distancia <  100.0) {
  40.                 xPos += (distancia * floatsin(-aPos, degrees)),
  41.                     yPos += (distancia * floatcos(-aPos, degrees));
  42.  
  43.                 distancia = floatsqroot(floatpower(floatabs(xPos-xPos), 2) + floatpower(floatabs(yPos-yPlayer), 2));
  44.  
  45.                 switch(GetPlayerWeapon(playerid)) {
  46.                     case 34:distancia -= 2.0;
  47.                     case 31:distancia -= 0.5;
  48.                     case 30:distancia -= 0.3;
  49.                     case 33:distancia -= 1.3;
  50.                 }
  51.  
  52.                 if(distancia < 1.9) {
  53.                     GetPlayerHealth(i, diferenceHealth);
  54.                     if(diferenceHealth < primeHealth[i] && ultimaDiferenca[i] != primeHealth[i] - diferenceHealth) {
  55.                         ultimaDiferenca[i] = primeHealth[i] - diferenceHealth;
  56.                         CallLocalFunction("OnPlayerShootPlayer", "iifd", playerid, i, ultimaDiferenca[i], GetPlayerWeapon(playerid));
  57.                     }
  58.                     GetPlayerHealth(i, primeHealth[i]);
  59.                 }
  60.  
  61.             }
  62.         }
  63.     }
  64.     return CallLocalFunction("CallOnPlayerKeyStateChange", "");
  65. }
  66.  
  67.  
  68. forward OnPlayerShootPlayer(shootid, playerid, Float:health, wep);
  69.  
  70. public OnPlayerDeath(playerid, killerid, reason)
  71. {
  72.     GetPlayerHealth(playerid, primeHealth[playerid]);
  73.     CallLocalFunction("OnPlayerShootPlayer", "iifd", killerid, playerid, primeHealth[playerid], reason);
  74.     return CallLocalFunction("CallOnPlayerDeath", "");
  75. }
  76.  
  77.  
  78. // Hook OnPlayerDeath
  79. #if defined HookOnPlayerDeath
  80. #undef OnPlayerDeath
  81. #else
  82. #define HookOnPlayerDeath
  83. #endif
  84. #define OnPlayerDeath CallOnPlayerDeath
  85.  
  86. // Hook OnPlayerKeyStateChange
  87. #if defined HookOnPlayerKeyStateChange
  88. #undef OnPlayerKeyStateChange
  89. #else
  90. #define HookOnPlayerKeyStateChange
  91. #endif
  92. #define OnPlayerKeyStateChange CallOnPlayerKeyStateChange
  93.  
  94. forward OnPlayerKeyStateChange(playerid, newkeys, oldkeys);
  95. forward OnPlayerDeath(playerid, killerid, reason);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement