Author Topic: past in a script  (Read 1433 times)

0 Members and 1 Guest are viewing this topic.

Offline Themaster

  • Triple Ace
  • **
  • Posts: 204
  • Karma: +0/-0
past in a script
« on: 11 January, 2005, 08:09:01 »
have a little problem 2 past this script i made a standalone...
i can't get in 2 my script...

Code: [Select]
Bot = "UserLog"

UserInfo = {}

sOffline = "UserLog.lst"

-- New User Connected --
function NewUserConnected(user,data)
LogInfo(user)
end

function Main()
   frmHub:RegBot(Bot)
   LoadFromFile(sOffline)
end

function OnExit()
   SaveToFile(sOffline, UserInfo , "UserInfo")
end

function DataArrival(user, data)
if (strsub(data, 1, 1) == "<" ) then
      local data=strsub(data,1,strlen(data)-1)
      local _,_,cmd=strfind(data, "%b<>%s+(%S+)")
      local Commands = (UserCommands(user, data, cmd))
      return Commands
   elseif (strsub(data,1,4) == "$To:") then
      data = strsub(data,1,-2);
      local s,e,whoTo,from,arg = strfind(data,"%$To:%s+(%S+)%s+From:%s+(%S+)%s+%$%b<>%s+(.*)")
      local s,e,cmd = strfind(arg,"(%S+)")
      if (whoTo == Bot) then
      UserCommands(user,data,cmd)
      end
   end
end

function UserCommands(user,data,cmd)
   if cmd == "+log" then
     UserLog(user,data)
      return 1
   end
end

function UserLog(user,data)
   local s,e,arg = strfind(data,"%b<>%s+%S+%s+(%S+)")
  -- dofile(sOffline)
   if UserInfo[arg] then
   local msg = "\r\n\r\n"
      msg = msg .."\t"..strrep("-=",40).."\r\n"
      msg = msg .."\t\tThe user Name are:\t\t"..arg.."\r\n"
      msg = msg .."\t\tThe user Ip are:\t\t"..UserInfo[arg].IP.."\r\n"
      msg = msg .."\t\tThe user Profile are:\t\t"..UserInfo[arg].PROFILE.."\r\n"
      msg = msg .."\t\tUser are Seen:\t\t"..UserInfo[arg].Seen.."\r\n"
      msg = msg .."\t\tUserInfo :\t\t"..UserInfo[arg].MYINFO.."\r\n"
      msg = msg .."\r\n"
   user:SendPM(Bot, msg)
   end
end

-- Log Users Info --
function LogInfo(user)
-- LoadFromFile(sOffline)
   UserInfo[user.sName] = {["IP"]=user.sIP,["PROFILE"]=user.iProfile,["MYINFO"]=user.sMyInfoString,["Seen"]=date("%m/%d/%y"),}
   SaveToFile(sOffline, UserInfo , "UserInfo")
return 1
end

-- Serialize --
function Serialize(tTable, sTableName, sTab)
assert(tTable, "tTable equals nil");
assert(sTableName, "sTableName equals nil");
assert(type(tTable) == "table", "tTable must be a table!");
assert(type(sTableName) == "string", "sTableName must be a string!");
sTab = sTab or "";
sTmp = ""
sTmp = sTmp..sTab..sTableName.." = {\n"
for key, value in tTable do
local sKey = (type(key) == "string") and format("[%q]",key) or format("[%d]",key);
if(type(value) == "table") then
sTmp = sTmp..Serialize(value, sKey, sTab.."\t"); -- THE BUG WAS IN HERE
else
local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
end
sTmp = sTmp..",\n"
end
sTmp = sTmp..sTab.."}\r\n"
return sTmp
end

function SaveToFile(file , table , tablename)
writeto(file)
write(Serialize(table, tablename))
writeto()
end

function LoadFromFile(file)
readfrom(file)
dostring(read("*all"))
readfrom()
end

it work's as a stanalone..so please help me 2 fix it
peace out...and love to your all scripter..that do the hard work  :D And all thx to your all there are here 2 help!!! :]

blade.lir.dk

PtokaX forum

past in a script
« on: 11 January, 2005, 08:09:01 »