-Blaze- Posted January 24, 2016 Posted January 24, 2016 hey guys , so i'm trying to make a script which outputs something when you hit a tree. addEventHandler("onClientPlayerWeaponFire", getLocalPlayer(), function( weap , ammo, ammoInClip, hitx, hity, hitz, hitElement, startX, startY, startZ) if weap == 6 then if ( getElementType ( hitElement ) == "object" ) and ( getElementModel ( hitElement ) == 686 ) then outputChatBox( "You have hit a tree" ) end end end ) normally the output should appear when you hit the tree with a shovel ( ID - 6 ) , but it doesn't happen so. However , if i remove the " if weap == 6 then " statement , it works for all weapons exept meelee weapons ( shovel , baseball bat etc.) How can i make it work for meelee weapons too? Thanks!
-Blaze- Posted January 24, 2016 Author Posted January 24, 2016 i just found a statement on the wiki saying - "This event is called when a player fires a weapon. This does not trigger for projectiles, melee weapons, or camera." so maybe this function doesen't work for meelee's. Is there any other way i can make it work? maybe some other function? i cant use colshapes because i have many trees/objects to check the hit on.
Castillo Posted January 24, 2016 Posted January 24, 2016 Indeed it doesn't work for melee weapons. You could bind the fire control to a function which checks if the player has a tree infront of him/her. https://wiki.multitheftauto.com/wiki/ProcessLineOfSight
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