Hello Hydra,
do you know about the onSettingChange serverside event? Whenever you change the outputNewsTimer setting, either through the admin panel or programmatically inside of your own resource, this event will be triggered with the "outputNewsTimer" string as setting name, the old and new values. Inside of the event handler you should change the timer period by killing the old timer and setting a new one using the same closure/function (showMessages).
You are saying that it does not work "when I change the values". I assume that you do not mean that the actual script stops working, but that you are not seeing the intended change in resource behaviour. But in the script that you have provided you do not command the Lua environment to perform the change so if you do not use the event handler that I have recommended it is working without bugs but not like you imagined it.