Jump to content

meta settings problem


Hydra

Recommended Posts

So I made a setting in meta but it's not working when I change the values. What I did wrong?

meta.xml

    <settings>
		<setting name="*outputNewsTimer" value="10000"
			friendlyname="Messages Timer"
			group="General"
			accept="100,10000,50000"
			desc="set news timer" />
	</settings>

server.lua

local timerMessages = get("outputNewsTimer")

function showMessages()
   if timerMessages then
   local randomMsg = messages[math.random(1, #messages)]
   outputChatBox("#FFBB00[NEWS]: #FFFfff"..randomMsg.."", root, 255, 255, 255, true)
   else
   set("outputNewsTimer", 10000)
   end
end
setTimer(showMessages, timerMessages, 0)

 

Link to comment

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.

Edited by The_GTA
  • Like 1
Link to comment
34 minutes ago, The_GTA said:

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.

Thank you for the answer. I know about onSettingChange and I use it in the resource and it's working fine(I get the old and the new values). I will do what you said, killing the timer and make another one.

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