Is there any more effective way to get someones name from a line in chat than this?
local function getName(chat)
if string.find(chat, ")", 0) ~= nil then
usr = string.sub(chat, string.find(chat, ")", 0), string.find(chat, ">")-4)
lineStart = string.find(chat, ")", 0)
lineEnd = string.find(chat, ">")-4
elseif string.find(chat, "]", 0) ~= nil then
usr = string.sub(chat, string.find(chat, "]", 0), string.find(chat, ">")-4)
lineStart = string.find(chat, "]", 0)
lineEnd = string.find(chat, ">")-4
else usr = string.sub(chat, string.find(chat, "<", 0) + 4, string.find(chat, ">")-4)
lineStart = string.find(chat, "<", 0)+4
lineEnd = string.find(chat, ">")-4
end
return usr, lineStart, lineEnd
end
add_hook("console","console",getName)
Last edited by IceColor; Oct 21, 2014 at 04:38 PM.