IS4Code / YSF

YSF Server Functions
Other
98 stars 34 forks source link

OnPlayerStatsAndWeaponsUpdate "Bugfix" #123

Closed tr1xy closed 2 years ago

tr1xy commented 4 years ago

Hello everyone! I had to split OnPlayerStatsAndWeaponsUpdate into OnPlayerStatsUpdate and OnPlayerWeaponsUpdate update because one simple reason:

OnPlayerStatsAndWeaponsUpdate was called only for CSAMPFunctions::Packet_StatsUpdate(p); because that packet is sent by the client twice in a second (therefore Weapons and Stats shouldn't be one because of the Packet_StatsUpdate call frequency)

Please merge as this affects the server performance too 👍 @IllidanS4

n0bodysec commented 4 years ago

OnPlayerStatsAndWeaponsUpdate gets called in ID_STATS_UPDATE and ID_WEAPONS_UPDATE packets (at least on my setup), so I don't think it's a issue/bug at all.

About the performance, it gets better performance for checking ID_WEAPONS_UPDATE only.

tr1xy commented 4 years ago

Yep, you're right but I think that ID_WEAPONS_UPDATE gets suppressed as ID_STATS_UPDATE is called for each stats update (which includes Drunk level changes which is equal to FPS change)

n0bodysec commented 4 years ago

What do you mean by "suppressed"? Both packets gets processed to update their own data.

Of course that OnPlayerStatsAndWeaponsUpdate gets more calls from ID_STATS_UPDATE that from ID_WEAPONS_UPDATE, but it gets called in both anyway.

Again, the only reason to merge this is to get "better performance" on ID_WEAPONS_UPDATE checks. (It's ok from my point of view).

tr1xy commented 4 years ago

What do you mean by "suppressed"? Both packets gets processed to update their own data.

Of course that OnPlayerStatsAndWeaponsUpdate gets more calls from ID_STATS_UPDATE that from ID_WEAPONS_UPDATE, but it gets called in both anyway.

Again, the only reason to merge this is to get "better performance" on ID_WEAPONS_UPDATE checks. (It's ok from my point of view).

Yeah, I forgot that WEAPON packet is called for each weapon shot, mb

NexiusTailer commented 2 years ago

I think you should add all the other parameters, not only playerid in both cases. Take a look at these articles: https://github.com/katursis/Pawn.RakNet/wiki/WeaponsUpdate https://github.com/katursis/Pawn.RakNet/wiki/StatsUpdate

These events have a lot more useful data which can be passed to our callbacks.