Hi all,
srifqi, thank you for your mod advancedban. It is really very useful.
Some players have dynamic IP (it means a bad player is able to change his IP just pressing a button in his modem) and in this way they can enter any server with any kind of banning mod with a new username *and* a new IP, without beeing banned. So, it seems your mod is a good option to be used alone (if some admins or the owner are able to play in the server sometimes, and watch / ban the bad players).
Of course other mods like xban (extended ban) and future_ban are also useful (for an automatic control, using IP), depending on the server (and the presence of admins in the server).
Anyway, I changed some lines in the code and I'd like to share with other people, for those who could eventually use it.
Instead of the code:
Code: Select all
minetest.register_on_joinplayer(function(player)
if file_exists(minetest.get_worldpath()..DIR_DELIM..FILE_NAME) == true then
local list = io.open(minetest.get_worldpath()..DIR_DELIM..FILE_NAME, "r")
for username in list:lines() do
local name = player:get_player_name()
if name == username then
minetest.after(0.1, function()
minetest.kick_player(name, BAN_MESSAGE) -- kick player
end)
end
end
list:close()
end
end)
I changed to:
Code: Select all
minetest.register_on_prejoinplayer(function(name, ip)
local lname = name:lower()
if file_exists(minetest.get_worldpath()..DIR_DELIM..FILE_NAME) == true then
local list = io.open(minetest.get_worldpath()..DIR_DELIM..FILE_NAME, "r")
for username in list:lines() do
if lname == username:lower() then --lname and username variables are in lowercase (so that the admin or server owner doesn't need to worry about typing BadGuy or badguy as an username; the script accepts all variations automatically)
return BAN_MESSAGE -- This line uses the same ban message configured at the beginning of the mod
--return "Sorry, this username is not available anymore. Please use another username (and play using one username only). Also, please do not use badnames or offensive names. Thank you." --This is just an idea for another ban message...
end
end
list:close()
end
end)
Basically the validation is done using "minetest.register_on_prejoinplayer" instead "minetest.register_on_joinplayer" (in other words, before the player logs in or enters the server).
It seems this change brings 3 interesting changes (faster and easier for the admins, and more productive for the server):
1) As the bad (banned) player is not able to log in (without need to be kicked after he joins), messages like "# player BadGuy entered the server" and (after being kicked) "# player BadGuy left the server", causing less span (unnecessary messages) in chat (what is good for all the players who are online and also for the server)
2) The validation is done before the player logs in, with (hopefully) some milliseconds in less time (that is, the server doesn't need to load all the player stuff like skin and items, probably using less CPU work in the server side).
3) There is a better psychological impact for the bad player: he is not able to enter the server (even for a few seconds before being kicked) and see the buildings, the spawn, the chat (conversation) or any other image inside the world in the server.
Additionaly, the lname and username variables are in lowercase (so that the admin or server owner doesn't need to worry about typing BadGuy or badguy as an username; the script accepts all variations automatically).
Well, just an idea. I hope it can be useful for other friends here. :)
If something is wrong, please correct or don't consider my post.
Regards,
WebWolf
P.S.: December, 29... Happy New Year 2015 for all people in this forum, including your family and friends.