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



OnPlayerGiveDamage Grenades problem - RedFusion - 11.08.2012

This callback does not detect explosion damage. In order to disable OnPlayerTakeDamage i have set all players to the same team, somehow i need to add grenades into OnPlayerTakeDamage as an exception and take damage even if all the players are in the same team. I use SetPlayerTeam.


Re: OnPlayerGiveDamage Grenades problem - [MM]RoXoR[FS] - 11.08.2012

pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
    if((gTeam[issuerid] == gTeam[playerid]) && weaponid == 16 )
    {
        SetPlayerHealth(playerid, GetPlayerHealth(playerid)-amount);
    }
    return 1;
}



Re: OnPlayerGiveDamage Grenades problem - RedFusion - 11.08.2012

Thing is, when 2 players are on the same team they dont recieve any damage from each others, so i dont think that callback is the way to go..

btw gTeam should compare like != and not == because i dont want teamplayers to kill eachothers


Re: OnPlayerGiveDamage Grenades problem - RedFusion - 11.08.2012

No help?


Re: OnPlayerGiveDamage Grenades problem - RedFusion - 12.08.2012

Bump!


Re: OnPlayerGiveDamage Grenades problem - playbox12 - 12.08.2012

I'm not sure if I understand what you mean. The example posted by RoXor will not work because the damage is never registered (the player will not take damage). Why doesn't OnPlayerGiveDamage work for this?

On a side note, stop bumping your topic so much, I know your eager to get help but you're not the only one, and we don't get paid to help you. Have some patience.


Re: OnPlayerGiveDamage Grenades problem - RedFusion - 12.08.2012

well it seems like OnPlayerGiveDamage doesnt register explosion damage.


Re: OnPlayerGiveDamage Grenades problem - RedFusion - 12.08.2012

OnPlayerTakeDamage Does register damage even if he is in the same team, but it restores automatically i guess. If you withdraw the damaged amount manually within the script it should work. So Roxor's theory probably works, thanks. +Rep.


Re: OnPlayerGiveDamage Grenades problem - playbox12 - 12.08.2012

Well, yeah, it makes sense GiveDamage doesn't register it as the game is probably more of a deal forget system. The grenade is thrown and damage is dealt, who threw it is unknown. TakeDamage should indeed work, I forgot it gets called whenever the player takes damage no matter what the cause is. However it depends how the team system works in samp, the no damage to friendlies is native so it can very well be that the damage is just never processed instead of set to old health.


Re: OnPlayerGiveDamage Grenades problem - new121 - 12.08.2012

There was no need to set all players to the same team, this snippet will disable gun damage, but nades will still kill people.

PHP код:
public OnPlayerTakeDamage(playeridissueridFloatamountweaponid)
{
    if(
issuerid != INVALID_PLAYER_ID && GetPlayerWeapon(playerid) != 16)
    {
            return 
0;//if they take damage from another player, and it is not from a nade the update isn't synced.
    
}
    return 
1;