NETMSG = {
	"CHAT","MAP","TITLE",
	"CL_SPAWN","CL_ANIM","CL_MOVE","CL_REMOVE",
	"ENT_SPAWN","ENT_UPDATE","ENT_REMOVE",
	"TSC_FAI","TSC_FAO","TSC_MSG","TSC_TEXT","TSC_MNA","TSC_NOD","TSC_CLR","TSC_END","TSC_KEY","TSC_YNJ"
}
for i,v in ipairs(NETMSG)
	NETMSG[v] = i
end

CHANGE = {
	"ANIM","FLIP","MX","MY"
}
for i,v in ipairs(CHANGE)
	CHANGE[v] = 1<<i
end

function string:bin(start,len)
	if not len
		len = 1
	end
	if not start or start > #self
		return nil
	end
	local work = self:sub(start,start+len-1)
	local num = 0
	for i = 1,len
		num = num + (work:sub(i):byte()<<(8*(i-1)))
	end
	return num
end

function string.num(int,len)
	if not len
		len = 1
	end
	if type(int) ~= "boolean" and type(int) ~= "number"
		return nil
	end
	if int == true
		int = 1
	elseif int == false
		int = 0
	end
	local work = {}
	for i = 1,len
		table.insert(work,(int>>(8*(i-1))) & 0xFF)
	end
	return string.char(unpack(work))
end

if CLIENT include "Client/net.lua" else include "Server/net.lua" end
net.loaded = true -- let the rest of the code know network functions are available
