Jump to content

how to disable short nicks.


killingyasoon

Recommended Posts

Posted
// SERVER

function nickHandler( playerNick )
	if ( playerNick and ( #playerNick <= 3 ) ) then
    	// DO SOMETHING
     	cancelEvent() // KICK
    end
end

addEventHandler( 'onPlayerConnect', root, nickHandler )

 

  • Thanks 2
Posted
19 hours ago, Simple01 said:

// SERVER

function nickHandler( playerNick )
	if ( playerNick and ( #playerNick <= 3 ) ) then
    	// DO SOMETHING
     	cancelEvent() // KICK
    end
end

addEventHandler( 'onPlayerConnect', root, nickHandler )

 

there're no errors but still doesn't work.

Posted (edited)
function nickHandler(playerNick) 
  if (playerNick) and string.len(playerNick) <3 then
    cancelEvent() 
  end
end 
addEventHandler("onPlayerConnect", root, nickHandler) 

 

Edited by Dimos7
Posted
On 02/09/2018 at 05:25, Simple01 said:

// SERVER

function nickHandler( playerNick )
	if ( playerNick and ( #playerNick <= 3 ) ) then
    	// DO SOMETHING
     	cancelEvent() // KICK
    end
end

addEventHandler( 'onPlayerConnect', root, nickHandler )

 

Way to reinvent how Lua comments are supposed to be.

  • Haha 1
Posted (edited)
function nickHandler(playerNick) 
  if (playerNick) and string.len(playerNick) <=3 then
    cancelEvent(true, "Your nickname is too short for that") 
  end
end 
addEventHandler("onPlayerConnect", root, nickHandler) 

 

Edited by Dimos7
Posted
2 hours ago, Dimos7 said:

function nickHandler(playerNick) 
  if (playerNick) and string.len(playerNick) <=3 then
    cancelEvent(true, "Your nickname is too short for that") 
  end
end 
addEventHandler("onPlayerConnect", root, nickHandler) 

 

Works totally perfect, thank you bud.

Posted
1 minute ago, killingyasoon said:

btw xd sorry to bother you, can you make it for OnplayerChangeNick too? it's not working for me xd.

no change nick if are less 3 characters ?

Posted
addEventHandler("onPlayerChangeNick", root, function(oldNick, newNick)
    if string.len(newNick) <= 3 then
          setPlayerName(source,oldNick)
	end
end)

 

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...