Scripting Moderators ds1-e Posted March 6, 2019 Scripting Moderators Share Posted March 6, 2019 Hey. Why script don't trigger server-side event onPlayerDamage? I decided to try server-side variation of this event. function onClientPlayerDamage(attacker, weapon, bodypart, loss) cancelEvent() end addEventHandler("onClientPlayerDamage", getLocalPlayer(), onClientPlayerDamage) function onPlayerDamage(attacker, weapon, bodypart, loss) outputDebugString("y") end addEventHandler("onPlayerDamage", getRootElement(), onPlayerDamage) Link to comment
Moderators IIYAMA Posted March 6, 2019 Moderators Share Posted March 6, 2019 (edited) because the MTA developers decided to consider cancelled events as 'it never happened`. onPayerDamage is a delayed/streamed version of onClientPlayerDamage Edited March 6, 2019 by IIYAMA 1 Link to comment
SaNoR Posted March 6, 2019 Share Posted March 6, 2019 (edited) https://wiki.multitheftauto.com/wiki/Scripting_Introduction#Clientside_and_Serverside_scripts Edited March 6, 2019 by SaNoR Link to comment
Scripting Moderators ds1-e Posted March 6, 2019 Author Scripting Moderators Share Posted March 6, 2019 2 hours ago, IIYAMA said: because the MTA developers decided to consider cancelled events as 'it never happened`. onPayerDamage is a delayed/streamed version of onClientPlayerDamage Oh well, so i should with onClientPlayerDamage? 1 Link to comment
Moderators IIYAMA Posted March 6, 2019 Moderators Share Posted March 6, 2019 (edited) function onClientPlayerDamage(...) cancelEvent() triggerLatentServerEvent("onPlayerDamage_", localPlayer, ...) end addEventHandler("onClientPlayerDamage", getLocalPlayer(), onClientPlayerDamage) addEvent("onPlayerDamage_", true)-- fake event onPlayerDamage_ = security addEventHandler("onPlayerDamage_", root, function (...) triggerEvent("onPlayerDamage", client, ...) end) It can be faked, but you might need to figure out a way to reduction data. @majqq For example buffer up till 100 ms, before sending the message This will reduce a lot in case of fire/minigun/Spraycan/Fire Extinguisher damage: (NOTE: surprisingly the minigun also fires a bullet every frame) How much reduction do you want for that scenario? Do the maths! local sendingDelay = 100 -- ms local fps = 60 local timeSlice = 1000 / fps local dataReduction = sendingDelay / timeSlice print("~" .. (dataReduction - 1 ) .. " x times LESS per " .. sendingDelay .. "ms") https://www.lua.org/cgi-bin/demo Edited March 6, 2019 by IIYAMA 1 Link to comment
Scripting Moderators ds1-e Posted March 7, 2019 Author Scripting Moderators Share Posted March 7, 2019 (edited) 9 hours ago, IIYAMA said: function onClientPlayerDamage(...) cancelEvent() triggerLatentServerEvent("onPlayerDamage_", localPlayer, ...) end addEventHandler("onClientPlayerDamage", getLocalPlayer(), onClientPlayerDamage) addEvent("onPlayerDamage_", true)-- fake event onPlayerDamage_ = security addEventHandler("onPlayerDamage_", root, function (...) triggerEvent("onPlayerDamage", client, ...) end) It can be faked, but you might need to figure out a way to reduction data. @majqq For example buffer up till 100 ms, before sending the message This will reduce a lot in case of fire/minigun/Spraycan/Fire Extinguisher damage: (NOTE: surprisingly the minigun also fires a bullet every frame) How much reduction do you want for that scenario? Do the maths! local sendingDelay = 100 -- ms local fps = 60 local timeSlice = 1000 / fps local dataReduction = sendingDelay / timeSlice print("~" .. (dataReduction - 1 ) .. " x times LESS per " .. sendingDelay .. "ms") https://www.lua.org/cgi-bin/demo That's cool, i'll try it out soon, also with your other solutions for sounds, explosion damage etc., ty I have used your way to synchronize data from server-side table -> client. For me works well, but until i'll finish my scripts, i am testing stuff alone. I am impatient to test how it will works with players on server I wanna exclude using elementData in my scripts (atleast in 99%), by creating temporary data system, within tables + trigger/triggerLatent. By the way as we are in topic about player damage. Using server-side variation of this event should improve hitboxes? Or it's about configuring it here - https://wiki.multitheftauto.com/wiki/Sync_interval_settings Bullet sync, latency reduction, threadnet, bandwidth_reduction, and also this? Edited March 7, 2019 by majqq Link to comment
Moderators IIYAMA Posted March 7, 2019 Moderators Share Posted March 7, 2019 As far as I know these settings are only used for sync element orientations. p.s you might also reduce data like this: function onClientPlayerDamage(attacker, weapon, bodypart, loss) local newHealth = getElementHealth(localPlayer) if newHealth > 0 then -- is not dead local oldHealth = newHealth + loss setElementHealth(localPlayer, oldHealth) -- reset else -- is dead cancelEvent() triggerLatentServerEvent("onPlayerDamage_", localPlayer, attacker, weapon, bodypart, loss) end end addEventHandler("onClientPlayerDamage", localPlayer, onClientPlayerDamage) p.s this might also be needed serverside. addEvent("onPlayerDamage", false) --remote disabled 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now