HELP PLEASE
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

HELP PLEASE

Started by Tw?sT?d-d?v, 20 April, 2005, 19:55:35

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Tw?sT?d-d?v

can some1 help my with this scritp plz     ive run N/L's converter but i get this error ..
PublicChat.lua5.lua:131: unexpected symbol near `%'
----------------------------------------------------- 
-- Chat Bot v3.5 Coded by [aXs] Wellx 01/09-03 
-- Formerly known as the Developer-Chat for TIC50 
-- Based on the idea VIPChat from Piglja 
-- Thx goes to Piglja & aMutex for Ideas and Help 
----------------------------------------------------- 

ChatBot = "?PublicChat?" -- Chat Bot Name 
CanUseCommands = { -1 , 0 , 1 , 2 , 3 ,4, 5 } -- Can Use Chat Bot Commands Lvl ( 0 = Master ~~ 1 = Operators ~~ 2 = VIPs ~~ 3 = Reg ~~ etc.) 

ChatArray={} 
ChatFile = "Chatters.tbl" 

function Main() 
frmHub:RegBot(ChatBot) 
ChatArray = LoadFromFile(ChatFile) 
end 

--======================================================== DataArrival: =========================================================-- 

function DataArrival(user, data) 
if (string.sub(data, 1, 1) == "<" ) then 
data=string.sub(data,1,string.len(data)-1) 
_,_,cmd=string.find(data, "%b<>%s+(%S+)") 
local Commands = (DeveloperCommands(user, data, cmd)) 
return Commands 
elseif string.sub(data, 1, 5) == "$To: " then 
local s, e, to = string.find(data, "$To: (%S+)") 
if to ~= ChatBot then 
return 0 
else 
if to == ChatBot then 
local data=string.sub(data,1,string.len(data)-1) 
local s,e,from,msg = string.find(data,"From:%s+(%S+)%s+$%b<>%s+(.+)") 
if ChatArray[user.sName] ~= nil then 
ChatArray[user.sName] = nil 
for i,v in ChatArray do 
Developer=GetItemByName(i) 
if (Developer~=nil) then 
Developer:SendData("$To: "..i.." From: "..ChatBot.." $<"..user.sName.."> "..msg.."|") 
end 
end 
ChatArray[user.sName] = user.sName 
else 
user:SendPM(ChatBot,"You do not have permission to write inhere (Join or Talk to a Operator if you need permission)") 
end 
local _,_,cmd = string.find(data,"$%b<>%s+(%S+)") 
local Commands = (DeveloperCommands(user, data, cmd)) 
end 
end 
end 
end 

--===================================================== Chat Commands: ======================================================-- 

function DeveloperCommands(user, data, cmd) 
if tfind(CanUseCommands, user.iProfile) then 
if (cmd == "+chathelp") then 
DevHelp(user) 
return 1 
elseif (cmd == "+chat") then 
local s,e,cmd,ChatName = string.find( data, "%b<>%s+(%S+)%s+(.*)" ) 
if (ChatName == nil) then 
ChatName = user.sName 
end 
if ChatArray[ChatName] == nil then 
ChatArray[ChatName] = ChatName 
for index, value in ChatArray do 
SendPmToNick(index, ChatBot, " "..ChatName.." Has joined the "..ChatBot) 
end 
else 
for index, value in ChatArray do 
SendPmToNick(index, ChatBot, " "..ChatName.." Has left the "..ChatBot) 
end 
ChatArray[ChatName] = nil 
end 
SaveToFile(ChatName,ChatFile,ChatArray) 
return 1 
elseif (cmd == "+showchatters") then 
function DevList() 
local DevList = "" 
for index, value in ChatArray do 
local line = index 
if GetItemByName(index) then 
if (string.len(index) <= 10) then 
DevList = DevList.." ? "..line.."\t\t\t~ On-line ~\r\n" 
else 
DevList = DevList.." ? "..line.."\t\t~ On-line ~\r\n" 
end 
else 
if (string.len(index) <= 10) then 
DevList = DevList.." ? "..line.."\t\t\t? Off-Line ?\r\n" 
else 
DevList = DevList.." ? "..line.."\t\t? Off-Line ?\r\n" 
end 
end 
end 
return DevList 
end 
user:SendPM(ChatBot, "\r\n\r\n(? ?.??.-> "..ChatBot.." Chatters <-.??.???) \r\n\r\n"..DevList()) 
return 1 
end 
else user:SendData("You don't have permission to use the commands to the "..ChatBot.." ask a Operator for permission !!") return 0 end 
end 

function DevHelp (user) 
local disp = "\r\n\r\n" 
disp = disp.."~~ Scripted DeveloperChat Commands: ~~\r\n\r\n" 
disp = disp.." +chat  - Add or part a user to the list of people that can chat in the "..ChatBot.."\r\n" 
disp = disp.." +showchatters - See witch users that can chat in the "..ChatBot.."\r\n" 
disp = disp.."\r\n" 
user:SendPM(ChatBot, disp) 
end 

--======================================================== Functions: ===========================================================-- 

function SaveToFile(arg,file,table) 
local aString = pickle(table) 
writeto(file) 
write(aString) 
writeto() 
end 

function LoadFromFile(file) 
readfrom(file) 
local aString = read("*all") 
return unpickle(aString) 
end 

function tfind(table, key) 
return table.foreachi(table, function(id, tmp) return (tmp == % key) and id end) 
end 

---------------------------------------------- 
-- Pickle.lua 
-- An table serialization utility for lua 
-- Steve Dekorte, http://www.dekorte.com, Apr 2000 
-- Freeware 
---------------------------------------------- 
function pickle(t) 
return Pickle:clone():pickle_(t) 
end 

Pickle = { 
clone = function (t) local nt={}; for i, v in t do nt[i]=v end return nt end 
} 

function Pickle:pickle_(root) 
if type(root) ~= "table" then 
error("can only pickle tables, not ".. type(root).."s") 
end 
self._tableToRef = {} 
self._refToTable = {} 
local savecount = 0 
self:ref_(root) 
local s = "" 
while table.getn(self._refToTable) > savecount do 
savecount = savecount + 1 
local t = self._refToTable[savecount] 
s = s.."{\n" 
for i, v in t do 
s = string.format("%s[%s]=%s,\n", s, self:value_(i), self:value_(v)) 
end 
s = s.."},\n" 
end 
return string.format("{%s}", s) 
end 

function Pickle:value_(v) 
local vtype = type(v) 
if vtype == "string" then return string.format("%q", v) 
elseif vtype == "number" then return v 
elseif vtype == "table" then return "{"..self:ref_(v).."}" 
else --error("pickle a "..type(v).." is not supported") 
end 
end 

function Pickle:ref_(t) 
local ref = self._tableToRef[t] 
if not ref then 
if t == self then error("can't pickle the pickle class") end 
table.insert(self._refToTable, t) 
ref = table.getn(self._refToTable) 
self._tableToRef[t] = ref 
end 
return ref 
end 

---------------------------------------------- 
-- unpickle 
---------------------------------------------- 

function unpickle(s) 
if type(s) ~= "string" then 
error("can't unpickle a "..type(s)..", only strings") 
end 
local tables = dostring("return "..s) 
for tnum = 1, table.getn(tables) do 
local t = tables[tnum] 
local tcopy = {}; for i, v in t do tcopy[i] = v end 
for i, v in tcopy do 
local ni, nv 
if type(i) == "table" then ni = tables[i[1]] else ni = i end 
if type(v) == "table" then nv = tables[v[1]] else nv = v end 
t[ni] = nv 
end 
end 
return tables[1] 
end

??????Hawk??????


plop

give this a try.
using a different way then hawk suggested and converted the file handling.
----------------------------------------------------- 
-- Chat Bot v3.5 Coded by [aXs] Wellx 01/09-03 
-- Formerly known as the Developer-Chat for TIC50 
-- Based on the idea VIPChat from Piglja 
-- Thx goes to Piglja & aMutex for Ideas and Help 
----------------------------------------------------- 

ChatBot = "?PublicChat?" -- Chat Bot Name 
CanUseCommands = { -1 , 0 , 1 , 2 , 3 ,4, 5 } -- Can Use Chat Bot Commands Lvl ( 0 = Master ~~ 1 = Operators ~~ 2 = VIPs ~~ 3 = Reg ~~ etc.) 

ChatArray={} 
ChatFile = "Chatters.tbl" 

function Main() 
frmHub:RegBot(ChatBot) 
ChatArray = LoadFromFile(ChatFile) 
end 

--======================================================== DataArrival: =========================================================-- 

function DataArrival(user, data) 
if (string.sub(data, 1, 1) == "<" ) then 
data=string.sub(data,1,string.len(data)-1) 
_,_,cmd=string.find(data, "%b<>%s+(%S+)") 
local Commands = (DeveloperCommands(user, data, cmd)) 
return Commands 
elseif string.sub(data, 1, 5) == "$To: " then 
local s, e, to = string.find(data, "$To: (%S+)") 
if to ~= ChatBot then 
return 0 
else 
if to == ChatBot then 
local data=string.sub(data,1,string.len(data)-1) 
local s,e,from,msg = string.find(data,"From:%s+(%S+)%s+$%b<>%s+(.+)") 
if ChatArray[user.sName] ~= nil then 
ChatArray[user.sName] = nil 
for i,v in ChatArray do 
Developer=GetItemByName(i) 
if (Developer~=nil) then 
Developer:SendData("$To: "..i.." From: "..ChatBot.." $<"..user.sName.."> "..msg.."|") 
end 
end 
ChatArray[user.sName] = user.sName 
else 
user:SendPM(ChatBot,"You do not have permission to write inhere (Join or Talk to a Operator if you need permission)") 
end 
local _,_,cmd = string.find(data,"$%b<>%s+(%S+)") 
local Commands = (DeveloperCommands(user, data, cmd)) 
end 
end 
end 
end 

--===================================================== Chat Commands: ======================================================-- 

function DeveloperCommands(user, data, cmd) 
if tfind(CanUseCommands, user.iProfile) then 
if (cmd == "+chathelp") then 
DevHelp(user) 
return 1 
elseif (cmd == "+chat") then 
local s,e,cmd,ChatName = string.find( data, "%b<>%s+(%S+)%s+(.*)" ) 
if (ChatName == nil) then 
ChatName = user.sName 
end 
if ChatArray[ChatName] == nil then 
ChatArray[ChatName] = ChatName 
for index, value in ChatArray do 
SendPmToNick(index, ChatBot, " "..ChatName.." Has joined the "..ChatBot) 
end 
else 
for index, value in ChatArray do 
SendPmToNick(index, ChatBot, " "..ChatName.." Has left the "..ChatBot) 
end 
ChatArray[ChatName] = nil 
end 
SaveToFile(ChatName,ChatFile,ChatArray) 
return 1 
elseif (cmd == "+showchatters") then 
function DevList() 
local DevList = "" 
for index, value in ChatArray do 
local line = index 
if GetItemByName(index) then 
if (string.len(index) <= 10) then 
DevList = DevList.." ? "..line.."\t\t\t~ On-line ~\r\n" 
else 
DevList = DevList.." ? "..line.."\t\t~ On-line ~\r\n" 
end 
else 
if (string.len(index) <= 10) then 
DevList = DevList.." ? "..line.."\t\t\t? Off-Line ?\r\n" 
else 
DevList = DevList.." ? "..line.."\t\t? Off-Line ?\r\n" 
end 
end 
end 
return DevList 
end 
user:SendPM(ChatBot, "\r\n\r\n(? ?.??.-> "..ChatBot.." Chatters <-.??.???) \r\n\r\n"..DevList()) 
return 1 
end 
else user:SendData("You don't have permission to use the commands to the "..ChatBot.." ask a Operator for permission !!") return 0 end 
end 

function DevHelp (user) 
local disp = "\r\n\r\n" 
disp = disp.."~~ Scripted DeveloperChat Commands: ~~\r\n\r\n" 
disp = disp.." +chat  - Add or part a user to the list of people that can chat in the "..ChatBot.."\r\n" 
disp = disp.." +showchatters - See witch users that can chat in the "..ChatBot.."\r\n" 
disp = disp.."\r\n" 
user:SendPM(ChatBot, disp) 
end 

--======================================================== Functions: ===========================================================-- 

function SaveToFile(arg,file,table) 
   local aString = pickle(table) 
   local fFile = io.open(file, "w+") 
   fFile:write(aString) 
   fFile:close() 
end 

function LoadFromFile(file) 
   local aString = io.open(file) 
   if aString then
	aString:read("*all") 
	return unpickle(aString) 
   else
	SendToOps(ChatBot, "file not found")
   end
end 

function tfind(table, key) 
   for id,tmp in ipairs(table) do
	if (tmp == key) and id then
	   return id
	end
   end
end 
--return table.foreachi(table, function(id, tmp) return (tmp == % key) and id end) 

---------------------------------------------- 
-- Pickle.lua 
-- An table serialization utility for lua 
-- Steve Dekorte, [URL]http://www.dekorte.com,[/URL] Apr 2000 
-- Freeware 
---------------------------------------------- 
function pickle(t) 
return Pickle:clone():pickle_(t) 
end 

Pickle = { 
clone = function (t) local nt={}; for i, v in t do nt[i]=v end return nt end 
} 

function Pickle:pickle_(root) 
if type(root) ~= "table" then 
error("can only pickle tables, not ".. type(root).."s") 
end 
self._tableToRef = {} 
self._refToTable = {} 
local savecount = 0 
self:ref_(root) 
local s = "" 
while table.getn(self._refToTable) > savecount do 
savecount = savecount + 1 
local t = self._refToTable[savecount] 
s = s.."{\n" 
for i, v in t do 
s = string.format("%s[%s]=%s,\n", s, self:value_(i), self:value_(v)) 
end 
s = s.."},\n" 
end 
return string.format("{%s}", s) 
end 

function Pickle:value_(v) 
local vtype = type(v) 
if vtype == "string" then return string.format("%q", v) 
elseif vtype == "number" then return v 
elseif vtype == "table" then return "{"..self:ref_(v).."}" 
else --error("pickle a "..type(v).." is not supported") 
end 
end 

function Pickle:ref_(t) 
local ref = self._tableToRef[t] 
if not ref then 
if t == self then error("can't pickle the pickle class") end 
table.insert(self._refToTable, t) 
ref = table.getn(self._refToTable) 
self._tableToRef[t] = ref 
end 
return ref 
end 

---------------------------------------------- 
-- unpickle 
---------------------------------------------- 

function unpickle(s) 
if type(s) ~= "string" then 
error("can't unpickle a "..type(s)..", only strings") 
end 
local tables = dostring("return "..s) 
for tnum = 1, table.getn(tables) do 
local t = tables[tnum] 
local tcopy = {}; for i, v in t do tcopy[i] = v end 
for i, v in tcopy do 
local ni, nv 
if type(i) == "table" then ni = tables[i[1]] else ni = i end 
if type(v) == "table" then nv = tables[v[1]] else nv = v end 
t[ni] = nv 
end 
end 
return tables[1] 
end

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Tw?sT?d-d?v

#3
Thx plop testing it now...getting this error

scripts\PublicChat.lua5.lua:204: can't unpickle a userdata, only strings

tried looking at this part of script
---------------------------------------------- 
-- Pickle.lua 
-- An table serialization utility for lua 
-- Steve Dekorte, [URL]http://www.dekorte.com,[/URL] Apr 2000 
-- Freeware 
----------------------------------------------

but page is not available    :((

Can any1 help out?
Or can the pickle part be changed?

jiten

Hum, try commenting that line.
Not sure if it will work, but it's worth a try.
function unpickle(s) 
	if type(s) ~= "string" then 
--		error("can't unpickle a "..type(s)..", only strings") 
	end 
	local tables = dostring("return "..s) 
	for tnum = 1, table.getn(tables) do 
		local t = tables[tnum] 
		local tcopy = {}; for i, v in t do tcopy[i] = v end 
		for i, v in tcopy do 
			local ni, nv 
			if type(i) == "table" then ni = tables[i[1]] else ni = i end 
			if type(v) == "table" then nv = tables[v[1]] else nv = v end 
			t[ni] = nv 
		end 
	end 
	return tables[1] 
end
Cheers

Tw?sT?d-d?v

got this error trying that jiten

scripts\PublicChat.lua5.lua:206: attempt to concatenate local `s' (a userdata value)

