How to go about getting the value of a math_counter from a script?
2 replies, posted
Good Afternoon,
I was trying to make a script for my map that would be able to take a value of a math_counter named "TestEnt" and print it, I have everything working except that no matter how I try to get the value it just returns nil, I was told to just check for differences when it changes its values, but I gave up after trying for an hour to get it working. Any help is appreciated.
My Code:
curTest = 0
function tsend()
BroadcastMsg(Color(255,0,0),tostring(curTest))
end
function getTest(ent, key, value)
if ent:GetName() == "Temperature" then
BroadcastMsg(Color(255,0,0),"Entity Temperature Changed!")
curTest = value
end
end
BroadcastMsg(Color(255,0,0),"Temperature Entity Found!")
timer.Create("testsend", 10, 0, tsend)
hook.Add("EntityKeyValue","GetTest",getTest)
So, you say it's named "TestEnt", but you check for "Temperature". Right now you change your value each time any keyvalue was changed, not only one you need. Check for key name and then update its value.
Thanks for pointing out the temperature part, but it still does not work. I believe the issue is that the hook isnt being called at all, since the chat keeps getting "0" (default curTest value) printed to it, wouldnt it change to whatever the last changed value was in the math_counter?
Sorry, you need to Log In to post a reply to this thread.