@Omega
function explode(e, sep) local result = {} e:gsub("[^".. sep .."]+", function(s) table.insert(result, s:match("^%s*(.-)%s*$")) end) return result end local file = io.open(dir, "r") local tmp = explode(file:read("*all"), "=") if tmp[1] == "rateExperience" then tmp[2] = 30 file:close() end local write = io.open(dir, "w+") write:write(table.concat(tmp, "/n"))
Obrigado por responder mas... a onde vai a configuração de hora e minuto? Abraço ![]()
@Desculpa não tinha lido tudo...hahahaha' Irei testar aqui. ![]()
Pode haver erros mas ai você me avisa, o único erro que eu penso e que seja "rateExperience = val" em vez de "rateExperience=val" ai não vai achar o valor.
function setNewExp(value) local function explode(e, sep) local result = {} e:gsub("[^".. sep .."]+", function(s) table.insert(result, s:match("^%s*(.-)%s*$")) end) return result end local file = io.open("config.lua", "r") local tmp = explode(file:read("*all"), "=") if tmp[1] == "rateExperience" then tmp[2] = value file:close() end local wr = io.open(dir, "w+") wr:write(table.concat(tmp, "/n")) end function onThink() local hours = { ["12:30"] = 30, ["16:30"] = 15 } local newExp = hours[os.date("%H:%M")] if(newExp) then setNewExp(newExp) broadcastMessage("Exp has been updated to " .. newExp .. "", 25) end return true endDeu esse erro mano =/
[Error - GlobalEvent Interface]data/globalevents/scripts/expcheck.lua:onThinkDescription:data/globalevents/scripts/expcheck.lua:16: bad argument #1 to 'open' (string expected, got nil)stack traceback:[C]: in function 'open'data/globalevents/scripts/expcheck.lua:16: in function 'setNewExp'data/globalevents/scripts/expcheck.lua:30: in function <data/globalevents/scripts/expcheck.lua:20>[Error - GlobalEvents::think] Couldn't execute event: checkConsegui arrumar aqui..
REP+ a todos que me ajudram
Valeu mesmo...



info
Grupo: Marquês
Registrado: 02/08/12
Posts: 1k
Reputação: +234
Char no Tibia: Maurolkit
Pode haver erros mas ai você me avisa, o único erro que eu penso e que seja "rateExperience = val" em vez de "rateExperience=val" ai não vai achar o valor.
function setNewExp(value) local function explode(e, sep) local result = {} e:gsub("[^".. sep .."]+", function(s) table.insert(result, s:match("^%s*(.-)%s*$")) end) return result end local file = io.open("config.lua", "r") local tmp = explode(file:read("*all"), "=") if tmp[1] == "rateExperience" then tmp[2] = value file:close() end local wr = io.open(dir, "w+") wr:write(table.concat(tmp, "/n")) end function onThink() local hours = { ["12:30"] = 30, ["16:30"] = 15 } local newExp = hours[os.date("%H:%M")] if(newExp) then setNewExp(newExp) broadcastMessage("Exp has been updated to " .. newExp .. "", 25) end return true endEditado Outubro 23 por Skymagnum