Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //
- // OnPlayerShootPlayer
- // Author: Bruno da Silva (thanks Allan Jader and Robson)
- // www.ips-team.blogspot.com
- //
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- new
- Float:primeHealth[MAX_PLAYERS],
- Float:ultimaDiferenca[MAX_PLAYERS];
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- static animacaoAtual[32];
- GetAnimationName(GetPlayerAnimationIndex(playerid), animacaoAtual, 32, animacaoAtual, 32);
- if(strfind(animacaoAtual, "GUN_STAND", true) != -1 || strfind(animacaoAtual, "COLT45_FIRE", true) != -1) {
- static
- Float:xPos,
- Float:yPos,
- Float:zPos,
- Float:distancia,
- Float:aPos;
- new
- Float:xPlayer,
- Float:yPlayer,
- Float:zPlayer,
- Float:diferenceHealth;
- GetPlayerPos(playerid, xPos, yPos, zPos);
- GetPlayerFacingAngle(playerid, aPos);
- for(new i = 0; i != MAX_PLAYERS; ++i) if(IsPlayerInRangeOfPoint(i, 200.0, xPos, yPos, zPos) && i != playerid) {
- GetPlayerPos(i, xPlayer, yPlayer, zPlayer);
- distancia = floatsqroot(floatpower(floatabs(xPos-xPlayer), 2) + floatpower(floatabs(yPos-yPlayer), 2));
- if(distancia < 100.0) {
- xPos += (distancia * floatsin(-aPos, degrees)),
- yPos += (distancia * floatcos(-aPos, degrees));
- distancia = floatsqroot(floatpower(floatabs(xPos-xPos), 2) + floatpower(floatabs(yPos-yPlayer), 2));
- switch(GetPlayerWeapon(playerid)) {
- case 34:distancia -= 2.0;
- case 31:distancia -= 0.5;
- case 30:distancia -= 0.3;
- case 33:distancia -= 1.3;
- }
- if(distancia < 1.9) {
- GetPlayerHealth(i, diferenceHealth);
- if(diferenceHealth < primeHealth[i] && ultimaDiferenca[i] != primeHealth[i] - diferenceHealth) {
- ultimaDiferenca[i] = primeHealth[i] - diferenceHealth;
- CallLocalFunction("OnPlayerShootPlayer", "iifd", playerid, i, ultimaDiferenca[i], GetPlayerWeapon(playerid));
- }
- GetPlayerHealth(i, primeHealth[i]);
- }
- }
- }
- }
- return CallLocalFunction("CallOnPlayerKeyStateChange", "");
- }
- forward OnPlayerShootPlayer(shootid, playerid, Float:health, wep);
- public OnPlayerDeath(playerid, killerid, reason)
- {
- GetPlayerHealth(playerid, primeHealth[playerid]);
- CallLocalFunction("OnPlayerShootPlayer", "iifd", killerid, playerid, primeHealth[playerid], reason);
- return CallLocalFunction("CallOnPlayerDeath", "");
- }
- // Hook OnPlayerDeath
- #if defined HookOnPlayerDeath
- #undef OnPlayerDeath
- #else
- #define HookOnPlayerDeath
- #endif
- #define OnPlayerDeath CallOnPlayerDeath
- // Hook OnPlayerKeyStateChange
- #if defined HookOnPlayerKeyStateChange
- #undef OnPlayerKeyStateChange
- #else
- #define HookOnPlayerKeyStateChange
- #endif
- #define OnPlayerKeyStateChange CallOnPlayerKeyStateChange
- forward OnPlayerKeyStateChange(playerid, newkeys, oldkeys);
- forward OnPlayerDeath(playerid, killerid, reason);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement