Dying to take punches
#1

I wonder how to change the code, one punches the other and the person loses life, I wanted to know how not to let it happen, does anyone know how I can modoficar? please?

PHP код:
public OnPlayerGiveDamage(playeriddamagedidFloatamountweaponidbodypart) {
    if ( 
weaponid == || weaponid == // soco e soqueira
        
return 0;
    return 
1;

Reply
#2

Edit: Wrong post.
Reply
#3

i would use
https://sampwiki.blast.hk/wiki/OnPlayerTakeDamage

even though both are called after damage has been done
you could use https://sampwiki.blast.hk/wiki/SetPlayerHealth
to restore the old health.

use a var to hold the old health,
if damage is done by fist restore health
if done by other weapon then update the health var with new health value.


returning 0 will just stop any filterscripts from running that callback.
Reply
#4

what you mean exactly? mm why player1 shoot player2,player2 die directly?
also put full codes
Reply
#5

Up..
Reply
#6

pawn Код:
new Float:aPlayerPunchHealth[MAX_PLAYERS];

public OnPlayerSpawn(playerid)
{
    GetPlayerHealth(playerid,aPlayerPunchHealth[playerid]);
    return 1;
}

public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
    if(issuerid != INVALID_PLAYER_ID) // If not self-inflicted
    {
        if ( weaponid == 0 || weaponid == 1 ){
            return SetPlayerHealth(playerid,aPlayerPunchHealth[playerid]);
        }
        GetPlayerHealth(playerid,aPlayerPunchHealth[playerid]);
    }
    return 1;
}
something like this.
you may want to handle the armor like the health also
Reply
#7

Why should we make it so difficult..

PHP код:
public OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if(
newkeys KEY_FIRE) {
            if(
GetPlayerWeapon(playerid) == || GetPlayerWeapon(playerid) == 1) {
                new 
victimid GetClosestPlayer(playerid);
                if(
IsPlayerConnected(victimid)) {
                    if(
GetDistanceBetweenPlayers(playerid,victimid) < 2) {
                        new 
Float:health;
                        
GetPlayerHealth(victimidhealth);
                        
SetPlayerHealth(victimidhealth 3.0);
                        return 
1;
                    }
            }
        }
    } 
And :

PHP код:
forward GetClosestPlayer(p1)
public 
GetClosestPlayer(p1)
{
    new 
x,Float:dis,Float:dis2,player;
    
player = -1;
    
dis 99999.99;
    for (
x=0;x<MAX_PLAYERS;x++) {
        if(
IsPlayerConnected(x)) {
            if(
!= p1) {
                
dis2 GetDistanceBetweenPlayers(x,p1);
                if(
dis2 dis && dis2 != -1.00) {
                    
dis dis2;
                    
player x;
                }
            }
        }
    }
    return 
player;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)