jiten

Well, made a fast conversion.
This one may have some bugs...
Anyway, here it is:
----------------------------------------------------- 
-- Chat Bot v3.5 Coded by [aXs] Wellx 01/09-03 
-- Converted to Lua 5 by jiten and plop
-- Formerly known as the Developer-Chat for TIC50 
-- Based on the idea VIPChat from Piglja 
-- Thx goes to Piglja & aMutex for Ideas and Help 
----------------------------------------------------- 

ChatBot = "?PublicChat?" -- Chat Bot Name 
CanUseCommands = { -1 , 0 , 1 , 2 , 3 ,4, 5 } -- Can Use Chat Bot Commands Lvl ( 0 = Master ~~ 1 = Operators ~~ 2 = VIPs ~~ 3 = Reg ~~ etc.) 

ChatArray={} 
ChatFile = "Chatters.tbl" 

function Main() 
	frmHub:RegBot(ChatBot) 
	if not Verify(ChatFile) then
		local f = io.open(ChatFile, "w+")
		f:write()
		f:close()
	else
		ChatArray = dofile(ChatFile) 
	end
end 

--======================================================== Arrivals: =========================================================-- 

function ChatArrival(user, data) 
	data=string.sub(data,1,string.len(data)-1) 
	_,_,cmd=string.find(data, "%b<>%s+(%S+)") 
	local Commands = (DeveloperCommands(user, data, cmd)) 
	return Commands 
