Hi there!
I just melted my brains trying to figure out how to check the users' nicknames. The situaation is I want a nick to look like [Cx]Nickname, where x may be 1, 6, 7, 8 or 17. That's all. Nothing less, nothing more. Can you help? I owe you big!
Are you using the PtokaX way or a script?
No, just PtokaX.
Thanks a lot, Mutor... All my gratitude!
This is my paranoid version.
-- created by bastya_elvtars
--[[ NICK CHECKING STUFF
=====================
BETTER NOT CHANGE THE BADNICK TABLE IF YOU DON'T KNOW WHAT YOU ARE DOING!!!
]]
-- The nick rule redirect address MUST be set in PtokaX.
-- Note that bad characters always get checked in every nick!!!
BadChars = { " ", ";", ",", "+", "<++", "^", "~",}
userlevels={ [-1] = 1, [0] = 5, [1] = 4, [2] = 3, [3] = 2 }
-- Define what prefixes can be used.
-- Can be anything between ( and { and [ and ] and } and ] , these can also be mixed.
-- note that check is case sensitive, so [hun] is not equal to [HUN]
PrefixesNeeded =
{
"[HUN]",
"[EU]",
"(HUN)",
}
--[[
Now something new. With these prefixes, one can not enter the hub.
This one works even if prefix check is off.
Obviously these only affect unreg users, and should only contain the most necessary elements.
(Only unregs can have bad prefix, because a user using a bad prefix cannot be registered IMHO. :P)
]]
BadPrefixes=
{
"[OP]",
"[VIP]",
"[SU]",
}
-- Values: 1 to disconnect, 2 to redirect
BadPrefixToDo=1
Level=3
ExclusionList= -- case of lettters does not matter
{
"{hublistpinger}","pinger","test-nick"
}
function Main()
Prefixes={Needed={},Bad={}}
for k,v in pairs(BadPrefixes) do
Prefixes.Bad[v]=1
end
Prefixes.List="\r\n====================\r\n"
table.sort(PrefixesNeeded)
for k,v in pairs(PrefixesNeeded) do
Prefixes.Needed[v]=1
Prefixes.List=Prefixes.List..v.."\r\n"
end
Prefixes.List=Prefixes.List.."====================\r\n\r\nNote that the check is case sensitive, a.k.a. [prefix] and [PREFIX] are different."
Immune={}
for i,v in ipairs(ExclusionList) do
Immune[string.lower(v)]=1
end
end
function MyINFOArrival(user,data)
if Immune[string.lower(user.sName)] then return end
if not user.bConnected then
for i,v in ipairs(BadChars) do
if string.find(user.sName,v,1,true) then
local bdchr=v
user:SendData("NickNameCheck","Your nick contains the following invalid character (if nothing shows, it's a space): "..v)
user:SendData("NickNameCheck","Please correct it and reconnect! Try using only numbers, letters, brackets, underscores and hyphens.")
user:SendData("NickNameCheck","Disconnects...")
user:Disconnect()
return
end
end
local _,_,prefix = string.find(user.sName, "^([%[%{%(]%S+[%)%}%]])%S+")
if prefix and Prefixes.Bad[prefix] and not user.bRegistered then
user:SendData("NickNameCheck", prefix.." - This prefix is not allowed for you to use.")
user:Disconnect()
end
if userlevels[user.iProfile] < Level then
if prefix then
if not Prefixes.Needed[prefix] then
user:SendData("NickNameCheck", "\r\nBad prefix, use one of these:"..Prefixes.List)
if BadPrefixToDo==1 then
user:Disconnect()
else
user:Redirect(frmHub:GetNickRuleRedirAddr())
end
return
end
else
user:SendData("NickNameCheck", "\r\nNo prefix specified, use one of these:"..Prefixes.List)
if BadPrefixToDo==1 then
user:Disconnect()
else
user:Redirect(frmHub:GetNickRuleRedirAddr())
end
end
end
end
end
LOL! Thank you a lot for the script! I'll try both! Keep up te good job!