Author Topic: Ynhub Register to Px Register  (Read 2174 times)

0 Members and 1 Guest are viewing this topic.

Offline rag3rac3r

  • Newbie
  • *
  • Posts: 1
  • Karma: +2/-0
Ynhub Register to Px Register
« on: 29 December, 2007, 20:50:54 »
This is a conversion of NightLitch original script to work with the new API. :)

Code: Lua
  1. --//----------------------------------------------------------------------------------------------->>
  2. --//-- Convert YnHub Register to PtokaX
  3. --//-- Originally created by NightLitch 2005-04-23
  4. --//--
  5. --//-- Converted to new Px LUA API 2007-12-29
  6. --//--
  7. --//-- To start the convert use specified command bellow in mainchat
  8. --//-- Usage: #convert
  9. --//----------------------------------------------------------------------------------------------->>
  10.  
  11. --//-- Specify the YnHub Profiles to work with your PtokaX Profiles
  12. --//-- YnHub Profiles   =   PtokaX Profiles
  13. ProfileRegistry = {
  14.         ["Owner"] = "Master",
  15.         ["SU"] = "Operator",
  16.         ["OP"] = "Operator",
  17.         ["VIP"] = "VIP",
  18.         ["Registered"] = "Reg",
  19.         ["Regular"] = "Reg",
  20. }
  21.  
  22. --//-- Specify the Path to YnHubs Register File (Every \ needs to be written as \\)
  23. FileName = "C:\\Path\\to\\YNHUB\\accounts.xml"
  24.  
  25. --//----------------------------------------------------------------------------------------------->>
  26. --//-- Don't Edit
  27. --//----------------------------------------------------------------------------------------------->>
  28. function ConvertYnHubRegisterFile(sFilename)
  29.     local curTable = {}
  30.     local curNick = ""
  31.     local Count = 0
  32.     local hFile,sE = io.open(sFilename, "r")
  33.         if hFile == nil then
  34.                 Core.SendToAll("Converter",tostring(hFile).." : "..tostring(sE))
  35.         end
  36.     for line in hFile:lines() do
  37.         local s,e,col,value = string.find(line, "<(%S+)>(%S+)<")
  38.         if col and value then
  39.             if col == "Nick" and Count == 0 then
  40.                 curNick = value
  41.                 curTable[value] = {["Pass"] = "", ["Profile"] = ""}
  42.                 Count = Count + 1
  43.             elseif col == "Pass" and Count == 1 then
  44.                 curTable[curNick].Pass = value
  45.                 Count = Count + 1
  46.             elseif col == "Profile" and Count == 2 then
  47.                 curTable[curNick].Profile = value
  48.                 Count = 0
  49.             end
  50.         end
  51.     end
  52.     hFile:close()
  53.     return curTable
  54. end
  55.  
  56. function ChatArrival(sUser,sData)
  57.         local _,_,Cmd = string.find(sData, "%b<>%s*(%S+)%|")
  58.         if Cmd == "#convert" then
  59.                 Core.SendToNick(sUser.sNick,"<Converter> Start Converting YnHub register into PtokaX register")
  60.                 local T = ConvertYnHubRegisterFile(FileName)
  61.                 local t,g,b = 0,0,0
  62.                 for nick,_ in pairs(T) do
  63.                         t = t + 1
  64.                         if ProfileRegistry[T[nick].Profile] and ProfMan.GetProfile(ProfileRegistry[T[nick].Profile]) ~= nil then
  65.                                 p = ProfMan.GetProfile(ProfileRegistry[T[nick].Profile])
  66.                                 if p.iProfileNumber ~= -1 then
  67.                                         g = g + 1
  68.                                         RegMan.AddReg(nick,T[nick].Pass, p.iProfileNumber)
  69.                                 else
  70.                                         b = b + 1
  71.                                 end
  72.                         else
  73.                                 b = b +1
  74.                         end
  75.                 end
  76.                 Core.SendToNick(sUser.sNick,"<Converter> *** Total ( "..t.." ) registered user(s) is found in YnHub")
  77.                 Core.SendToNick(sUser.sNick,"<Converter> *** Total ( "..g.." ) user(s) are registered to PtokaX registry")
  78.                 Core.SendToNick(sUser.sNick,"<Converter> *** Total ( "..b.." ) user(s) is not registered because profiles doesn't exist in PtokaX")
  79.                 return true
  80.         end
  81. end
  82.  

PtokaX forum

Ynhub Register to Px Register
« on: 29 December, 2007, 20:50:54 »

Offline Spader

  • Newbie
  • *
  • Posts: 2
  • Karma: +0/-0
Re: Ynhub Register to Px Register
« Reply #1 on: 23 February, 2008, 20:38:28 »
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

Offline Spader

  • Newbie
  • *
  • Posts: 2
  • Karma: +0/-0
Re: Ynhub Register to Px Register
« Reply #2 on: 24 February, 2008, 01:50:31 »
tnx American Idiot
it?s work

/Spader

Offline Zlobomir

  • Newbie
  • *
  • Posts: 7
  • Karma: +5/-0
Re: Ynhub Register to Px Register
« Reply #3 on: 20 June, 2008, 22:03:19 »
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: :)

Code: [Select]
--//----------------------------------------------------------------------------------------------->>
--//-- 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

PtokaX forum

Re: Ynhub Register to Px Register
« Reply #3 on: 20 June, 2008, 22:03:19 »