I have a code to hide ulx commands popping up in the chat, and I wanted to use string.lower instead of string.sub (For obvious reasons)
I have this: [CODE]local function hidechat( ply, text, public )
for k, v in pairs(ulx_commands_table) do
if string.lower( text, 1, #v ) == v then
return("")
end
end
end
hook.Add("PlayerSay", "hidechat", hidechat)[/CODE]
But for some reason, it isn't working. So I added a string.sub part:
[CODE]local function hidechat( ply, text, public )
for k, v in pairs(ulx_commands_table) do
if string.lower( text, 1, #v ) == v then
return("")
end
end
end
local function hidechatdebug( ply, text, public )
for k, v in pairs(ulx_commands_table) do
if string.sub( text, 1, #v ) == v then
return("")
end
end
end
hook.Add("PlayerSay", "hidechat", hidechat)
hook.Add("PlayerSay", "hidechatdebug", hidechatdebug)[/CODE]
Now it works if I type (for example) !slap but not !sLaP.
Am I doing something wrong with string.lower?
Untested.
[code]
local function doCrap(_, text)
text = text:lower()
for _, cmd in pairs(ulx_commands_table) do
if text:StartWith(cmd) then return "" end
end
end
hook.Add("PlayerSay", "HideUlxCommands", doCrap)
[/code]
Sorry, you need to Log In to post a reply to this thread.