Jump to content

A little problem with an if statement.


-Blaze-

Recommended Posts

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!

Link to comment

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.

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...