Jump to content

Kick when changed name


Toffbrown

Recommended Posts

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
  • Moderators

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...