PtokaX forum

Development Section => Your Developing Problems => Topic started by: NightLitch on 17 October, 2003, 14:57:47

Title: Hopping for some help here... plz...
Post by: NightLitch on 17 October, 2003, 14:57:47
I have made an function that checks users password in RegisteredUsers.dat...

Now my problem... When I have regged a NEW user, and want to view that users name & password it doesn't show'n... why...

have tried with the

dofile(file)

but doesn't work... What is the solusion???

Have It loaded into a table...

How to reread the file.. help...

Cause it didn't work when using the same:

LoadRegFile(table,file) in Main in the function... nothing updated... :-(

plz help me out...

/NightLitch
Title:
Post by: pHaTTy on 17 October, 2003, 15:16:40
can you show us an example, im quite confused
Title:
Post by: OpiumVolage on 17 October, 2003, 15:31:01
Copied from SlimV2 by trof. Take what you need in.

local temp={}
TextLoad("../RegisteredUsers.dat",temp)
for x=1,getn(temp) do s,e,name,pass,level=strfind(temp[x],"(.-)\124(.-)\124(.+)")
if (sarg==level) then showArray = { sName=name, sPass = pass, slevel = level}
if GetItemByName(name) then
botreplye=botreplye.."? "..name.." ? est en ligne\r\n"
else
botreplye=botreplye.."? "..name.." ? n'est pas en ligne.\r\n"
end
end
end

function TextLoad(file,array,text)
array[0]="" local x=0
readfrom(file)
    repeat if (text) then
      text=text..array[x].."\r\n"
    end
    x=x+1 array[x]=read() until (array[x]==nil)  
    readfrom()
    return text
end
Title:
Post by: plop on 17 October, 2003, 16:07:31
got the idea you want something like the next function does.
function FindPassword(nick)
   readfrom("../RegisteredUsers.dat")
   while 1 do
      local line = read()
      local who
      if line == nil then
         readfrom()
         break
      end
      s,e,who = strfind(line,"(.+)|.+|.+")
      if who == nick then
         s,e,password = strfind(line,".+|(.+)|.+")
         readfrom()
         break
      end
   end
   return password
end
if you use tables 2 store usersnames in you have 2 reload them everytime a user is added (for safety it's better 2 totaly flush the table, specialy if you remove a user) or add/remove the user 2/from the table.
if you want i can strip that part from a.i.bot for you.

plop
Title:
Post by: NightLitch on 17 October, 2003, 19:08:52
ThX Guys That was the help I was looking for... Gonna ask later if I don't get it work properly as I want it to...

/NightLitch

(Sry for my english)