ElexTron Software Posted July 28, 2010 Share Posted July 28, 2010 Hello! I am trying to make it so that: A) Every time a player fires a Silenced Pistol, a Satchel is placed at the pistol's target. B) Every time the Satchel Detonator is used, a detonation sound is played. I have made a script for this, but it is not working: client.lua -- This function gets triggered everytime player shoots. function onClientPlayerWeaponFireFunc(weapon,ammo,ammoInClip,hitX,hitY,hitZ,hitElement) if weapon == 23 then -- If Silenced Pistol is Used... local aimSpot = getPedTarget(getLocalPlayer()) if aimSpot then createProjectile(getLocalPlayer(),39,getElementPosition(aimSpot)) then -- Then Create a Satchel at Target if Targeting outputChatBox("Satchel Created", source) else outputChatBox("no target!", source) end end if weapon == 40 then -- If Satchel Detonator is Used... local satchSnd = playSound("detonate.mp3") -- Play Detonation Sound end end -- Don't forget to add the onClientPlayerWeaponFireFunc function as a handler for onClientPlayerWeaponFire. addEventHandler("onClientPlayerWeaponFire", getLocalPlayer(), onClientPlayerWeaponFireFunc) I have a folder named modweapons where I put my three files in it; the script above, detonate.mp3, and this meta.xml file: <meta> <info type="script" author="Cecil G. Bowen" Version="1.0" name="ModWeapons" /> <script src="script.lua" type="client" /> <file src="detonate.mp3" /> </meta> Help would be really appreciated! Thanks in advance! Link to comment
dzek (varez) Posted July 28, 2010 Share Posted July 28, 2010 I have made a script for this, but it is not working: what exactly is not working? any errors? Link to comment
ElexTron Software Posted July 28, 2010 Author Share Posted July 28, 2010 Well when I run it and start the resource no message is displayed whatsoever, whether a Satchel was placed or not, and no sound is played when I use the Satchel Detonator. EDIT: But no, no errors show up on the Console. Link to comment
Slothman Posted July 28, 2010 Share Posted July 28, 2010 there is some redundancy to your script, using OnClientPlayerWeaponFire alows you with args for weapon, ammo, ammoInClip, hitX, hitY, hitZ, and hitElement. so no need to get target since its already supplied xyz coords and if you hit an element it gives you the element. Link to comment
ElexTron Software Posted July 28, 2010 Author Share Posted July 28, 2010 Thanks but that still doesn't solve the problem. Link to comment
ElexTron Software Posted July 28, 2010 Author Share Posted July 28, 2010 Okay I just edited the code a little and this works, though it is more limited: function onClientPlayerWeaponFireFunc(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement ) if weapon == 23 and getElementType(hitElement)=="vehicle" then -- If the player shoots with a minigun, and hits another player... createProjectile(getLocalPlayer(),39,hitX,hitY,hitZ) end end -- Add this as a handler so that the function will be triggered every time the local player fires. addEventHandler ( "onClientPlayerWeaponFire", getLocalPlayer(), onClientPlayerWeaponFireFunc ) 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