AMARANT Posted May 9, 2012 Posted May 9, 2012 Hello there. I wanted to make something like a stun when you hit player with a cop nightstick. But I came across a very annoying bug. The event "onPlayerDamage" doesn't work correctly. I just made a check that you use the nightstick and a debug message showing that the event triggered. But it doesn't always work and while a source is on the run it won't trigger at all! I provided my simple script and hope you can help me with this issue. function NightstickStun ( attacker, weapon, bodypart, loss ) if ( weapon == 3 ) then outputChatBox("HIT!",getRootElement(),0,255,255) end end addEventHandler ( "onPlayerDamage", getRootElement (), NightstickStun )
Moderators IIYAMA Posted May 9, 2012 Moderators Posted May 9, 2012 1 > did you start the resource? 2 > Serverside event < it is server side just like headshot (looks like 90% at it) 3 > debugscript. Any thing? 4 > meta ???? Check it all pls, bevore you are going to say the code is wrong.
TAPL Posted May 9, 2012 Posted May 9, 2012 This is just a simple code that doesn't have any error it's just will out put 'HIT!' for everyone whenever any player attacks other player with nightstick.
AMARANT Posted May 9, 2012 Author Posted May 9, 2012 1 > did you start the resource?2 > Serverside event < it is server side just like headshot (looks like 90% at it) 3 > debugscript. Any thing? 4 > meta ???? Check it all pls, bevore you are going to say the code is wrong. Of course, I checked that all because this simple code is a part of the huge police system script. And it works with about 90% chance just like TAPL said. The problem is that why doesn't it work with 100% chance and why doesn't it work when a source is moving?
Callum Posted May 9, 2012 Posted May 9, 2012 This is known as desynchronization. When a player is running on your screen, the position and rotation aren't always 100% correct (especially if you or the target has a slow Internet connection and/or computer). Thus hitting them doesn't actually trigger the event, as you never hit them according to the server.
AMARANT Posted May 9, 2012 Author Posted May 9, 2012 It's very sad I suppose that it will happen even if I do it client-side, won't it?
Moderators IIYAMA Posted May 9, 2012 Moderators Posted May 9, 2012 It's very sad I suppose that it will happen even if I do it client-side, won't it? Yes client side would be better. Server side will only calculate this as a hit when it is visible at server side.
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