SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Discussion

Reply
 
Thread Tools Display Modes
Old 10/04/2013, 11:55 PM   #1
MP2
Godfather
 
MP2's Avatar
 
Join Date: Jan 2011
Location: England
Posts: 6,231
Reputation: 993
Default Anti-Lag

If you're not familar with what I mean by 'anti-lag', here's a brief thing:

Because of lag, you have to 'lead' the player you're shooting at, which sucks. Lag compensation would be awesome, but Kye has stated that he tried to add this and it didn't work great, and I can't see it being added any time soon. What he did do which is really awesome though, is add the callback 'OnPlayerGiveDamage'. This callback is fired when YOU damage a player, not when THEY take the damage, which means lag/latency is completely gone.

This may seem like the most awesome thing ever, unfortunately, with most things in life, if it sound too good to be true.......


1. Cheating

Kye has said this himself. I can't find the post (it may be gone now) but he basically said that it may be possible to hack it so you can 'fake' damage being given, as the client reports this to the server.

2. Controllers/Joypads can Auto-Aim/Lock-On

Joypads/controllers (as you may know) can auto-aim or 'lock-on' to targets and EVERY shot will hit. This is obviously a massive advantage. The only slight thing is, that it can happen in reverse. If a player with a mouse aims NEAR a player that is using a joypad, the joypad user will see that the mouse user, even though not aiming directly at the player, is locked on, and it's very hard to escape this. They will take all the damage, even if the mouse user never actually hits them on their screen.

What's your opinion on this? I REALLY want to use anti-lag on my server, but these two things are making it seem a less and less viable option.
__________________
Click banner above for more info. View trailers here.
Enter referral code SAMPFORUM after registering for a $5000 starting bonus!
MP2 is offline   Reply With Quote
Old 11/04/2013, 12:16 AM   #2
Pottus
High-roller
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 4,852
Reputation: 1313
Default Re: Anti-Lag

The best way to use Anti-lag is to create a hybrid type system where you can lead aim but also shoot the skin if you want due to the nature of this kind of system you will need to have a delay to see if a player has any OnPlayerTakeDamage() happen in this case you cancel the OnPlayerGiveDamage(). We've had some excellent results with this type of system being well suited and balanced for online play since the damage cycle of OnPlayerGiveDamage() is 300ms per message it tones down the excessive damage as a result which quells rapid-fire cbugging. I should also note since it will only process one per 300ms any additional messages are ignored until this is complete or an OnPlayerTakeDamage() is received, there is no need for putting all the players on the same team which is so lame with most anti-lag systems as a lead aim shot will stun you but no damage is lost. In terms of cheating we've never had anyone send fake messages yet that isn't much of an issue in fact it's usually quite the opposite making cheating more difficult.

Edit - There is a lot of stuff you need to do to set this up correctly, I wouldn't recommend using OnPlayerDeath() it's better to make your own call back I usually use OnPlayerDeathEx() then set OnPlayerDeath() { return 1; } now you'll need to detect when a player is killed. I send the message from OnPlayerGiveDamage() to a hit issuer function which will directly call OnPlayerTakeDamage() from there you process the damage and set it with SetPlayerArmour() and SetPlayerHealth() then call OnPlayerDeathEx() when a kill is detected. You'll also need to use OnPlayerStateChange() since some deaths are not detected in OnPlayerTakeDamage(). Contact me if you need more information I've written several of these systems and have done literally months of testing and tweaking so I have a pretty good idea of all situations you'll encounter.

Last edited by Pottus; 11/04/2013 at 02:01 AM.
Pottus is offline   Reply With Quote
Old 11/04/2013, 09:04 AM   #3
MP2
Godfather
 
MP2's Avatar
 
Join Date: Jan 2011
Location: England
Posts: 6,231
Reputation: 993
Default Re: Anti-Lag

Not sure what that has to do with anything I mentioned, but okay.
__________________
Click banner above for more info. View trailers here.
Enter referral code SAMPFORUM after registering for a $5000 starting bonus!
MP2 is offline   Reply With Quote
Old 11/04/2013, 09:55 AM   #4
cessil
High-roller
 
cessil's Avatar
 
Join Date: Apr 2009
Posts: 1,353
Reputation: 296
Default Re: Anti-Lag

For mine I only used OnPlayerGiveDamage.
I put everyone on teamid 1 so that no one could hurt each other, and then checked under opgd a few things like if they were on opposite teams, if they were not in shop mode, not spawn kill protected, not already dead and the player shooting was not already dead.

Since all health and armour variables were stored on the server and then displayed on the clients I knew when someone would die, the killerid and the reason before they would.
I saved the killerid and reason with variables and under OnPlayerDeath used the variables instead of whatever would of been reported. (Also making sure the killerid was still connected)

1. Cheating
There were only a couple cheaters that were ever a threat, one that did fake killing which was easily detected since if no damage was reported how can there be a killer?
And another with rapid fire weapons like a rapid fire sniper rifle, which I detected and blocked by getting the time intervals of every weapon and stopping the damage if it was too fast.

