Jump to content

sound sync


Xwad

Recommended Posts

the sync is not working:/ i use root, i dont know why its not working.. I thought root contains the sync

function sniper_sound(weaponID) 
local muzzleX, muzzleY, muzzleZ = getPedWeaponMuzzlePosition(source) 
    if weaponID == 34 then  
    local id = getElementModel ( localPlayer )  
    if id == 23 then 
        sound_shoot = playSound3D("files/sounds/sniper_kar98.wav", muzzleX, muzzleY, muzzleZ, false) 
        setSoundMaxDistance(sound_shoot, 100) 
        setTimer ( function() 
        local sound_reload = playSound3D("files/sounds/reload.wav", muzzleX, muzzleY, muzzleZ, false) 
        setSoundMaxDistance(sound_reload, 10) 
        setSoundVolume(sound_reload, 0.12) 
        end, 500, 1 ) 
    elseif id == 103 then 
        sound_shoot2 = playSound3D("files/sounds/sniper_springfield.wav", muzzleX, muzzleY, muzzleZ, false) 
        setSoundMaxDistance(sound_shoot2, 100) 
        setTimer ( function() 
        local sound_reload = playSound3D("files/sounds/reload.wav", muzzleX, muzzleY, muzzleZ, false) 
        setSoundMaxDistance(sound_reload, 10) 
        setSoundVolume(sound_reload, 0.12) 
        end, 500, 1 ) 
    end 
  end 
end 
addEventHandler("onClientPlayerWeaponFire", root, sniper_sound) 

Link to comment

I have one more problem with sync: now this time its with bone_attach.. the problem is with the attachElementToBone. Other players can't see the object on the player, only the localPlayer can see it

  
function custom_sniper() 
       local id = getElementModel ( source )  
       if id == 23 then 
       local PedWeapon = getPedWeapon(localPlayer) 
       if (PedWeapon == 34) then 
       sniper = createObject(1853,-1317,-167,14.14) 
       exports.bone_attach:attachElementToBone(sniper2,localPlayer,12,0,0,0,0,-90,0) 
       outputChatBox("sniper created", 255, 255, 0) 
       end 
       end 
       if id == 23 then 
       local PedWeapon = getPedWeapon(localPlayer) 
       if not (PedWeapon == 34) then 
       destroyElement(sniper2) 
       outputChatBox("sniper destroyed", 255, 0, 0) 
    end 
  end 
end 
addEventHandler ( "onClientPlayerWeaponSwitch", getRootElement(), custom_sniper ) 
  

Link to comment

this is not working too:/ pls help!

client

--SNIPER 
function custom_sniper() 
       local id = getElementModel ( source )  
       if id == 23 then 
       local PedWeapon = getPedWeapon(localPlayer) 
       if (PedWeapon == 34) then 
       sniper = createObject(1853,-1317,-167,14.14) 
       exports.bone_attach:attachElementToBone(sniper,localPlayer,12,0,0,0,0,-90,0) 
       outputChatBox("sniper create", 255, 255, 0) 
       end 
       end 
       if id == 23 then 
       local PedWeapon = getPedWeapon(localPlayer) 
       if not (PedWeapon == 34) then 
       destroyElement(sniper) 
       outputChatBox("sniper destroyed", 255, 0, 0) 
    end 
  end 
end 
addEvent( "client", true ) 
addEventHandler( "client", root, custom_sniper ) 

server

function server () 
triggerClientEvent ( root, "client", source) 
end 
addEvent( "server", true ) 
addEventHandler( "server", resourceRoot, server ) 
  

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...