Damage - Client vs Server [rep++]
#5

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.

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


Messages In This Thread
Damage - Client vs Server [rep++] - by EnforcerDon - 02.10.2014, 23:59
Re: Damage - Client vs Server [rep++] - by Abagail - 03.10.2014, 00:04
Re: Damage - Client vs Server [rep++] - by EnforcerDon - 03.10.2014, 00:20
Re: Damage - Client vs Server [rep++] - by JJack - 03.10.2014, 01:52
Re: Damage - Client vs Server [rep++] - by Pottus - 03.10.2014, 01:57
Re: Damage - Client vs Server [rep++] - by EnforcerDon - 03.10.2014, 02:12
Re: Damage - Client vs Server [rep++] - by XGreen - 03.10.2014, 02:17
Re: Damage - Client vs Server [rep++] - by Pottus - 03.10.2014, 02:18
Re: Damage - Client vs Server [rep++] - by EnforcerDon - 03.10.2014, 02:23
Re: Damage - Client vs Server [rep++] - by EnforcerDon - 03.10.2014, 02:26

Forum Jump:


Users browsing this thread: 3 Guest(s)