end

function ToArrival(user, data) 
	local s, e, to = string.find(data, "$To: (%S+)") 
	if to ~= ChatBot then 
		return 0 
	else 
		if to == ChatBot then 
			local data=string.sub(data,1,string.len(data)-1) 
			local s,e,from,msg = string.find(data,"From:%s+(%S+)%s+$%b<>%s+(.+)") 
			if ChatArray[user.sName] == nil then 
				user:SendPM(ChatBot,"You do not have permission to write inhere (Join or Talk to a Operator if you need permission)") 
				return 0
			else
				ChatArray[user.sName] = nil 
				for i,v in ChatArray do 
					Developer=GetItemByName(i) 
					if (Developer~=nil) then
						Developer:SendData("$To: "..i.." From: "..ChatBot.." $<"..user.sName.."> "..msg.."|") 
					end 
				end 
				ChatArray[user.sName] = user.sName 
			end 
			local _,_,cmd = string.find(data,"$%b<>%s+(%S+)") 
			local Commands = (DeveloperCommands(user, data, cmd)) 
		end 
	end 
end 

--===================================================== Chat Commands: ======================================================-- 

function DeveloperCommands(user, data, cmd) 
	if tfind(CanUseCommands, user.iProfile) then 
		if (cmd == "+chathelp") then 
			DevHelp(user) 
			return 1 
		elseif (cmd == "+chat") then 
			local s,e,cmd,ChatName = string.find( data, "%b<>%s+(%S+)%s+(.*)" ) 
			if (ChatName == nil) then 
				ChatName = user.sName 
			end 
			if ChatArray[ChatName] == nil then 
				ChatArray[ChatName] = ChatName 
				for index, value in ChatArray do 
					SendPmToNick(index, ChatBot, " "..ChatName.." Has joined the "..ChatBot) 
				end 
			else 
				for index, value in ChatArray do 
					SendPmToNick(index, ChatBot, " "..ChatName.." Has left the "..ChatBot) 
				end 
				ChatArray[ChatName] = nil 
			end 
			SaveToFile(ChatName,ChatFile,ChatArray) 
			return 1 
		elseif (cmd == "+showchatters") then 
			function DevList() 
			local DevList = "" 
			for index, value in ChatArray do 
				local line = index 
				if GetItemByName(index) then 
					if (string.len(index) <= 10) then 
						DevList = DevList.." ? "..line.."\t\t\t~ On-line ~\r\n" 
					else 
						DevList = DevList.." ? "..line.."\t\t~ On-line ~\r\n" 
					end 
				else 
					if (string.len(index) <= 10) then 
						DevList = DevList.." ? "..line.."\t\t\t? Off-Line ?\r\n" 
					else 
						DevList = DevList.." ? "..line.."\t\t? Off-Line ?\r\n" 
					end 
				end 
			end 
			return DevList 
		end 
		user:SendPM(ChatBot, "\r\n\r\n(? ?.??.-> "..ChatBot.." Chatters <-.??.???) \r\n\r\n"..DevList()) 
		return 1 
	end 
	else user:SendData("You don't have permission to use the commands to the "..ChatBot.." ask a Operator for permission !!") return 0 end 
