OnPlayerGiveDamage
#1

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..
Reply
#2

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]
Reply
#3

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...
Reply
#4

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

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

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.
Reply
#7

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

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)