SA-MP Forums Archive
OnPlayerGiveDamage - 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: OnPlayerGiveDamage (/showthread.php?tid=647053)



OnPlayerGiveDamage - None1337 - 28.12.2017

Hello, i have a problem on my server with OnPlayerGiveDamage.

I have this code

Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart)
{
    if(damagedid != INVALID_PLAYER_ID) {
        if(PlayerInfo[playerid][pGroup] == PlayerInfo[playerid][pGroup] && WarActive[PlayerInfo[playerid][pMember]] > 0) {
            amount = 0;
            return 0;
        }
    }
    return 1;
}
As far I know, return 0 stop the function to be executed, but the player still take damage..


Re: OnPlayerGiveDamage - Kane - 28.12.2017

returning 0 doesn't stop the damage. Check the return values for OnPlayerGiveDamage in the SA:MP wiki.

Also:
Код:
PlayerInfo[playerid][pGroup] == PlayerInfo[playerid][pGroup]



Re: OnPlayerGiveDamage - None1337 - 29.12.2017

Quote:
Originally Posted by Arthur Kane
Посмотреть сообщение
returning 0 doesn't stop the damage. Check the return values for OnPlayerGiveDamage in the SA:MP wiki.

Also:
Код:
PlayerInfo[playerid][pGroup] == PlayerInfo[playerid][pGroup]
I changed, same..

I saw the returns on wiki, but i don't use any filterscripts...


Re: OnPlayerGiveDamage - RedFusion - 29.12.2017

Quote:
Originally Posted by Arthur Kane
Посмотреть сообщение
returning 0 doesn't stop the damage.
this


Re: OnPlayerGiveDamage - None1337 - 29.12.2017

So, what can I do for health of damagedid to not decrease when the playerid shoot?


Re: OnPlayerGiveDamage - Ritzy2K - 29.12.2017

Quote:
Originally Posted by None1337
Посмотреть сообщение
So, what can I do for health of damagedid to not decrease when the playerid shoot?
Put them in the same team? That's the only flawless way I know so far.

Edit: You can actually return 0 in OnPlayerWeaponShot to make the bullet useless

Код:
OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
 if(hittype = BULLET_HIT_TYPE_PLAYER)
{
     if(PlayerInfo[playerid][pGroup] == PlayerInfo[playerid][pGroup] && WarActive[PlayerInfo[playerid][pMember]] > 0)
       return 0;
}
return 1;
}
Sorry for lousy braces xD It's hard at tablet

Edit2: Jake, that's a shitty idea. if a player has 1 HP, he will die.

Try what I said, I'm fairly certain it would work.


Re: OnPlayerGiveDamage - JaKe Elite - 29.12.2017

You can try getitng the player's health then SetPlayerHealth increasing it using the amount of damage that player sustained.


Re: OnPlayerGiveDamage - RedFusion - 29.12.2017

The best way to do it is to block all damage between players by assigning them to the same team (SetPlayerTeam) and then allow some exceptions, where one exception would be that they're in different groups.