end 

function DevHelp (user) 
	local disp = "\r\n\r\n" 
	disp = disp.."~~ Scripted DeveloperChat Commands: ~~\r\n\r\n" 
	disp = disp.." +chat  - Add or part a user to the list of people that can chat in the "..ChatBot.."\r\n" 
	disp = disp.." +showchatters - See witch users that can chat in the "..ChatBot.."\r\n" 
	disp = disp.."\r\n" 
	user:SendPM(ChatBot, disp) 
end 

--======================================================== Functions: ===========================================================-- 

function SaveToFile(arg,file,table) 
	local aString = pickle(table) 
	local fFile = io.open(file, "w+") 
	fFile:write(aString) 
	fFile:close() 
end 

function LoadFromFile(file) 
	local aString = io.open(file) 
	if aString then
		aString:read("*all") 
--		return unpickle(aString) 
	else
		SendToOps(ChatBot, "file not found")
	end
end 

function tfind(table, key) 
	for id,tmp in ipairs(table) do
		if (tmp == key) and id then
			return id
		end
	end
end 

function Verify(filename)
	local f = io.open(filename, "r")
	if f then
		f:close()
		return true
	end
end

---------------------------------------------- 
-- Pickle.lua 
-- An table serialization utility for lua 
-- Steve Dekorte, [URL]http://www.dekorte.com,[/URL] Apr 2000 
-- Freeware 
---------------------------------------------- 
function pickle(t) 
	return Pickle:clone():pickle_(t) 
