[Include] lagcomp.inc - Fixed lagcomp response; custom weapon damage; serversided damage handling
#1

Lagcomp.inc
Version: 2.0 | Last Updated: 5 Sept, 2017


Lagcomp is a simple include which fixes SAMP lagcomp response and detection vastly. There are some advantages too such as protection against Fake kills and since the damage system is all server sided, there is no way hackers can hack Weapon damage values.

Since the damage system is server sided, you can set the weapon's damage per player:
(Note: the damage value is only override for Player giving Player damage, for self damage, these functions don't work)
PHP Code:
SetPlayerWeaponDamage(playeridweaponidFloat:damage);
Float:GetPlayerWeaponDamage(playeridweaponid); 
Installation
  • Click on the download link given above.
  • Click "Raw" button on top of script and "Copy" the code from there.
  • Go to your pawno/include folder and make a new text document file.
  • Paste all the code there and save it as "lagcomp.inc".
  • Goto your script and add "#include <lagcomp>" right after "#include <a_samp>". Then you can include other libraries but this one should be above them.
Download
https://github.com/Agneese-Saini/SA-...de/lagcomp.inc

Credits
Slice - "ProcessDamage" function with the damage data array
Humza - Testing the script
Reply
#2

Good job!
Reply
#3

Wasn't this was going to be in the server-sided include which you removed lately?
Reply
#4

Quote:
Originally Posted by Logic_
View Post
Wasn't this was going to be in the server-sided include which you removed lately?
serversided wasn't gonna make it since you required SKY plugin and everything slice did in weapon-config. So that's why there was no point in making a copy.

This only fixes your lagcomp. This can be further developed for an anti cheat. I guess i will make anti health and armor from this.
Reply
#5

Good release Gammix!,

But isn't this completely useless?, as 'OnPlayerGiveDamage' and 'OnPlayerTakeDamage' can both be faked by some fake kill cheats?


EDIT: Ahh I see, damage checks.. thats very clever indeed
Reply
#6

Quote:
Originally Posted by Killa[DGZ]
View Post
Good release Gammix!,

But isn't this completely useless?, as 'OnPlayerGiveDamage' and 'OnPlayerTakeDamage' can both be faked by some fake kill cheats?


EDIT: Ahh I see, damage checks.. thats very clever indeed
I forgot to mention this also has protection against fake kills
Reply
#7

Quote:
Originally Posted by Gammix
View Post
I forgot to mention this also has protection against fake kills
Small issue?,

line 488 : warning 202: number of arguments does not match definition
PHP Code:
return LC_OnPlayerTakeDamage(playeridissueridamountweaponidbodypart); 
line 500 : error 025: function heading differs from prototype
PHP Code:
forward LC_OnPlayerTakeDamage(playeridissueridFloat:amountweaponidbodypart); 
line 550 : warning 202: number of arguments does not match definition
PHP Code:
LC_OnPlayerTakeDamage(damagedidplayeridamountweaponidbodypart); 
I'm already using the native within my gamemode.. could that be it?
Reply
#8

Quote:
Originally Posted by Killa[DGZ]
View Post
Small issue?,

line 488 : warning 202: number of arguments does not match definition
PHP Code:
return LC_OnPlayerTakeDamage(playeridissueridamountweaponidbodypart); 
line 500 : error 025: function heading differs from prototype
PHP Code:
forward LC_OnPlayerTakeDamage(playeridissueridFloat:amountweaponidbodypart); 
line 550 : warning 202: number of arguments does not match definition
PHP Code:
LC_OnPlayerTakeDamage(damagedidplayeridamountweaponidbodypart); 
I'm already using the native within my gamemode.. could that be it?
One of your include is using a different set of parameters for OnPlayerTakeDamage.
Reply
#9

You were right, I was simply missing the 'bodypart' parameter from the function heading within my gamemode..
PHP Code:
OnPlayerTakeDamage(playeridissueridFloat:amountweaponid
Thanks.
Reply
#10

A few small issues with this, tested with 10 players within a deathmatch.

You get full armour everytime you kill somebody?(confirmed multiple times)
Sometimes when shooting someone you lose health instead of the target?(confirmed multiple times)
Reply
#11

Quote:
Originally Posted by Killa[DGZ]
View Post
A few small issues with this, tested with 10 players within a deathmatch.

You get full armour everytime you kill somebody?(confirmed multiple times)
Sometimes when shooting someone you lose health instead of the target?(confirmed multiple times)
Yea right, i see the mistakes in code but i will be able to update the include by tomorrow.
Reply
#12

Alright man whenever you can.. thanks very much, it really does improve things quite substantially.

EDIT: Fake killing is still possible also Gammix, I was just fake killed by someone while driving(they were passenger), instead now I actually die when they fake kill me due to the damage sync your include provides, which must mean that they're calling OnPlayerTake/GiveDamage with damage values?

They had no weapons.
Reply
#13

What exactly is wrong with the current lagcomp?
Reply
#14

Quote:
Originally Posted by Kar
View Post
What exactly is wrong with the current lagcomp?
Well for starters it has more delay than an old amstrad computer?.. using this include makes giving/taking damage much much better.
Reply
#15

Quote:
Originally Posted by Killa[DGZ]
View Post
Well for starters it has more delay than an old amstrad computer?.. using this include makes giving/taking damage much much better.
Hmm, what else?

I'm just curious, obviously I always make my own system but I want to know what all this really 'fixes'. (I wanna make sure I'm not missing anything lol)
Reply
#16

Quote:
Originally Posted by Kar
View Post
Hmm, what else?

I'm just curious, obviously I always make my own system but I want to know what all this really 'fixes'. (I wanna make sure I'm not missing anything lol)
For me it fixes the issue where sometimes you shoot someone, an you shoot an shoot an shoot and blood is pissin out of the target but you can't seem to take much health from them until you get really close.

