SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 26/03/2018, 08:29 PM   #1
oSAINTo
Huge Clucker
 
oSAINTo's Avatar
 
Join Date: Aug 2015
Posts: 204
Reputation: 35
Default How to get better hit-registration(sync) without any includes/filterscripts/etc.

Well, today I'm going to be teaching you exactly what the title of the thread states. Yes, I know there are some amazing includes out there that actually improve the hit-registration. Hell, two of these includes are actually extremely popular! Those being:
Though these are extremely viable options for better hit-registration, many people would prefer to not have to use an external include or external code just to get better hit-registration. I'm here to tell you why you don't need these external includes just to get better hit-registration. Surprisingly, many people don't know that you can actually get better hit sync, vehicle sync, and just plain old on-foot sync just by editing some values in your default server.cfg file.

Let's take a look at the default server.cfg file for 0.3-DL:
Code:
echo Executing Server Config...
lanmode 0
rcon_password changeme
maxplayers 50
port 7777
hostname SA-MP 0.3 Server
gamemode0 grandlarc 1
filterscripts gl_actions gl_realtime gl_property gl_mapicon ls_elevator attachments test_cmds skinchanger vspawner ls_mall ls_beachside npc_record stunt_island stunt_island2 ospawner
announce 0
chatlogging 0
weburl www.sa-mp.com
onfoot_rate 80
incar_rate 80
weapon_rate 40
stream_distance 300.0
stream_rate 1000
maxnpc 10
logtimeformat [%H:%M:%S]
language English
useartwork 1
sleep 1
mtu 1400
This file actually has A LOT of useful data in it that you can adjust and tinker with to improve the overall stability, performance, and sync of your gameserver. Yet, for this tutorial, we're focusing on hit-registration. So, let's focus on the specific line that deals with hit-registration.
Code:
weapon_rate 40
Now, let's take a step back and learn about weapon_rate for a second. On the SA-MP wiki weapon_rate is classified under the "Client" section. This means that it deals with connected clients(users) and their specific rates. Now, by definition, weapon_rate is: "The time in milliseconds a client should update the server with new data while firing a weapon." Basically, what this means is that whenever a player fires a weapon it will take 40ms to send data to the server and update it's previous data. That's based on the rate in the default server.cfg, however.

Though 40ms may not seem like a long time, in terms of sync it can cause some issues or hiccups. We all have witnessed those times when we're DMing or just shooting in general and our crosshair is clearly on the opposing player and when we shoot it just seems to miss. This is caused by weapon_rate, packetloss, ping, and server stability. Yet, we're focusing on weapon_rate. If we look back at the SA-MP wiki, it also tells us under the "Client" section that: "Lower values of onfoot_rate, incar_rate and weapon_rate increases sync performance, but uses more bandwidth." Yes, lowering the value of weapon_rate will cause more bandwidth usage, yet that's expected considering we're going to be improving the sync of the server. Of course it will require more packets to be send back-and-forth since they'll be being sent faster to the server.

Now, before you go and set your weapon_rate down to 1 and think you're going to have the best sync ever let me stop you. We're going to have to use some common-sense. If we set the weapon_rate value to 1, this means that it will only take 1ms to update the server with data from the client whenever they shoot. Let's imagine the client is using a weapon that has a high fire-rate. An M4, AK-47, Tec9, Uzi, Mp5, Minigun, etc. This would cause the server to practically update instantly whenever the client fires a bullet. This will cause issues because it will hog up the bandwidth and possibly even cause the server to flood with packets(simulating a DDoS attack sort-of.) So let's be reasonable with the number we set the weapon_rate to.

