~DarkRacer~ Posted March 27, 2014 Share Posted March 27, 2014 onClientPlayerDamage doesn't get triggered if the weapon was a spraycan! it was working fine but suddenly it became untriggerable for the spraycan weapon... i tried it on other weapons and it works but on spraycan it won't work. addEventHandler('onClientPlayerDamage', getRootElement(), function(attacker, weapon, bodypart ,loss) outputChatBox('1') end ) is this a MTA bug or what? please try it on your local server and tell me the result.. because my mind will explode soon ! Link to comment
Moderators IIYAMA Posted March 27, 2014 Moderators Share Posted March 27, 2014 You sure there are no events get cancelled? (in another script) Link to comment
~DarkRacer~ Posted March 27, 2014 Author Share Posted March 27, 2014 You sure there are no events get cancelled? (in another script) Never, its working fine but if the attacker's weapon is spraycan it doesn't trigger. Edit: Please try it on your local server and tell my the result cause i test it on my brother's pc and still the same. Link to comment
Moderators IIYAMA Posted March 27, 2014 Moderators Share Posted March 27, 2014 ok very strange. You can report the bug if you want. https://bugs.multitheftauto.com/my_view_page.php But to solve your problem, you can use "onClientPlayerWeaponFire" + getDistanceBetweenPoints3D(because of the strange weapon range) Link to comment
~DarkRacer~ Posted March 27, 2014 Author Share Posted March 27, 2014 ok very strange.You can report the bug if you want. https://bugs.multitheftauto.com/my_view_page.php But to solve your problem, you can use "onClientPlayerWeaponFire" + getDistanceBetweenPoints3D(because of the strange weapon range) as for the report.. (EDIT : NVM) and as for the solution.. i don't understand, i'll be glad if you make it more clear for me and thank you. Link to comment
Moderators IIYAMA Posted March 27, 2014 Moderators Share Posted March 27, 2014 addEventHandler("onClientPlayerWeaponFire", root, function (weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement, startX, startY, startZ) local attacker = source if weapon == 41 then if getDistanceBetweenPoints3D (hitX, hitY, hitZ,startX, startY, startZ) < 3 then -- anti bug outputChatBox('spraycan hit') end else outputChatBox('1') end end) Or you can use:(this event can cancel the damage/animation) addEventHandler("onClientPlayerChoke", root, function (weapon,attacker) if weapon == 41 then outputChatBox("hit with spraycan > onClientPlayerChoke ") end end) Link to comment
~DarkRacer~ Posted March 27, 2014 Author Share Posted March 27, 2014 addEventHandler("onClientPlayerWeaponFire", root, function (weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement, startX, startY, startZ) local attacker = source if weapon == 41 then if getDistanceBetweenPoints3D (hitX, hitY, hitZ,startX, startY, startZ) < 3 then -- anti bug outputChatBox('spraycan hit') end else outputChatBox('1') end end) Thanks you now i get it. but the thing is .. the source get damaged and cancelEvent() has no effect. what's the solution for that? Link to comment
Moderators IIYAMA Posted March 27, 2014 Moderators Share Posted March 27, 2014 By using the second example + cancelEvent() of my previous post. addEventHandler("onClientPlayerChoke", root, function (weapon,attacker) if weapon == 41 then outputChatBox("hit with spraycan > onClientPlayerChoke ") cancelEvent() end end) You have to read the information better from the event's. Only events that have information about cancelling events can do that, others cannot. Link to comment
~DarkRacer~ Posted March 27, 2014 Author Share Posted March 27, 2014 By using the second example + cancelEvent() of my previous post. addEventHandler("onClientPlayerChoke", root, function (weapon,attacker) if weapon == 41 then outputChatBox("hit with spraycan > onClientPlayerChoke ") cancelEvent() end end) You have to read the information better from the event's. Only events that have information about cancelling events can do that, others cannot. your code prevent the player from doing the action but it still getting damage! Link to comment
WhoAmI Posted March 27, 2014 Share Posted March 27, 2014 Check this out addEventHandler ( "onClientPlayerChoke", localPlayer, function ( weapon ) if ( source ~= localPlayer ) then return end if ( weapon == 41 ) then cancelEvent() end end ) 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