end 

Pickle = { 
clone = function (t) local nt={}; for i, v in t do nt[i]=v end return nt end 
} 

function Pickle:pickle_(root) 
	if type(root) ~= "table" then 
		error("can only pickle tables, not ".. type(root).."s") 
	end 
	self._tableToRef = {} 
	self._refToTable = {} 
	local savecount = 0 
	self:ref_(root) 
	local s = "" 
	while table.getn(self._refToTable) > savecount do 
		savecount = savecount + 1 
		local t = self._refToTable[savecount] 
		s = s.."{\n" 
		for i, v in t do 
			s = string.format("%s[%s]=%s,\n", s, self:value_(i), self:value_(v)) 
		end 
		s = s.."},\n" 
	end 
	return string.format("{%s}", s) 
end 

function Pickle:value_(v) 
	local vtype = type(v) 
	if vtype == "string" then
		return string.format("%q", v) 
	elseif vtype == "number" then
		return v 
	elseif vtype == "table" then
		return chatname.." = {"..self:ref_(v).."}" 
	else --error("pickle a "..type(v).." is not supported") 
	end 
end 

function Pickle:ref_(t) 
	local ref = self._tableToRef[t] 
	if not ref then 
		if t == self then
			error("can't pickle the pickle class")
		end 
		table.insert(self._refToTable, t) 
		ref = table.getn(self._refToTable) 
		self._tableToRef[t] = ref 
	end 
	return ref 
