overlocus Posted August 19, 2018 Share Posted August 19, 2018 function createBackFire(theVeh, scx, scy, scz) local fireChords={} local dist = 0.04 for i = 1, 6 do local x, y, z = getPositionFromElementOffset(theVeh,scx,scy-dist,scz) fireChords[i]= {pX = x, pY = y, pZ = z} dist = dist + 0.2 end local x,y,z = getPositionFromElementOffset(theVeh,scx,scy,scz) local x2,y2,z2 = getPositionFromElementOffset(theVeh,scx,0,scz) local v1, v2, v3 = getVectors(x,y,z, x2,y2,z2) for i, val in ipairs(fireChords) do fxAddGunshot(val.pX,val.pY,val.pZ, v1,v2,v3, true) fxAddGunshot(val.pX,val.pY,val.pZ, v1+1.5,v2,v3, true) fxAddGunshot(val.pX,val.pY,val.pZ, v1-1.5,v2,v3, true) fxAddGunshot(val.pX,val.pY,val.pZ, v1,v2,v3+0.8, true) fxAddGunshot(val.pX,val.pY,val.pZ, v1,v2,v3-0.8, true) fxAddGunshot(val.pX,val.pY,val.pZ, v1,v2+1,v3+0.8, true) fxAddGunshot(val.pX,val.pY,val.pZ, v1,v2+2,v3+0.8, true) fxAddGunshot(val.pX,val.pY,val.pZ, v1,v2+10,v3+0.8, true) fxAddGunshot(val.pX,val.pY,val.pZ, v1,v2-10,v3+0.8, true) fxAddGunshot(val.pX,val.pY,val.pZ, v1,v2-2,v3+0.8, true) fxAddGunshot(val.pX,val.pY,val.pZ, v1,v2-1,v3+0.8, true) end local s = playSound3D("sound/backfire2.wav", x,y,z, false) setSoundMaxDistance( s, 80 ) setSoundVolume(s, 0.5) I want the code to repeat itself randomly Link to comment
Keiichi1 Posted August 19, 2018 Share Posted August 19, 2018 Set a random interval timer. setTimer math.random Link to comment
JeViCo Posted August 19, 2018 Share Posted August 19, 2018 replace local s = playSound3D("sound/backfire2.wav", x,y,z, false) with local s = playSound3D("sound/backfire2.wav", x,y,z, true) but it will play until you stop it with stopSound or destroyElement 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