Xeonmeister Posted June 22, 2016 Posted June 22, 2016 Hello everyone! So i started to make a script which does the following: Basically it is a weapon sound system. It plays a normal sound for the player who shot, and plays a 3d sound for everone except the local player (who shot). It plays the normal sound fine, but the evenet is not triggered for everyone for some reason, however, it is triggered for the local player. Why isn't it triggered for everyone? addEventHandler("onClientPlayerWeaponFire", localPlayer, function(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement) local x, y, z = getElementPosition(localPlayer) local pplayer = localPlayer triggerEvent("weaponSound", getRootElement(), weapon, x, y, z, pplayer) playSound("sounds/"..weapon..".wav") end) addEvent("weaponSound", true) addEventHandler("weaponSound", getRootElement(), function(weapon, x, y, z, pplayer) if pplayer ~= localPlayer then local sound = playSound3D("sounds/"..weapon..".wav", x, y, z) setSoundMaxDistance(sound, 300) end end)
TAPL Posted June 22, 2016 Posted June 22, 2016 addEventHandler("onClientPlayerWeaponFire", root, function(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement) if source == localPlayer then playSound("sounds/"..weapon..".wav") else local x, y, z = getElementPosition(source) local sound = playSound3D("sounds/"..weapon..".wav", x, y, z) setSoundMaxDistance(sound, 300) end end)
#RooTs Posted June 22, 2016 Posted June 22, 2016 addEventHandler("onClientPlayerWeaponFire", root, function(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement) if source == localPlayer then playSound("sounds/"..weapon..".wav") else local x, y, z = getElementPosition(source) local sound = playSound3D("sounds/"..weapon..".wav", x, y, z) setSoundMaxDistance(sound, 300) end end) local x, y, z = getElementPosition(source) @TAPL, source not work in ClientSide
</Mr.Tn6eL> Posted June 22, 2016 Posted June 22, 2016 addEventHandler("onClientPlayerWeaponFire", root, function(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement) if source == localPlayer then playSound("sounds/"..weapon..".wav") else local x, y, z = getElementPosition(source) local sound = playSound3D("sounds/"..weapon..".wav", x, y, z) setSoundMaxDistance(sound, 300) end end) local x, y, z = getElementPosition(source) @TAPL, source not work in ClientSide source work in client & server SourceThe source of this event is the streamed in player who fired the weapon.
ErHaBe Posted July 15, 2016 Posted July 15, 2016 addEventHandler("onClientPlayerWeaponFire", root, function(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement) if source == localPlayer then playSound("sounds/"..weapon..".wav") else local x, y, z = getElementPosition(source) local sound = playSound3D("sounds/"..weapon..".wav", x, y, z) setSoundMaxDistance(sound, 300) end end) local x, y, z = getElementPosition(source) @TAPL, source not work in ClientSide Shared function
TAPL Posted July 15, 2016 Posted July 15, 2016 addEventHandler("onClientPlayerWeaponFire", root, function(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement) if source == localPlayer then playSound("sounds/"..weapon..".wav") else local x, y, z = getElementPosition(source) local sound = playSound3D("sounds/"..weapon..".wav", x, y, z) setSoundMaxDistance(sound, 300) end end) local x, y, z = getElementPosition(source) @TAPL, source not work in ClientSide Shared function So you replied to a topic after 23 days of the last reply to say "source = function"?
ErHaBe Posted July 16, 2016 Posted July 16, 2016 What problem code? TAPL addEvent("n2",true) addEventHandler("n2",root, function () setPedAnimation ( plr, "CRACK", "crckidle3") triggerClientEvent(source,"c2",source) end) addCommandHandler("nmoney",root,)
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