import es, gamethread, playerlib ### Start Config ### upper_percent_allow = 50 # The pecent of caps allowed in a sentance upper_messages = {'All capitals is not cool': 1, 'Talking in all capitals does not get other people to listen to you': 3, 'In fact, it makes them utterly dispise you': 5, 'Please, help rid the world of noobs by killing yourself, now': 7, 'In fact, I\'ll do it for you': 9} # The messages that will be shown to the corresponding users the numbers are time that it takes to tell them minimum_characters = 7 # The minimum amount of characters before starting punishment excluded_persons = ('STEAM_0:0:230942304', 'STEAM_0:0:302493') # People who can talk in all caps upper_characters = ('!?') # Characters that will count as Capitals strip_all_text_without_tell = 1 # Just strip all Caps without telling people that All caps are nubs slay_all_caps = 0 ### End Config ###. info = es.AddonInfo() info.name = 'Caps Lock Filter' info.version = '1.0' info.url = 'http://addons.eventscripts.com/addons/view/caps_filter' info.basename = 'caps_filter' info.author = 'Bonbon AKA: Bonbon367' es.ServerVar('clf_version', info.version, 'Caps Lock Filter').makepublic() def load(): es.addons.registerSayFilter(caps_filter) def unload(): es.addons.unregisterSayFilter(caps_filter) def caps_filter(userid, text, teamonly): text = text.strip('"') if isupper(text.replace(' ', '')) and not playerlib.getPlayer(userid).get('steamid') in excluded_persons and not strip_all_text_without_tell: for a in upper_messages: gamethread.delayed(upper_messages[a], es.tell, (userid, '#green', a)) if slay_all_caps: b = upper_messages.values() b.sort() gamethread.delayed(b[len(b) - 1], slay_person, userid) return (userid, text.lower(), teamonly) elif isupper(text.replace(' ', '')) and strip_all_text_without_tell and not playerlib.getPlayer(userid).get('steamid') in excluded_persons: return (userid, text.lower(), teamonly) else: return (userid, text, teamonly) def isupper(text): a = 0 for b in text: if b.isupper() or b in upper_characters: a += 1 if a / float(len(text)) * 100 > upper_percent_allow and not len(text) <= minimum_characters: return 1 def slay_person(userid): if not int(playerlib.getPlayer(userid).get('isdead')): playerlib.getPlayer(userid).set('health', '1') es.server.queuecmd('damage %s 99 32 %s'%(userid, userid))