SA-MP Forums Archive
Dying to take punches - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Dying to take punches (/showthread.php?tid=579024)



Dying to take punches - JoshNudock - 23.06.2015

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;




Re: Dying to take punches - Inn0cent - 23.06.2015

Edit: Wrong post.


Re: Dying to take punches - Jonny5 - 23.06.2015

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.


Re: Dying to take punches - Roberto80 - 23.06.2015

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


Re: Dying to take punches - JoshNudock - 23.06.2015

Up..


Re: Dying to take punches - Jonny5 - 23.06.2015

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


Re : Dying to take punches - KillerDVX - 24.06.2015

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;