HOWTO: Inter-plugin communication
#15
Yea I know, but you can pass userdata. And with my 'Login' plugin I have a table with functions in it where I keep my passwords. So I was wondering if I could somehow convert the table to userdata so it could be passable. This is the code:
function LoadPasswords(Path)
	local File = io.open(Path)
	local Table = {}
	if File then
		for I in File:lines() do
			local Split = StringSplit(I, ";")
			Table[Split[1]] = Split[2]
		end
		File:close()
	else
		local File = io.open(Path, "w")
		File:write()
		File:close()
	end
	local Object = {}
	function Object:GetPassFromPlayer(PlayerName)
		if Table[PlayerName] ~= nil then
			return true, Table[PlayerName]
		end
		return false
	end
	
	function Object:AddPass(PlayerName, Password)
		if Table[PlayerName] == nil then
			Table[PlayerName] = md5(Password)
			return true
		end
		return false
	end
	
	function Object:RemovePlayer(PlayerName)
		if Table[PlayerName] ~= nil then
			Table[PlayerName] = nil
			return true
		end
		return false
	end
	
	function Object:ChangePass(PlayerName, NewPassword)
		if Table[PlayerName] ~= nil then
			Table[PlayerName] = md5(NewPassword)
			return true
		end
		return false
	end
	
	function Object:PlayerExists(PlayerName)
		if Table[PlayerName] ~= nil then
			return true
		end
		return false
	end
	
	function Object:ReturnTable()
		return Table
	end
	
	function Object:Save()
		local File = io.open(Path, "w")
		for I, k in pairs(Table) do
			File:write(I .. ";" .. k .. "\n")
		end
		File:close()
	end
	return Object
end
Reply
Thanks given by:


Messages In This Thread
HOWTO: Inter-plugin communication - by FakeTruth - 10-11-2012, 08:07 AM
RE: HOWTO: Inter-plugin communication - by ThuGie - 10-11-2012, 08:11 AM
RE: HOWTO: Inter-plugin communication - by xoft - 10-11-2012, 09:08 PM
RE: HOWTO: Inter-plugin communication - by xoft - 10-11-2012, 11:05 PM
RE: HOWTO: Inter-plugin communication - by ThuGie - 10-12-2012, 12:36 AM
RE: HOWTO: Inter-plugin communication - by xoft - 10-12-2012, 04:57 AM
RE: HOWTO: Inter-plugin communication - by NiLSPACE - 10-22-2013, 11:49 PM
RE: HOWTO: Inter-plugin communication - by xoft - 10-23-2013, 05:43 AM
RE: HOWTO: Inter-plugin communication - by xoft - 10-23-2013, 06:33 AM
RE: HOWTO: Inter-plugin communication - by xoft - 11-25-2013, 01:33 AM
RE: HOWTO: Inter-plugin communication - by xoft - 12-07-2013, 06:51 AM



Users browsing this thread: 2 Guest(s)