Toffbrown Posted February 19, 2014 Share Posted February 19, 2014 function loginPlayer ( ) local name = getPlayerName ( source ) if ( string.find(name,"[VIP]")) then kickPlayer (source,"Remove the [VIP] Tag") end end addEventHandler ( "onPlayerJoin", root, loginPlayer ) addEventHandler ( "onPlayerChangeNick", root, kick ) how can i make this kick the player when they change their nick to [VIP] ingame? i have also tried unction kick(oldN,newN) local name = getPlayerName(source) if ( string.find(name,"[VIP]")) then kickPlayer(source,"[VIP] Tag is banned, please remove it") end end addEventHandler("onPlayerChangeNick",root,kick) but it kicks the actual player when they change nick to anything like if they type nick jdshjkfhsd it kicks them Link to comment
iPrestege Posted February 19, 2014 Share Posted February 19, 2014 addEventHandler ( 'onPlayerChangeNick',root, function ( _,Nick ) if string.find ( Nick,'[VIP]' ) then kickPlayer ( source,root,'[VIP] Tag is banned, please remove it' ) end end ) Link to comment
Toffbrown Posted February 19, 2014 Author Share Posted February 19, 2014 thanks heaps Prestege have an awesome day :3 Link to comment
Toffbrown Posted February 21, 2014 Author Share Posted February 21, 2014 hi just wondering if i could use a better find value to find only [FO] because it kicks players with like [xx] and fontmaker etc Link to comment
Toffbrown Posted February 21, 2014 Author Share Posted February 21, 2014 another example is [FNY]Logix it detects the o in logix and F in first bracket Link to comment
Moderators Citizen Posted February 21, 2014 Moderators Share Posted February 21, 2014 Check this section from the Lua Reference Manual: http://www.lua.org/manual/5.1/manual.html#5.4.1 [set]: represents the class which is the union of all characters in set. A range of characters can be specified by separating the end characters of the range with a '-'. All classes %x described above can also be used as components in set. All other characters in set represent themselves So you basically want to escape the brackets using % if string.find ( Nick,"%[VIP%]" ) then Link to comment
Moderators Citizen Posted February 22, 2014 Moderators Share Posted February 22, 2014 Thanks 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