killingyasoon Posted September 1, 2018 Share Posted September 1, 2018 hello, i am just wondering how to disable short nicks with 3 letters/digits like abc,hey,123,... and so on. Link to comment
iMr.WiFi..! Posted September 1, 2018 Share Posted September 1, 2018 "onPlayerConnect" -- To get length of letters in name use # Ex. #getPlayerName(player) getPlayerName -- if was less than 3 letters then cancelEvent Link to comment
Mr.Loki Posted September 1, 2018 Share Posted September 1, 2018 The first function parameter in onPlayerConnect is the player's name just check that instead of using getPlayerName Link to comment
Simple0x47 Posted September 2, 2018 Share Posted September 2, 2018 // SERVER function nickHandler( playerNick ) if ( playerNick and ( #playerNick <= 3 ) ) then // DO SOMETHING cancelEvent() // KICK end end addEventHandler( 'onPlayerConnect', root, nickHandler ) 2 Link to comment
killingyasoon Posted September 2, 2018 Author Share Posted September 2, 2018 Appreciated. Link to comment
killingyasoon Posted September 2, 2018 Author Share Posted September 2, 2018 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. Link to comment
Dimos7 Posted September 2, 2018 Share Posted September 2, 2018 (edited) function nickHandler(playerNick) if (playerNick) and string.len(playerNick) <3 then cancelEvent() end end addEventHandler("onPlayerConnect", root, nickHandler) Edited September 2, 2018 by Dimos7 Link to comment
killingyasoon Posted September 3, 2018 Author Share Posted September 3, 2018 Still tho. Link to comment
AJXB Posted September 3, 2018 Share Posted September 3, 2018 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. 1 Link to comment
Simple0x47 Posted September 3, 2018 Share Posted September 3, 2018 2 hours ago, SP3CTR3 said: Way to reinvent how Lua comments are supposed to be. Wrote it fast and since I haven't been coding in Lua for a while made those comments in C++. Link to comment
Dimos7 Posted September 3, 2018 Share Posted September 3, 2018 (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 September 3, 2018 by Dimos7 Link to comment
killingyasoon Posted September 3, 2018 Author Share Posted September 3, 2018 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. Link to comment
killingyasoon Posted September 3, 2018 Author Share Posted September 3, 2018 20 minutes ago, Dimos7 said: np btw xd sorry to bother you, can you make it for OnplayerChangeNick too? it's not working for me xd. Link to comment
Dimos7 Posted September 3, 2018 Share Posted September 3, 2018 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 ? Link to comment
killingyasoon Posted September 3, 2018 Author Share Posted September 3, 2018 Just now, Dimos7 said: no change nick if are less 3 characters ? ye Link to comment
Dimos7 Posted September 3, 2018 Share Posted September 3, 2018 addEventHandler("onPlayerChangeNick", root, function(oldNick, newNick) if string.len(newNick) <= 3 then cancelEvent() end end) try this Link to comment
killingyasoon Posted September 3, 2018 Author Share Posted September 3, 2018 failed to load the script. debugscript = expected '=' near ' on line 1 Link to comment
killingyasoon Posted September 4, 2018 Author Share Posted September 4, 2018 can't get it to work with OnplayerChangeNick Link to comment
URBAN Posted September 4, 2018 Share Posted September 4, 2018 addEventHandler("onPlayerChangeNick", root, function(oldNick, newNick) if string.len(newNick) <= 3 then setPlayerName(source,oldNick) end end) 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