2. Controllers/Joypads can Auto-Aim/Lock-On
They weren't really a threat although I did have detection and a kick for them, seeing as joypad users never return an id for GetPlayerTargetPlayer.

I did have to put up a few things to make it easier for players being shot though.
1. Everyone on the opposite team had no name tag or map marker.
2. On being hit, the person that hit you would have their name tag revealed and their map marker visible for you until your death or theirs.
3. Also added a tagging system where you aim at a person and press the 'NO' key then they'd have their name tag visible and map marker for your whole team until their death.
4. On being hit, a textdraw would display showing how much damage you're taking which would stack or disappear within a few seconds.

The main reason I did it was to get rid of health locking cheaters, but I also thought it'd be interesting and I had gotten very sick of lead aiming.
cessil is offline   Reply With Quote
Old 11/04/2013, 10:25 AM   #5
MP2
Godfather
 
MP2's Avatar
 
Join Date: Jan 2011
Location: England
Posts: 6,231
Reputation: 993
Default Re: Anti-Lag

I personally use a PS3 controller, and I wouldn't re-join a server that kicked me for using it!

It's very tempting for me to go ahead with this, but I'm really not sure. It's almost impossible to detect auto-aiming (even with the target function - if a player shoots with a mouse and keyboard from medium range they won't show a target and your method will make the script think they're using a joypad).

What would really be awesome would be a function to disable controller lock-on.
__________________
Click banner above for more info. View trailers here.
Enter referral code SAMPFORUM after registering for a $5000 starting bonus!
MP2 is offline   Reply With Quote
Old 11/04/2013, 11:30 AM   #6
Gamer_Z
High-roller
 
Join Date: Jun 2009
Posts: 1,047
Reputation: 1370
Default Re: Anti-Lag

I'm wondering, if you set the same team for all players and shoot with an RPG/hunter rocket / hydra near them, does OnPlayerGiveDamage get called? Or will the players be 'explosion invincible'?
Gamer_Z is offline   Reply With Quote
Old 11/04/2013, 11:58 AM   #7
Pottus
High-roller
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 4,852
Reputation: 1313
Default Re: Anti-Lag

Quote:
Originally Posted by Gamer_Z View Post
I'm wondering, if you set the same team for all players and shoot with an RPG/hunter rocket / hydra near them, does OnPlayerGiveDamage get called? Or will the players be 'explosion invincible'?
I'm pretty sure explosions are invincible I know nades don't get called so I'm guessing it should be the same for these weapons, but like I mentioned anti-lag with everyone on the same team is lame.
Pottus is offline   Reply With Quote
Old 12/04/2013, 01:35 AM   #8
2KY
Gangsta
 
2KY's Avatar
 
Join Date: Jan 2012
Location: United States
Posts: 950
Reputation: 166
Default Re: Anti-Lag

The only anti-lag server I've ever visited that was decent was cessil's and he's basically mastered it. It works perfectly, go give it a try, and listen to his tips - he knows what he's talking about.
__________________
Check out my wiki page
2KY is offline   Reply With Quote
Old 12/04/2013, 01:51 AM   #9
[ABK]Antonio
High-roller
 
[ABK]Antonio's Avatar
 
Join Date: Sep 2011
Location: ID, USA
Posts: 1,224
Reputation: 185
Default Re: Anti-Lag

I wouldn't say perfectly, but with current stuff ye it's pretty good... Lag is still present just in a different way. They can be off screen on your screen but you're on theirs due to latency and kill you
__________________

ABKClan.com
[ABK]Antonio is offline   Reply With Quote
Old 12/04/2013, 04:49 PM   #10
wups
High-roller
 
wups's Avatar
 
Join Date: Apr 2010
Posts: 1,216
Reputation: 141
Default Re: Anti-Lag

It's been discussed multiple times, nowadays there are two-three disadvantages of this system.
First and most important - the aimhackers. You just can't detect them without an admin test.
the second would be the latency lags. People get desynced and you can't change their health by SetPlayerHealth, so they get reported by other players of being invulnerable.
And the last - you can't give grenade and rocketlauncher damage.
wups is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] Anti-Lag/Anti-Lead/MTA-Bullet Hit Sync System v0.1 (Weapon Damages Synced) Matz Filterscripts 21 26/05/2018 04:37 PM
Anti Flood/Anti Spam/Anti Database Hack CROSS_Hunter Server Support 3 11/09/2012 08:29 AM
[FilterScript] [FS]Zadmin2.0|Admin System + Anticheat + Anti-flood + Anti high ping [ZFM]Zuc Filterscripts 32 18/06/2012 06:29 PM
[FilterScript] [K.A.S] Knight's Anti Cheat (Anti: Armas, Spam, DB, MaxPing, Palavrões, Money Hack) The Knight Lançamentos/Releases 5 05/05/2011 04:41 AM


All times are GMT. The time now is 11:00 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.