In general, it just makes damage much more synchronized, even my players commented on how fast it was to react when they shot/hit someone an also the bugs :P
Reply
#17

Quote:
Originally Posted by Killa[DGZ]
View Post
For me it fixes the issue where sometimes you shoot someone, an you shoot an shoot an shoot and blood is pissin out of the target but you can't seem to take much health from them until you get really close.

In general, it just makes damage much more synchronized, even my players commented on how fast it was to react when they shot/hit someone an also the bugs :P
Your last comment sounds impossible. Can you elaborate on what you meant?

@Gammix What's the bug with lagcomp?

The only issue I am aware of is that some non-desynced players become bulletproof and none of the callbacks get called (I am not even sure if this has to do something with my code; it happens to 4-5 players a day and it is not possible to reproduce it in an empty gamemode).
Reply
#18

Quote:
Originally Posted by Yashas
View Post
Your last comment sounds impossible. Can you elaborate on what you meant?

@Gammix What's the bug with lagcomp?

The only issue I am aware of is that some non-desynced players become bulletproof and none of the callbacks get called (I am not even sure if this has to do something with my code; it happens to 4-5 players a day and it is not possible to reproduce it in an empty gamemode).
Never heard of that issue Yashas, not sure how thats came about.. be really tricky to fix too I imagine.

In short, the include from my understanding sets everyone to the same team (enables friendly fire) and uses the damage callbacks to negate from the victims health accordingly.

Not sure why, but it is alot quicker and persistant to update than the normal way.. just try it.
Reply
#19

Quote:
Originally Posted by Killa[DGZ]
View Post
Never heard of that issue Yashas, not sure how thats came about.. be really tricky to fix too I imagine.

In short, the include from my understanding sets everyone to the same team (enables friendly fire) and uses the damage callbacks to negate from the victims health accordingly.
I am not sure about the bulletproof issue. It happens so rarely that it makes it very difficult to reproduce it in an empty gamemode. I would need to invite hundreds of players to play in am empty gamemode and wait for it happen.

The other issue is callbacks aren't called always and there are an awful lot of bug reports of this in the Bug Reports section already.

What did it really fix?

Quote:
Originally Posted by Killa[DGZ]
View Post
Not sure why, but it is alot quicker and persistant to update than the normal way.. just try it.
Where did you test?
Reply
#20

The issue with lagcomp is that it first of all doesnt work with melee weapons, when you try to hit someone but it doesnt call OnPlayerTakeDamage, you have to predict like in old days where to fire. Best is that you go in an empty gamemode and test the way "Testing" section in main post says (two times, one without this include and one with).
Ofcourse wait till i fix the bug(s).

Secondally lets say you have a deagle and you fire 7 bullets, its likely that all the shots will register OnPlayerTakeDamage (all the shots were hit) but they will call OnPlayerWeaponShot and OnPlayerGiveDamage. So that part is fixed in this.

So the reason why i set all to same team is so that player cannot damage a player with any weapon, neglect OnPlayerTakeDamage completely for player hit player. So i manually handle damage system in OnPlayerGiveDamage which makes it protective from hacks too.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)