is it possible to use command handler to change a variable in a particular script?
For example (in sound.script)
SoundEnabled = true
function sound()
if SoundEnabled then
[some code]
end
AddEventHandler(......)
now this function is my disable and enable sound function:
function disablePlayLocalMusic(playerSource)
if (playerSource) then
if(SoundEnabled) then
SoundEnabled = false
outputChatBox ( "Ambience Sounds Disabled!", playerSource )
end
elseif not (GroveEnable) then
outputChatBox ( "Ambience Sounds Already Disabled!", playerSource )
end
end
end
addCommandHandler ( "OffAmbience", disablePlayLocalMusic)
function enablePlayLocalMusic(playerSource)
if (playerSource) then
if(SoundEnabled) then
outputChatBox ( "Ambience Sounds Already Enabled!", playerSource )
end
elseif not (SoundEnabled) then
SoundEnabled= true
outputChatBox ( "Ambience Sounds Enabled!", playerSource )
end
end
end
addCommandHandler ( "OnAmbience", enablePlayLocalMusic)
I want to use them to change soundEnabled to either true or false
However in the game when I typed /OnAmbience or /OffAmbience, nothing happens and the function sound() also stops working. What did I do wrong? or does this method even work?