Log in

View Full Version : Update a variable inside a script



cornex
07-02-2015, 04:47 PM
Hello, I tried to update a variable in a script for a while now. Seems not to work the way I do it, could someone help me?
What I try to do is, when you say "/start" in the custom channel, it updates the status variable to be true, so we know that the script is started.
But yeah, it do reset once the script reloop.. please, any help :D


local status = false

local myCustomChannel = Channel("Custom Channel", mySpeakCallback, myCloseCallback)
myCustomChannel:SendOrangeMessage("umas", "Welcome to Custom Channel.")

function mySpeakCallback(channel, text)

channel:SendYellowMessage(Self.Name(), text)

if (text:lower() == "/start") then
channel:SendOrangeMessage("Script has been started")
local status = true
end

end

function myCloseCallback(channel)
print(channel:Name().." was closed.")
end

Module.New("kkwp", function(module)

if status then
for _, creature in ipairs(Self.GetSpectators(false)) do

-- Make a check if there is any player on the screen
if creature:isPlayer() then
print([[
We have no players on screen, proceed.]])
end

end
end

Module:Delay(500)
end)

cornex
07-02-2015, 05:14 PM
Thanks to my brotha this is solved, need to change local status = to just status =