.:HyPeX:. Posted September 13, 2013 Share Posted September 13, 2013 wich function can detect capitals in player's chat, or how can i detect them? Link to comment
myonlake Posted September 13, 2013 Share Posted September 13, 2013 (edited) Well you can use this to get the uppercase letters. Should work, tested on Lua demo. function getUppercaseLetters(string) local wow = "" for i=0,string.len(string) do -- Do for each letter local string_ = string.sub(string, i, i) -- Get the letter if(string.find(string_, "%u")) then -- Check if it's uppercase wow = wow .. string_ -- Add to result end end return wow -- Return the uppercase string end So in action it would probably be like: addEventHandler("onPlayerChat", root, -- When someone says something function(message, messageType) if(getUppercaseLetters(message) ~= "") then -- If there are any uppercase strings outputDebugString("Used uppercase letters: '" .. getUppercaseLetters(message) .. "'.") -- Print a message end end ) Edited September 14, 2013 by Guest Link to comment
.:HyPeX:. Posted September 14, 2013 Author Share Posted September 14, 2013 Thanks!, i was also thinking of detecting letter by letter (since mta is uppercase-sensitive), but this will make it easier. Link to comment
myonlake Posted September 14, 2013 Share Posted September 14, 2013 You're welcome. Feel free to make it as you want it. Link to comment
.:HyPeX:. Posted September 14, 2013 Author Share Posted September 14, 2013 by the way, where i can find those variables of the find? there you used "%u", where i can find all the values lua has? i couldnt find them on the lua reference manual (wich is linked from here). Link to comment
myonlake Posted September 14, 2013 Share Posted September 14, 2013 by the way, where i can find those variables of the find? there you used "%u", where i can find all the values lua has? i couldnt find them on the lua reference manual (wich is linked from here). Found the %u thingy here » I did know most of those before too, but then I was wondering what other ones there are. Link to comment
ixjf Posted September 14, 2013 Share Posted September 14, 2013 You need to improve some aspects in your function, namely variables (local variables are recommended) and concatenation (table concatenation is faster). Link to comment
.:HyPeX:. Posted September 14, 2013 Author Share Posted September 14, 2013 thanks for the list, bookmarked! Link to comment
myonlake Posted September 14, 2013 Share Posted September 14, 2013 You need to improve some aspects in your function, namely variables (local variables are recommended) and concatenation (table concatenation is faster). Even though concatenation is easy to do, I suppose we're not talking about long paragraphs, so I doubt the speed is a common factor for his use. Changed to local variables as suggested. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now