READ THE RULES
0 Members and 1 Guest are viewing this topic.
local line = file:read() curUser:SendPM(bot,"\r\n"..border.."\r\n\t\t\tNEW MESSAGES WHILE YOU WERE OFFLINE: (TOTALLY: "..offlineops[curUser.sName]["settings"]["msgs"]..")\r\n"..border.."\r\n") while line do curUser:SendPM(bot,line) line = file:read() end
function OpDisconnected(curUser) if offlineops[curUser.sName] ~= nil then if offlineops[curUser.sName] ~= nil then
bot = frmHub:GetHubBotName()offprefix = "[OP]"originalprefix = "[OP]"
Ehh, you've right... Before i ended the script there was an other value in the table: on with value true or false bool. I removed it, because that was unnecessary, but on the code other parts i was careless, and i didn't remove all. I will correct it a.s.a.p., thanks the report. The serialize function is really unknown for me, and this version works well enough to me. So, you want to change the prefix while script running? That's possible, easy to do. And why i have to put the commands into a table? Why this not good?
Commands in a table wouldn't be better too?Less mem usage Roll Eyes
Less memory I made all command to local vars, and not global... If i make a global table, it will use more memory
By the way could you say me what this serialize function is doing? I looked for that, and it handle files also... Please say me more about this, and i will build in it to my script. Thanks
tOffline = { [Nick Name] = { [email] = user.sEmail [description] = user.sDescription [awaymsg] = message }}
Commands in a table wouldn't be better too?Less mem usage
function ChatArrival(curUser, data) local data = string.sub(data, 1, -2) local s,e,cmd = string.find(data, "%b<>%s+[%!%+](%S+)") -- Find commands if cmd then -- Found command cmd = string.lower(cmd) local tCmds = { -- Here is all commands ["help"] = function(curUser, data) local Profile = GetProfileName(curUser.iProfile) if curUser.iProfile == -1 then Profile = "User" end local f = io.input("MadSecurity/Txt/Help" ..Profile.. ".txt") local line = string.gsub(f:read("*all"), "\n", "\r\n")f:close() curUser:SendPM(tConfig.Bot.Name, line) return 1 end, ["rules"] = function(curUser, data) local f = io.input("MadSecurity/Txt/Rules.txt") local line = string.gsub(f:read("*all"), "\n", "\r\n")f:close() curUser:SendPM(tConfig.Bot.Name, line) return 1 end, } if tCmds[cmd] then -- If the command was in table return tCmds[cmd](curUser, data) -- Then execute it... end
Quote from: Markitos on June 24, 2006, 06:18:22 pmCommands in a table wouldn't be better too?Less mem usage What he means is that he thinks you should do like this,Code: [Select]function ChatArrival(curUser, data) local data = string.sub(data, 1, -2) local s,e,cmd = string.find(data, "%b<>%s+[%!%+](%S+)") -- Find commands if cmd then -- Found command cmd = string.lower(cmd) local tCmds = { -- Here is all commands ["help"] = function(curUser, data) local Profile = GetProfileName(curUser.iProfile) if curUser.iProfile == -1 then Profile = "User" end local f = io.input("MadSecurity/Txt/Help" ..Profile.. ".txt") local line = string.gsub(f:read("*all"), "\n", "\r\n")f:close() curUser:SendPM(tConfig.Bot.Name, line) return 1 end, ["rules"] = function(curUser, data) local f = io.input("MadSecurity/Txt/Rules.txt") local line = string.gsub(f:read("*all"), "\n", "\r\n")f:close() curUser:SendPM(tConfig.Bot.Name, line) return 1 end, } if tCmds[cmd] then -- If the command was in table return tCmds[cmd](curUser, data) -- Then execute it... end
You could format format the user settings file in a more formal way likeCode: [Select]tOffline = { [Nick Name] = { [email] = user.sEmail [description] = user.sDescription [awaymsg] = message }}instead of Estranho_para_ti¤y@blabla.com¤0¤15¤Ba Bye