Wisam Posted April 19, 2014 Share Posted April 19, 2014 Hello.. I have here part of the map for assault gamemode and this script creates explosions when all the map objectives are finished and i added the sound function but.. the explosion works perfect but the sound dont play? please help me! i get this error: ERROR: radar\radarscript.lua:11: attempt to call global 'playSound' (a nil value) Script: (Client) function finished(objective) if (objective.id ~= "radar") then return end explosions() sound() end function sound() local sound = playSound("win.wav") setSoundVolume(sound, 1) -- set the sound volume to 50% end function explosions() createExplosion(-314.86804,1575.07471,76.80782, 7 ,true, 50.0,true ) end addEventHandler("onAssaultObjectiveReached",getRootElement(),finished) Link to comment
Saml1er Posted April 19, 2014 Share Posted April 19, 2014 playSound is a client side function. Link to comment
Wisam Posted April 19, 2014 Author Share Posted April 19, 2014 (edited) function finished(objective) if (objective.id ~= "radar") then return end sound() end function sound() local sound = playSound("win.wav") --Play wasted.mp3 from the sounds folder setSoundVolume(sound, 1) -- set the sound volume to 50% end addEventHandler("onAssaultObjectiveReached",getRootElement(),finished) I changed to this and i chnaged the script type to client in meta.xml file and didnt work Edited April 19, 2014 by Guest Link to comment
Saml1er Posted April 19, 2014 Share Posted April 19, 2014 Server side : function finished(objective) if (objective.id ~= "radar") then return end triggerClientEvent(root,"onAssaultObjectiveReached",root) end addEventHandler("onAssaultObjectiveReached",getRootElement(),finished) Client side: function finished(objective) if (objective.id ~= "radar") then return end sound() end function sound() local sound = playSound("win.wav") --Play wasted.mp3 from the sounds folder setRadioChannel(0) setSoundVolume(sound, 1) -- set the sound volume to 50% end addEvent("onAssaultObjectiveReached",true) addEventHandler("onAssaultObjectiveReached",getRootElement(),finished) Link to comment
Wisam Posted April 19, 2014 Author Share Posted April 19, 2014 Still the same error radar\radarscript.lua:11: attempt to call global 'playSound' (a nil value) Link to comment
TAPL Posted April 20, 2014 Share Posted April 20, 2014 That's because you put it in server side. This function is client side only, just make sure you have it client side in the meta. 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