Example:
A player join my server and his name is "[Admin] Player". I found "admin" in his name, but I don't know how to delete "admin". I checked the lua documentary, but I can never understand for some reasons...
Scripts
Delete string...?
Delete string...?
1

addhook("join","_join")
addhook("name","_name")
unacceptable={"admin","vip","etc"}
function _join(id)
	if stripWords(player(id,"name"),unacceptable)~=string.lower(player(id,"name")) then
		parse("setname "..id.." "..stripWords(player(id,"name"),unacceptable))
	end
end
function _name(id,oldname,newname)
	if stripWords(newname,unacceptable)~=string.lower(newname) then
		return 1
	end
end
function stripWords(start,words)
	for index,value in ipairs(words) do
		words[index]=string.lower(value)
	end
	start=string.lower(start)
	for _,key in ipairs(words) do
		while string.find(start,key)~=nil do
			start=string.gsub(start,key,"")
		end
	end
	return start
end
--Player's name is [Admin]KenVo
addhook("join","_join") --Add hook on joining
addhook("name","_name") --Add hook on changing name
unacceptable={"admin","vip","etc"} --Words that are not allow in player's name
function _join(id) --On join
	if stripWords(player(id,"name"),unacceptable)~=string.lower(player(id,"name")) then --if []KenVo(stripped admin from [Admin]KenVo) is NOT [Admin]KenVo
		parse("setname "..id.." "..stripWords(player(id,"name"),unacceptable))--then set player's name to the stripped name
	end
end
function _name(id,oldname,newname) --On changing name in game
	if stripWords(newname,unacceptable)~=string.lower(newname) then --if the new name that the player is changing to has matched unacceptable letters ([]KenVo to [Admin]KenVo)
		return 1 --then the player's name can't get changed
	end
end
function stripWords(start,words)
	for index,value in ipairs(words) do --loop the unacceptable's table
		words[index]=string.lower(value) --change all the upper case letters in the table to lower case letters
	end
	start=string.lower(start) --change all the upper case letters of 1st parameter to lower case letters
	for _,key in ipairs(words) do --loop the unacceptable's table
		while string.find(start,key)~=nil do --make sure if the letters of 1st parameter match the letters of the table
			start=string.gsub(start,key,"") --take out the matched letters from the 1st parameter
		end
	end
	return start --idk how to explain this...???
end
addhook("join","_join")
addhook("name","_name")
adminlist={"14706"}
unacceptable={"admin","vip","etc"}
function isadmin(i)
	for u=1,#adminlist do
		if adminlist[u] == player(i,"usgn") then
			return true
		end
	end
	return false
end
function _join(id)
	if isadmin(id) == false then
		if stripWords(player(id,"name"),unacceptable)~=string.lower(player(id,"name")) then
			parse("setname "..id.." "..stripWords(player(id,"name"),unacceptable))
		end
	end
end
function _name(id,oldname,newname)
	if stripWords(newname,unacceptable)~=string.lower(newname) then
		return 1
	end
end
function stripWords(start,words)
	for index,value in ipairs(words) do
		words[index]=string.lower(value)
	end
	start=string.lower(start)
	for _,key in ipairs(words) do
		while string.find(start,key)~=nil do
			start=string.gsub(start,key,"")
		end
	end
	return start
end
Kel9290: So wait, what's the point of your post again? Just adding an admin function?
1
