Ynhub Register to Px Register
 

Ynhub Register to Px Register

Started by rag3rac3r, 29 December, 2007, 20:50:54

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

rag3rac3r

This is a conversion of NightLitch original script to work with the new API. :)

Code: lua
--//----------------------------------------------------------------------------------------------->>
--//-- Convert YnHub Register to PtokaX
--//-- Originally created by NightLitch 2005-04-23
--//--
--//-- Converted to new Px LUA API 2007-12-29
--//--
--//-- To start the convert use specified command bellow in mainchat
--//-- Usage: #convert
--//----------------------------------------------------------------------------------------------->>
 
--//-- Specify the YnHub Profiles to work with your PtokaX Profiles
--//-- YnHub Profiles   =   PtokaX Profiles
ProfileRegistry = {
	["Owner"] = "Master",
	["SU"] = "Operator",
	["OP"] = "Operator",
	["VIP"] = "VIP",
	["Registered"] = "Reg",
	["Regular"] = "Reg",
}
 
--//-- Specify the Path to YnHubs Register File (Every \ needs to be written as \\)
FileName = "C:\\Path\\to\\YNHUB\\accounts.xml"
 
--//----------------------------------------------------------------------------------------------->>
--//-- Don't Edit
--//----------------------------------------------------------------------------------------------->>
function ConvertYnHubRegisterFile(sFilename)
    local curTable = {}
    local curNick = ""
    local Count = 0
    local hFile,sE = io.open(sFilename, "r")
	if hFile == nil then
		Core.SendToAll("Converter",tostring(hFile).." : "..tostring(sE))
	end
    for line in hFile:lines() do
        local s,e,col,value = string.find(line, "<(%S+)>(%S+)<")
        if col and value then
            if col == "Nick" and Count == 0 then
                curNick = value
                curTable[value] = {["Pass"] = "", ["Profile"] = ""}
                Count = Count + 1
            elseif col == "Pass" and Count == 1 then
                curTable[curNick].Pass = value
                Count = Count + 1
            elseif col == "Profile" and Count == 2 then
                curTable[curNick].Profile = value
                Count = 0
            end
        end
    end
    hFile:close()
    return curTable
end
 
function ChatArrival(sUser,sData)
	local _,_,Cmd = string.find(sData, "%b<>%s*(%S+)%|")
	if Cmd == "#convert" then
		Core.SendToNick(sUser.sNick,"<Converter> Start Converting YnHub register into PtokaX register")
		local T = ConvertYnHubRegisterFile(FileName)
		local t,g,b = 0,0,0
		for nick,_ in pairs(T) do
			t = t + 1
			if ProfileRegistry[T[nick].Profile] and ProfMan.GetProfile(ProfileRegistry[T[nick].Profile]) ~= nil then
				p = ProfMan.GetProfile(ProfileRegistry[T[nick].Profile])
				if p.iProfileNumber ~= -1 then
					g = g + 1
					RegMan.AddReg(nick,T[nick].Pass, p.iProfileNumber)
				else
					b = b + 1
				end
			else
				b = b +1
			end
		end
		Core.SendToNick(sUser.sNick,"<Converter> *** Total ( "..t.." ) registered user(s) is found in YnHub")
		Core.SendToNick(sUser.sNick,"<Converter> *** Total ( "..g.." ) user(s) are registered to PtokaX registry")
		Core.SendToNick(sUser.sNick,"<Converter> *** Total ( "..b.." ) user(s) is not registered because profiles doesn't exist in PtokaX")
		return true
	end
end

Spader

Hi
Then i try this script i get this msg

[16:08] Syntax ynhub.lua:56: bad argument count to 'SendToAll' (1 expected, got 2)

have cange profie so they are right for my ynhub

/spader

Spader


Zlobomir

Hi,

After some error (expected } after { in Accounts section, line 14, caused by 11) and yes, } was on place, here is a working one, edited by one my OPs: :)

--//----------------------------------------------------------------------------------------------->> 
--//-- Convert YnHub Register to PtokaX 
--//-- Created by NightLitch 2005-04-23 & Edited by Diamond 2008-06-20 
--//-- To start the convert use specified command bellow in mainchat 
--//-- Usage: #convert 
--//----------------------------------------------------------------------------------------------->> 
 
--//-- Specify the YnHub Profiles to work with your PtokaX Profiles 
--//-- YnHub Profiles   =   PtokaX Profiles 
ProfileRegistry = { 
	["Owner"] = "Owner", 
	["SU"] = "SuperUser", 
	["OP"] = "Operator", 
	["VIP"] = "VIP", 
	["Registered"] = "Reg", 
	["Reg"] = "Reg", 
} 

--//-- Specify the Path to YnHubs Register File 
FileName = "C:\\YOURpathHERE\\PtokaX\\scripts\\accounts.xml" 
 
--//----------------------------------------------------------------------------------------------->> 
--//-- Don't Edit 
--//----------------------------------------------------------------------------------------------->> 
function ConvertYnHubRegisterFile(sFilename) 
    local curTable = {} 
    local curNick = "" 
    local Count = 0 
    local hFile,sE = io.open(sFilename, "r") 
	if hFile == nil then 
		Core.SendToAll("Converter",tostring(hFile).." : "..tostring(sE)) 
	end 
    for line in hFile:lines() do 
        local s,e,col,value = string.find(line, "<(%S+)>(%S+)<") 
        if col and value then 
            if col == "Nick" and Count == 0 then 
                curNick = value 
                curTable[value] = {["Pass"] = "", ["Profile"] = ""} 
                Count = Count + 1 
            elseif col == "Pass" and Count == 1 then 
                curTable[curNick].Pass = value 
                Count = Count + 1 
            elseif col == "Profile" and Count == 2 then 
                curTable[curNick].Profile = value 
                Count = 0 
            end 
        end 
    end 
    hFile:close() 
    return curTable 
end 
  
function ChatArrival(sUser,sData) 
	local _,_,Cmd = string.find(sData, "%b<>%s*(%S+)%|") 
	if Cmd == "#convert" then 
		Core.SendToNick(sUser.sNick,"<Converter> Start Converting YnHub register into PtokaX register") 
		local T = ConvertYnHubRegisterFile(FileName) 
		local t,g,b = 0,0,0 
		for nick,_ in pairs(T) do 
			t = t + 1 
			if ProfileRegistry[T[nick].Profile] and ProfMan.GetProfile(ProfileRegistry[T[nick].Profile]) ~= nil then 
				p = ProfMan.GetProfile(ProfileRegistry[T[nick].Profile]) 
				if p.iProfileNumber ~= -1 then 
					g = g + 1 
					RegMan.AddReg(nick,T[nick].Pass, p.iProfileNumber) 
				else 
					b = b + 1 
				end 
			else 
				b = b +1 
			end 
		end 
		Core.SendToNick(sUser.sNick,"<Converter> *** Total ( "..t.." ) registered user(s) is found in YnHub") 
		Core.SendToNick(sUser.sNick,"<Converter> *** Total ( "..g.." ) user(s) are registered to PtokaX registry") 
		Core.SendToNick(sUser.sNick,"<Converter> *** Total ( "..b.." ) user(s) is not registered because profiles doesn't exist in PtokaX") 
		return true 
	end 
end 
--// Nightlight & edit by Diamond

SMF spam blocked by CleanTalk