Personal preference and just from previous experience, I'd say choose a number anywhere for 18-25. Though these numbers don't seem far from the original 40, it will genuinely make a huge difference. The best way to figure out what you want this rate to be is just by trial and error. Change the number down to something you think will work, try it out. If it's slowing down the server or causing the sync to be TOO precise for SA-MP, then bump it up. Keep testing new values and figure out which works the best for your server/community. I also suggest matching the onfoot_rate and incar_rate values to your weapon_rate values as that'll increase the overall sync for your community. If you're just a DM server that uses arenas, then the onfoot_rate and weapon_rate will be what you need to worry about. If you're a TDM server that uses vehicles, then you should worry about all three.

I know many people may not classify this as a tutorial, but I believe it is because it's informing people of something they didn't know about previously and teaching them. If you have any questions or concerns, please don't be shy. Leave a reply below, I'd be more than happy to converse about this and assist anyone in need. I hope someone finds this tutorial useful, have a great day!

tl;dr
lower the weapon_rate value in your server.cfg and figure out which value works the best for your community's needs/desires.
oSAINTo is offline   Reply With Quote
Old 27/03/2018, 04:10 AM   #2
LMan
Little Clucker
 
Join Date: Dec 2017
Posts: 3
Reputation: 0
Default Re: How to get better hit-registration(sync) without any includes/filterscripts/etc.

Thank you very much! You really helped me to understand what the problem with the sync of shooting is at all.
LMan is offline   Reply With Quote
Old 27/03/2018, 12:31 PM   #3
oSAINTo
Huge Clucker
 
oSAINTo's Avatar
 
Join Date: Aug 2015
Posts: 204
Reputation: 35
Default Re: How to get better hit-registration(sync) without any includes/filterscripts/etc.

Quote:
Originally Posted by LMan View Post
Thank you very much! You really helped me to understand what the problem with the sync of shooting is at all.
Glad you found it informative and useful.
oSAINTo is offline   Reply With Quote
Old 14/05/2019, 06:00 AM   #4
DeitY
Huge Clucker
 
DeitY's Avatar
 
Join Date: Aug 2012
Location: Serbia
Posts: 323
Reputation: 14
Default Re: How to get better hit-registration(sync) without any includes/filterscripts/etc.

Quote:
Originally Posted by oSAINTo View Post
Well, today I'm going to be teaching you exactly what the title of the thread states. Yes, I know there are some amazing includes out there that actually improve the hit-registration. Hell, two of these includes are actually extremely popular! Those being:
Though these are extremely viable options for better hit-registration, many people would prefer to not have to use an external include or external code just to get better hit-registration. I'm here to tell you why you don't need these external includes just to get better hit-registration. Surprisingly, many people don't know that you can actually get better hit sync, vehicle sync, and just plain old on-foot sync just by editing some values in your default server.cfg file.

Let's take a look at the default server.cfg file for 0.3-DL:
Code:
echo Executing Server Config...
lanmode 0
rcon_password changeme
maxplayers 50
port 7777
hostname SA-MP 0.3 Server
gamemode0 grandlarc 1
filterscripts gl_actions gl_realtime gl_property gl_mapicon ls_elevator attachments test_cmds skinchanger vspawner ls_mall ls_beachside npc_record stunt_island stunt_island2 ospawner
announce 0
chatlogging 0
weburl www.sa-mp.com
onfoot_rate 80
incar_rate 80
weapon_rate 40
stream_distance 300.0
stream_rate 1000
maxnpc 10
logtimeformat [%H:%M:%S]
language English
useartwork 1
sleep 1
mtu 1400
This file actually has A LOT of useful data in it that you can adjust and tinker with to improve the overall stability, performance, and sync of your gameserver. Yet, for this tutorial, we're focusing on hit-registration. So, let's focus on the specific line that deals with hit-registration.
Code:
weapon_rate 40
Now, let's take a step back and learn about weapon_rate for a second. On the SA-MP wiki weapon_rate is classified under the "Client" section. This means that it deals with connected clients(users) and their specific rates. Now, by definition, weapon_rate is: "The time in milliseconds a client should update the server with new data while firing a weapon." Basically, what this means is that whenever a player fires a weapon it will take 40ms to send data to the server and update it's previous data. That's based on the rate in the default server.cfg, however.

