• comparing and returning bool from string in name
    1 replies, posted
I am trying to find a way to utilize "string.match" to see wheter a players nick has a specific number or text in it, and I am trying to return a bool wheter it does or not. How can I efficiently do this? what I am trying to do is to check in an if-statement, wheter the player has this number/text in this name
I usually use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/string/find]string.find[/url], it's easier and on it's own can be checked using an if statement [CODE] if string.find( playername, text ) then -- something end [/CODE] [editline]4th November 2017[/editline] If you want a bool: [CODE] local function PlayerNameContains( name, text ) return string.find( name, text ) ~= nil end [/CODE]
Sorry, you need to Log In to post a reply to this thread.