end 

---------------------------------------------- 
-- unpickle 
---------------------------------------------- 

function unpickle(s) 
	if type(s) ~= "string" then 
		error("can't unpickle a "..type(s)..", only strings") 
	end 
	local tables = dostring("return "..s) 
	for tnum = 1, table.getn(tables) do 
		local t = tables[tnum] 
		local tcopy = {};
		for i, v in t do
			tcopy[i] = v
		end 
		for i, v in tcopy do 
			local ni, nv 
			if type(i) == "table" then
				ni = tables[i[1]]
			else
				ni = i
			end 
			if type(v) == "table" then
				nv = tables[v[1]]
			else
				nv = v
			end 
			t[ni] = nv 
		end 
	end 
	return tables[1] 
end

Tw?sT?d-d?v

No errors when i start hub

But if i try to join chat (+chat) i get this ...

PublicChat.lua5.lua:74: attempt to index global `ChatArray' (a nil value)

jiten

Another try:
----------------------------------------------------- 
-- Chat Bot v3.5 Coded by [aXs] Wellx 01/09-03 
-- Converted to Lua 5 by jiten, Dessamator and plop
-- Formerly known as the Developer-Chat for TIC50 
-- Based on the idea VIPChat from Piglja 
-- Thx goes to Piglja & aMutex for Ideas and Help 
----------------------------------------------------- 

ChatBot = "?PublicChat?" -- Chat Bot Name 
CanUseCommands = { -1 , 0 , 1 , 2 , 3 ,4, 5 } -- Can Use Chat Bot Commands Lvl ( 0 = Master ~~ 1 = Operators ~~ 2 = VIPs ~~ 3 = Reg ~~ etc.) 

ChatArray={} 
ChatFile = "Chatters.tbl" 

function Main() 
	frmHub:RegBot(ChatBot) 
	LoadFromFile(ChatFile)
end 


--======================================================== Arrivals: =========================================================-- 

function ChatArrival(user, data) 
	data=string.sub(data,1,string.len(data)-1) 
	_,_,cmd=string.find(data, "%b<>%s+(%S+)") 
	local Commands = (DeveloperCommands(user, data, cmd)) 
	return Commands 
end

function ToArrival(user, data) 
	local s, e, to = string.find(data, "$To: (%S+)") 
	if to ~= ChatBot then 
		return 0 
	else 
		if to == ChatBot then 
			local data=string.sub(data,1,string.len(data)-1) 
			local s,e,from,msg = string.find(data,"From:%s+(%S+)%s+$%b<>%s+(.+)") 
			if ChatArray[user.sName] == nil then 
				user:SendPM(ChatBot,"You do not have permission to write inhere (Join or Talk to a Operator if you need permission)") 
				return 0
			else
				ChatArray[user.sName] = nil 
				for i,v in ChatArray do 
					Developer=GetItemByName(i) 
					if (Developer~=nil) then
						Developer:SendData("$To: "..i.." From: "..ChatBot.." $<"..user.sName.."> "..msg.."|") 
					end 
				end 
				ChatArray[user.sName] = user.sName 
			end 
			local _,_,cmd = string.find(data,"$%b<>%s+(%S+)") 
			local Commands = (DeveloperCommands(user, data, cmd)) 
		end 
	end 
end 

--===================================================== Chat Commands: ======================================================-- 

function DeveloperCommands(user, data, cmd) 
	if tfind(CanUseCommands, user.iProfile) then 
		if (cmd == "+chathelp") then 
			DevHelp(user) 
			return 1 
		elseif (cmd == "+chat") then 
			local s,e,cmd,ChatName = string.find( data, "%b<>%s+(%S+)%s+(.*)" ) 
			if (ChatName == nil) then 
				ChatName = user.sName 
			end 
			if ChatArray[ChatName] == nil then 
				ChatArray[ChatName] = "1"
				for index, value in ChatArray do 
					SendPmToNick(index, ChatBot, " "..ChatName.." Has joined the "..ChatBot) 
				end 
			else 
				for index, value in ChatArray do 
					SendPmToNick(index, ChatBot, " "..ChatName.." Has left the "..ChatBot) 
				end 
				ChatArray[ChatName] = nil 
			end 
			SaveToFile(ChatFile,ChatArray,"ChatArray") 
			return 1 
		elseif (cmd == "+showchatters") then 
			function DevList() 
			local DevList = "" 
			for index, value in ChatArray do 
				if GetItemByName(index) then 
					if (string.len(index) <= 10) then 
						DevList = DevList.." ? "..index.."\t\t\t~ On-line ~\r\n" 
					else 
						DevList = DevList.." ? "..index.."\t\t~ On-line ~\r\n" 
					end 
				else 
					if (string.len(index) <= 10) then 
						DevList = DevList.." ? "..index.."\t\t\t? Off-Line ?\r\n" 
					else 
						DevList = DevList.." ? "..index.."\t\t? Off-Line ?\r\n" 
					end 
				end 
			end 
			return DevList 
		end 
		user:SendPM(ChatBot, "\r\n\r\n(? ?.??.-> "..ChatBot.." Chatters <-.??.???) \r\n\r\n"..DevList()) 
		return 1 
	end 
	else user:SendData("You don't have permission to use the commands to the "..ChatBot.." ask a Operator for permission !!") return 0 end 
end 

function DevHelp (user) 
	local disp = "\r\n\r\n" 
	disp = disp.."~~ Scripted DeveloperChat Commands: ~~\r\n\r\n" 
	disp = disp.." +chat  - Add or part a user to the list of people that can chat in the "..ChatBot.."\r\n" 
	disp = disp.." +showchatters - See witch users that can chat in the "..ChatBot.."\r\n" 
	disp = disp.."\r\n" 
	user:SendPM(ChatBot, disp) 
end 

--======================================================== Functions: ===========================================================-- 



function tfind(table, key) 
	for id,tmp in ipairs(table) do
		if (tmp == key) and id then
			return id
		end
	end
end 

function Verify(filename)
	local f = io.open(filename, "r")
	if f then
		f:close()
		return true
	end
end
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 string.format("[%q]",key) or string.format("[%d]",key);

                if(type(value) == "table") then
                        sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
                else
                        local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value);
                        sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
                end

                sTmp = sTmp..",\n"
        end

        sTmp = sTmp..sTab.."}"
        return sTmp
end

function SaveToFile(file , table , tablename)
	local handle = io.open(file,"w+")
	handle:write(Serialize(table, tablename))
	handle:flush()
	handle:close()
end

function LoadFromFile(file)
	local handle = io.open(file,"r")
        if (handle ~= nil) then
		dofile(file)
		handle:flush()
		handle:close()
	end
end
Cheers

Tw?sT?d-d?v

works like a dream m8   TY    =)

jiten

yw :]
Btw, if it wasn't for Dessamator I wouldn't have done it all yesterday...  :D

Cheers

SMF spam blocked by CleanTalk