Though 40ms may not seem like a long time, in terms of sync it can cause some issues or hiccups. We all have witnessed those times when we're DMing or just shooting in general and our crosshair is clearly on the opposing player and when we shoot it just seems to miss. This is caused by weapon_rate, packetloss, ping, and server stability. Yet, we're focusing on weapon_rate. If we look back at the SA-MP wiki, it also tells us under the "Client" section that: "Lower values of onfoot_rate, incar_rate and weapon_rate increases sync performance, but uses more bandwidth." Yes, lowering the value of weapon_rate will cause more bandwidth usage, yet that's expected considering we're going to be improving the sync of the server. Of course it will require more packets to be send back-and-forth since they'll be being sent faster to the server.

Now, before you go and set your weapon_rate down to 1 and think you're going to have the best sync ever let me stop you. We're going to have to use some common-sense. If we set the weapon_rate value to 1, this means that it will only take 1ms to update the server with data from the client whenever they shoot. Let's imagine the client is using a weapon that has a high fire-rate. An M4, AK-47, Tec9, Uzi, Mp5, Minigun, etc. This would cause the server to practically update instantly whenever the client fires a bullet. This will cause issues because it will hog up the bandwidth and possibly even cause the server to flood with packets(simulating a DDoS attack sort-of.) So let's be reasonable with the number we set the weapon_rate to.

Personal preference and just from previous experience, I'd say choose a number anywhere for 18-25. Though these numbers don't seem far from the original 40, it will genuinely make a huge difference. The best way to figure out what you want this rate to be is just by trial and error. Change the number down to something you think will work, try it out. If it's slowing down the server or causing the sync to be TOO precise for SA-MP, then bump it up. Keep testing new values and figure out which works the best for your server/community. I also suggest matching the onfoot_rate and incar_rate values to your weapon_rate values as that'll increase the overall sync for your community. If you're just a DM server that uses arenas, then the onfoot_rate and weapon_rate will be what you need to worry about. If you're a TDM server that uses vehicles, then you should worry about all three.

I know many people may not classify this as a tutorial, but I believe it is because it's informing people of something they didn't know about previously and teaching them. If you have any questions or concerns, please don't be shy. Leave a reply below, I'd be more than happy to converse about this and assist anyone in need. I hope someone finds this tutorial useful, have a great day!

tl;dr
lower the weapon_rate value in your server.cfg and figure out which value works the best for your community's needs/desires.
Can you provide guide for functions such as sleep and tweaks for onfoot rate / in vehicle rate?
__________________
Kasno je za oprostaj ; )

DeitY is offline   Reply With Quote
Old 31/05/2019, 05:37 PM   #5
MisterTickle
Huge Clucker
 
MisterTickle's Avatar
 
Join Date: Jul 2007
Posts: 365
Reputation: 75
Default Re: How to get better hit-registration(sync) without any includes/filterscripts/etc.

onfoot_rate 20
incar_rate 20
weapon_rate 20
stream_distance 300.0
stream_rate 1000

This is what we've had for years and have noticed no problems. Also we are on a dedicated machine (not a VPS or gameserver)
__________________
MisterTickle 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
[Tool/Web/Other] Filterscripts and includes Michael@Belgium Filterscripts 147 11/01/2018 09:15 PM
[DUVIDA] Sobre filterscripts e includes Vinicin PortuguÍs/Portuguese 4 19/10/2014 12:58 PM
[Tool/Web/Other] Useful Filterscripts and Includes FireCat Filterscripts 5 22/07/2012 02:48 PM
[Tool/Web/Other] [0.3d]Filterscripts and Includes Notis123 Filterscripts 15 06/12/2011 02:00 PM
[QUESTION] includes Vs filterscripts clavador Help Archive 2 03/06/2011 06:21 PM


All times are GMT. The time now is 08:45 PM.


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