OnPlayerTakeDamage reliability issue
#1

In light of the upcoming update I'm sure many server owners and developers are looking to create anti-cheat systems by combining the OnPlayerTakeDamage and OnPlayerWeaponShot callbacks. However, after conducting some testing I've concluded that there seem to be some reliability issues with OnPlayerTakeDamage. The damage OnPlayerTakeDamage reports seems to be different from the actual damage the player takes.

For clarification so that everyone understands what is what:

The amounts shown as "Health before" are:
Код:
GetPlayerHealth(playerid, fHealth);
The amounts shown as "Health after" are:
Quote:

format(string, sizeof(string), "(OnPlayerTakeDamage) Health before: %.1f (%f) | Health after: %.1f (%f)", fHealth, fHealth, fHealth-amount, fHealth-amount);

So basically health minus damage taken (amount) as reported by OnPlayerTakeDamage.


The amounts shown as "Server-side health" and "Client-side health" are:
Quote:

format(string, sizeof(string), "ID: %d | Server-side health: %.1f (%f) | Client-side health: %.1f (%f)", playerid, ValidHealth[playerid], ValidHealth[playerid], fHealth, fHealth);

This is called a couple of seconds after OnPlayerTakeDamage. ValidHealth is the same as "Health after", so health minus damage taken (amount) as reported by OnPlayerTakeDamage.


Here are the tests with several different weapons (all of these are a single shot/punch):

You will notice that the damages reported vary per OnPlayerTakeDamage and GetPlayerHealth.

Punch
Quote:

(OnPlayerTakeDamage) ID: 1 | IssuerID: 0 | Amount: 1.3 (1.320000) | WeaponID: 0 | Bodypart: 3
(OnPlayerTakeDamage) Health before: 100.0 (100.000000) | Health after: 98.6 (98.680000)

Quote:

ID: 1 | Server-side health: 98.6 (98.680000) | Client-side health: 98.0 (98.000000)

9mm
Quote:

(OnPlayerTakeDamage) ID: 1 | IssuerID: 0 | Amount: 8.2 (8.250000) | WeaponID: 22 | Bodypart: 3
(OnPlayerTakeDamage) Health before: 100.0 (100.000000) | Health after: 91.7 (91.750000)

Quote:

ID: 1 | Server-side health: 91.7 (91.750000) | Client-side health: 91.0 (91.000000)

MP5
Quote:

(OnPlayerTakeDamage) ID: 1 | IssuerID: 0 | Amount: 8.2 (8.250000) | WeaponID: 29 | Bodypart: 3
(OnPlayerTakeDamage) Health before: 100.0 (100.000000) | Health after: 91.7 (91.750000)

Quote:

(ID: 1 | Server-side health: 91.7 (91.750000) | Client-side health: 91.0 (91.000000)

Shotgun
Quote:

(OnPlayerTakeDamage) ID: 1 | IssuerID: 0 | Amount: 49.5 (49.500003) | WeaponID: 25 | Bodypart: 3
(OnPlayerTakeDamage) Health before: 100.0 (100.000000) | Health after: 50.4 (50.499996)

Quote:

ID: 1 | Server-side health: 50.4 (50.499996) | Client-side health: 50.0 (50.000000)

Deagle
Quote:

(OnPlayerTakeDamage) ID: 1 | IssuerID: 0 | Amount: 46.2 (46.200000) | WeaponID: 24 | Bodypart: 3
(OnPlayerTakeDamage) Health before: 100.0 (100.000000) | Health after: 53.7 (53.799999)

Quote:

ID: 1 | Server-side health: 53.7 (53.799999) | Client-side health: 53.0 (53.000000)

SPAS-12
Quote:

ID: 1 | IssuerID: 0 | Amount: 39.6 (39.600002) | WeaponID: 27 | Bodypart: 3
Health before: 100.0 (100.000000) | Health after: 60.3 (60.399997)

Quote:

ID: 1 | Server-side health: 60.3 (60.399997) | Client-side health: 60.0 (60.000000)

Sniper
Quote:

(OnPlayerTakeDamage) ID: 1 | IssuerID: 0 | Amount: 41.2 (41.250000) | WeaponID: 34 | Bodypart: 3
(OnPlayerTakeDamage) Health before: 100.0 (100.000000) | Health after: 58.7 (58.750000)

Quote:

ID: 1 | Server-side health: 58.7 (58.750000) | Client-side health: 58.0 (58.000000)

Reply


Messages In This Thread
OnPlayerTakeDamage reliability issue - by Zhao - 22.01.2014, 14:32
Re: OnPlayerTakeDamage reliability issue - by Kalcor - 22.01.2014, 15:02
Re: OnPlayerTakeDamage reliability issue - by Zhao - 22.01.2014, 19:33
Re: OnPlayerTakeDamage reliability issue - by CuervO - 22.01.2014, 22:51
Re: OnPlayerTakeDamage reliability issue - by ViruZz - 24.01.2014, 13:29

Forum Jump:


Users browsing this thread: 2 Guest(s)