03.10.2014, 01:57
OnPlayerGiveDamage() is reported by the player WHO shoots another player.
OnPlayerTakeDamage() is reported by the player WHO was shot after taking damage.
If you want to use OnPlayerGiveDamage() which is what I recommend when creating your own damage system which any serious server should be using anyways since lagcomp as I have said many times is unreliable. You need to set all players to the same team to negate OnPlayerTakeDamage() I have created an include which I use to hook the SetPlayerTeam() and GetPlayerTeam() functions to do this behind the scenes.
Now there is a few other things you will need to do and it is quite a bit to explain but I will give a quick outline.
- Calculate damage in OnPlayerGiveDamage() you can set damage values to whatever you want
- Damage for certain weapons will not work (nades, vehicles) these are detectable in OnPlayerTakeDamage() where you can process custom damage values
- Directly call OnPlayerDeath() when a player dies you will also need to set a variable PlayerIsDead[playerid] = true; and return 1; on successive calls to OnPlayerDeath() it will happen
OnPlayerTakeDamage() is reported by the player WHO was shot after taking damage.
If you want to use OnPlayerGiveDamage() which is what I recommend when creating your own damage system which any serious server should be using anyways since lagcomp as I have said many times is unreliable. You need to set all players to the same team to negate OnPlayerTakeDamage() I have created an include which I use to hook the SetPlayerTeam() and GetPlayerTeam() functions to do this behind the scenes.
pawn Код:
static PlayerTeam[MAX_PLAYERS];
forward TF_SetPlayerTeam(playerid, team);
public TF_SetPlayerTeam(playerid, team)
{
PlayerTeam[playerid] = team;
return SetPlayerTeam(playerid, 999);
}
#if defined _ALS_SetPlayerTeam
#undef SetPlayerTeam
#else
#define _ALS_SetPlayerTeam
#endif
#define SetPlayerTeam TF_SetPlayerTeam
forward TF_GetPlayerTeam(playerid);
public TF_GetPlayerTeam(playerid)
{
return PlayerTeam[playerid];
}
#if defined _ALS_GetPlayerTeam
#undef GetPlayerTeam
#else
#define _ALS_GetPlayerTeam
#endif
#define GetPlayerTeam TF_GetPlayerTeam
- Calculate damage in OnPlayerGiveDamage() you can set damage values to whatever you want
- Damage for certain weapons will not work (nades, vehicles) these are detectable in OnPlayerTakeDamage() where you can process custom damage values
- Directly call OnPlayerDeath() when a player dies you will also need to set a variable PlayerIsDead[playerid] = true; and return 1; on successive calls to OnPlayerDeath() it will happen