Author Topic: RegisteredUsers.xml from Verlihub  (Read 2199 times)

0 Members and 1 Guest are viewing this topic.

Offline ATAG

  • Scripter
  • Double Ace
  • ******
  • Posts: 111
  • Karma: +14/-0
  • secret things
    • Metin2 Hungarian Forum
RegisteredUsers.xml from Verlihub
« on: 12 May, 2009, 21:57:29 »
Code: [Select]
-- vh_reg2px.lua v0.01
-- by ATAG @ 2009.05.12.

-- ########################################
-- THIS IS A VERLIHUB SCRIPT! DO NOT USE IT ON PTOKAX HUB!
-- ########################################

classtable = {
[1] = 3,
[2] = 2,
[3] = 1,
[4] = 1,
[5] = 1,
[10] = 0
}

regusers = { }

function Main()
local f, e = io.open( ".verlihub/RegisteredUsers.xml" )
if f then
local reg = {}
for line in f:lines() do
local _,_, var, val  = string.find( line, ".*<(.-)>([^<]*)</%1>" )
if var then
if var == "Profile" then
regusers[ reg["Nick"] ] = { reg["Password"] , val }
reg = {}
else
reg[ var ] = val
end
end
end
end
end

temp = {}

function VH_OnParsedMsgAny( sNick, sData )
if string.sub( sData, 1, 7 ) == "$MyPass" then
temp[ sNick ] = string.sub( sData, 9 )
end
return 1
end

function VH_OnUserLogin( sNick )
if temp[ sNick ] then
local res, class = VH:GetUserClass( sNick )
if res then
class = tonumber( class )
if classtable[ class ] then
regusers[ sNick ] = { temp[ sNick ], classtable[ class ] }
end
end
temp[ sNick ] = nil
end
return 1
end

function UnLoad()
local f, e = io.open( ".verlihub/RegisteredUsers.xml", "w+" )
if f then
f:write("<?xml version=\"1.0\" encoding=\"windows-1252\" standalone=\"yes\" ?>\n")
f:write("<RegisteredUsers>\n")
for nick in pairs( regusers ) do
f:write("\t<RegisteredUser>\n"..
"\t\t<Nick>" .. nick .. "</Nick>\n"..
"\t\t<Password>" .. ( regusers[ nick ][1] or "" ) .."</Password>\n"..
"\t\t<Profile>" .. ( regusers[ nick ][2] or "3" ) .. "</Profile>\n"..
"\t</RegisteredUser>\n"
)
end
f:write("</RegisteredUsers>")
f:flush()
f:close()
end
end
« Last Edit: 13 May, 2009, 19:00:14 by ATAG »

PtokaX forum

RegisteredUsers.xml from Verlihub
« on: 12 May, 2009, 21:57:29 »