.:HyPeX:. Posted September 13, 2013 Posted September 13, 2013 wich function can detect capitals in player's chat, or how can i detect them? My ingame nick is ~HyPeX~ BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager
myonlake Posted September 13, 2013 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 If I helped you, please click the like button on the right Thanks!
.:HyPeX:. Posted September 14, 2013 Author 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. My ingame nick is ~HyPeX~ BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager
myonlake Posted September 14, 2013 Posted September 14, 2013 You're welcome. Feel free to make it as you want it. If I helped you, please click the like button on the right Thanks!
.:HyPeX:. Posted September 14, 2013 Author 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). My ingame nick is ~HyPeX~ BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager
myonlake Posted September 14, 2013 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. If I helped you, please click the like button on the right Thanks!
ixjf Posted September 14, 2013 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). I used to know how to code, but then I took an arrow in the knee. Project Redivivus - Remaking Old School MTA With New Code MTA 0.6 Nightly 1 released
.:HyPeX:. Posted September 14, 2013 Author Posted September 14, 2013 thanks for the list, bookmarked! My ingame nick is ~HyPeX~ BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager
myonlake Posted September 14, 2013 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. If I helped you, please click the like button on the right Thanks!
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