• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TalkAction Changename in-game

Ratser : thanks you very much!
Jetro : works perfect.. I try it tomorrow either.
 
Nice but, try this with that script: "/changename [space]blabla"; "/changename blabla[space]" or "/changename [space]" :p

EDIT: Wait...that string.gsub(word, " ", " ") is searching for every space on the param...so if you do "/changename About Twenty Percent Cooler" it'll return 3 and so it won't work.
 
Last edited:
Solved all bugs (i think)
  • A name with only spaces it's not valid.
  • A name with symbols or numbers it's not valid.
  • A name with too many spaces it's not valid. The number of spaces can be set at variable "maxspaces"

Lua:
local itemId, count, maxTextLenght, delay = 2160, 1, 15, 2 * 1000
local blacklistParam = {"god", "cm", "gm", "tutor", "tester"}
local maxspaces = 2
function getSpaces(word)
	   _, count = string.gsub(word, " ", " ")   
	   return count
end 
function onSay(cid, words, param, channel)

	local text, continue = "You will be kicked in 2 seconds.", true
	if (not param or  param:find("%a") == nil) then
		text, continue = "You must put a correct name.", false
	elseif(db.getResult("SELECT `name` FROM `players` WHERE `name` = " .. db.escapeString(param) .. ";"):getID() ~= -1) then
		text, continue = "That name is already in use.", false
	elseif(getPlayerItemCount(cid, itemId) < count) then
		text, continue = "You do not have enough premium points.", false
	elseif(not getTilePzInfo(getCreaturePosition(cid))) then
		text, continue = "You must be inside a protection zone to use this command.", false
	elseif(not tostring(param)) then
		text, continue = "Invalid parameter.", false
	elseif(getSpaces(param) > maxspaces) then
		text, continue = "Parameter contains too much spaces.", false
	elseif(string.len(tostring(param)) > maxTextLenght) then
		text, continue = "You can use a maximum of " .. maxTextLenght .. " characters.", false
	elseif(string.find(param:lower(), "[%p%d]") ~= nil) then
		text, continue = "You can not use symbols.", false
	else
		for blacklist = 1, table.maxn(blacklistParam) do
			if(string.find(param:lower(), blacklistParam[blacklist]) ~= nil) then
				text, continue = "Invalid name entry.", false
				break
			end
		end
	end
 
	if(continue == false) then
		doPlayerSendCancel(cid, text)
		return true
	end
 
	db.executeQuery("UPDATE `players` SET `name` = " .. db.escapeString(param) .. " WHERE `id` = " .. getPlayerGUID(cid) .. ";")
	doPlayerRemoveItem(cid, itemId, count)
	doPlayerSendTextMessage(cid, 25, text)
	addEvent(function(cid, forceLogout)
		if(isPlayer(cid)) then
			doRemoveCreature(cid, forceLogout)
		end
	end, delay, cid, false)
	return true
end
btw nice script :)

Is it 100%?
 
This should do it:

Lua:
local itemId, count, maxTextLenght, delay = 1111, 1, 15, 2 * 1000
local blacklistParam = {"god", "cm", "gm", "tutor", "tester"}
 
function onSay(cid, words, param, channel)
	local text, continue = "You will be kicked in 2 seconds.", true
	local spaceStart, spaceEnd = string.find(param, "%s*")
	if(db.getResult("SELECT `name` FROM `players` WHERE `name` = " .. db.escapeString(param) .. ";"):getID() ~= -1) then
		text, continue = "That name is already in use.", false
	elseif(getPlayerItemCount(cid, itemId) < count) then
		text, continue = "You do not have enough premium points.", false
	elseif(not getTilePzInfo(getCreaturePosition(cid))) then
		text, continue = "You must be inside a protection zone to use this command.", false
	elseif(not tostring(param)) then
		text, continue = "Invalid parameter.", false
	elseif(spaceStart == 1 or spaceEnd == string.len(tostring(param))) then
		text, continue = "The first or last characters cannot be spaces.", false
	elseif(string.find(param, "%a%s+") ~= nil) then
		text, continue = "Parameter contains too many spaces in between letters.", false
	elseif(string.len(tostring(param)) > maxTextLenght) then
		text, continue = "You can use a maximum of " .. maxTextLenght .. " characters.", false
	elseif(string.find(param:lower(), "[^%l%s]") ~= nil) then
		text, continue = "You can not use symbols.", false
	else
		for blacklist = 1, table.maxn(blacklistParam) do
			if(string.find(param:lower(), blacklistParam[blacklist]) ~= nil) then
				text, continue = "Invalid name entry.", false
				break
			end
		end
	end
 
	if(continue == false) then
		doPlayerSendCancel(cid, text)
		return true
	end
 
	db.executeQuery("UPDATE `players` SET `name` = " .. db.escapeString(param) .. " WHERE `id` = " .. getPlayerGUID(cid) .. ";")
	doPlayerRemoveItem(cid, itemId, count)
	doPlayerSendTextMessage(cid, 25, text)
	addEvent(function(cid, forceLogout)
		if(isPlayer(cid)) then
			doRemoveCreature(cid, forceLogout)
		end
	end, delay, cid, false)
	return true
end
 
You should consider :free()-ing the result or using getPlayerGUIDByName to check if player exists..
 
Does getPlayerGUIDByName checks players who are offline?

EDIT: Oh wow I just checked the sources and it does. Thanks.
 
This should do it:

Lua:
local itemId, count, maxTextLenght, delay = 1111, 1, 15, 2 * 1000
local blacklistParam = {"god", "cm", "gm", "tutor", "tester"}
 
function onSay(cid, words, param, channel)
	local text, continue = "You will be kicked in 2 seconds.", true
	local spaceStart, spaceEnd = string.find(param, "%s*")
	if(db.getResult("SELECT `name` FROM `players` WHERE `name` = " .. db.escapeString(param) .. ";"):getID() ~= -1) then
		text, continue = "That name is already in use.", false
	elseif(getPlayerItemCount(cid, itemId) < count) then
		text, continue = "You do not have enough premium points.", false
	elseif(not getTilePzInfo(getCreaturePosition(cid))) then
		text, continue = "You must be inside a protection zone to use this command.", false
	elseif(not tostring(param)) then
		text, continue = "Invalid parameter.", false
	elseif(spaceStart == 1 or spaceEnd == string.len(tostring(param))) then
		text, continue = "The first or last characters cannot be spaces.", false
	elseif(string.find(param, "%a%s+") ~= nil) then
		text, continue = "Parameter contains too many spaces in between letters.", false
	elseif(string.len(tostring(param)) > maxTextLenght) then
		text, continue = "You can use a maximum of " .. maxTextLenght .. " characters.", false
	elseif(string.find(param:lower(), "[^%l%s]") ~= nil) then
		text, continue = "You can not use symbols.", false
	else
		for blacklist = 1, table.maxn(blacklistParam) do
			if(string.find(param:lower(), blacklistParam[blacklist]) ~= nil) then
				text, continue = "Invalid name entry.", false
				break
			end
		end
	end
 
	if(continue == false) then
		doPlayerSendCancel(cid, text)
		return true
	end
 
	db.executeQuery("UPDATE `players` SET `name` = " .. db.escapeString(param) .. " WHERE `id` = " .. getPlayerGUID(cid) .. ";")
	doPlayerRemoveItem(cid, itemId, count)
	doPlayerSendTextMessage(cid, 25, text)
	addEvent(function(cid, forceLogout)
		if(isPlayer(cid)) then
			doRemoveCreature(cid, forceLogout)
		end
	end, delay, cid, false)
	return true
end

Is it 100%?
 
It should be.
This one too (Added config value "newMethod". If it's true then it'll use the new 0.3.7+ function doPlayerChangeName else it'll just use the common db update.):
Lua:
local itemId, count, maxTextLenght, delay, newMethod = 1111, 1, 15, 2 * 1000, true
local blacklistParam = {"god", "cm", "gm", "tutor", "tester"}

function onSay(cid, words, param, channel)
	local oldName, guid, text, continue = getCreatureName(cid), getPlayerGUIDByName(oldName), "You will be kicked in 2 seconds.", true
	local spaceStart, spaceEnd = string.find(param, "%s*")
	if(getPlayerGUIDByName(param) ~= nil) then
		text, continue = "That name is already in use.", false
	elseif(getPlayerItemCount(cid, itemId) < count) then
		text, continue = "You do not have enough premium points.", false
	elseif(not getTilePzInfo(getCreaturePosition(cid))) then
		text, continue = "You must be inside a protection zone to use this command.", false
	elseif(not tostring(param)) then
		text, continue = "Invalid parameter.", false
	elseif(spaceStart == 1 or spaceEnd == string.len(tostring(param))) then
		text, continue = "The first or last characters cannot be spaces.", false
	elseif(string.find(param, "%a%s+") ~= nil) then
		text, continue = "Parameter contains too many spaces in between letters.", false
	elseif(string.len(tostring(param)) > maxTextLenght) then
		text, continue = "You can use a maximum of " .. maxTextLenght .. " characters.", false
	elseif(string.find(param:lower(), "[^%l%s]") ~= nil) then
		text, continue = "You can not use symbols.", false
	else
		for blacklist = 1, table.maxn(blacklistParam) do
			if(string.find(param:lower(), blacklistParam[blacklist]) ~= nil) then
				text, continue = "Invalid name entry.", false
				break
			end
		end
	end

	if(continue == false) then
		doPlayerSendCancel(cid, text)
		return true
	end

	if(getBooleanFromString(newMethod)) then
		doPlayerChangeName(guid, oldName, param) -- for 0.3.7+ (is it necessary to kick the player when using this?)
	else
		db.executeQuery("UPDATE `players` SET `name` = " .. db.escapeString(param) .. " WHERE `id` = " .. guid .. ";")
		addEvent(function(cid, forceLogout)
			if(isPlayer(cid)) then
				doRemoveCreature(cid, forceLogout)
			end
		end, delay, cid, false)
	end

	doPlayerRemoveItem(cid, itemId, count)
	doPlayerSendTextMessage(cid, 25, text)
	return true
end
 
Last edited:
So, this is for 0.4 right? FALSE
Lua:
local itemId, count, maxTextLenght, delay, newMethod = 1111, 1, 15, 2 * 1000, false
local blacklistParam = {"god", "cm", "gm", "tutor", "tester"}
 
function onSay(cid, words, param, channel)
	local oldName, guid, text, continue = getCreatureName(cid), getPlayerGUIDByName(oldName), "You will be kicked in 2 seconds.", true
	local spaceStart, spaceEnd = string.find(param, "%s*")
	if(getPlayerGUIDByName(param) ~= nil) then
		text, continue = "That name is already in use.", false
	elseif(getPlayerItemCount(cid, itemId) < count) then
		text, continue = "You do not have enough premium points.", false
	elseif(not getTilePzInfo(getCreaturePosition(cid))) then
		text, continue = "You must be inside a protection zone to use this command.", false
	elseif(not tostring(param)) then
		text, continue = "Invalid parameter.", false
	elseif(spaceStart == 1 or spaceEnd == string.len(tostring(param))) then
		text, continue = "The first or last characters cannot be spaces.", false
	elseif(string.find(param, "%a%s+") ~= nil) then
		text, continue = "Parameter contains too many spaces in between letters.", false
	elseif(string.len(tostring(param)) > maxTextLenght) then
		text, continue = "You can use a maximum of " .. maxTextLenght .. " characters.", false
	elseif(string.find(param:lower(), "[^%l%s]") ~= nil) then
		text, continue = "You can not use symbols.", false
	else
		for blacklist = 1, table.maxn(blacklistParam) do
			if(string.find(param:lower(), blacklistParam[blacklist]) ~= nil) then
				text, continue = "Invalid name entry.", false
				break
			end
		end
	end
 
	if(continue == false) then
		doPlayerSendCancel(cid, text)
		return true
	end
 
	if(getBooleanFromString(newMethod)) then
		doPlayerChangeName(guid, oldName, param) -- for 0.3.7+ (is it necessary to kick the player when using this?)
	else
		db.executeQuery("UPDATE `players` SET `name` = " .. db.escapeString(param) .. " WHERE `id` = " .. guid .. ";")
		addEvent(function(cid, forceLogout)
			if(isPlayer(cid)) then
				doRemoveCreature(cid, forceLogout)
			end
		end, delay, cid, false)
	end
 
	doPlayerRemoveItem(cid, itemId, count)
	doPlayerSendTextMessage(cid, 25, text)
	return true
end
 
If it's on false it's compatible for 0.4 and less
If it's on true then it's only for 0.3.7 and higher

EDIT: Can someone check if it's necessary to kick the player when using doPlayerChangeName (set newMethod to true)?.
 
Nice but, try this with that script: "/changename [space]blabla"; "/changename blabla[space]" or "/changename [space]" :p

EDIT: Wait...that string.gsub(word, " ", " ") is searching for every space on the param...so if you do "/changename About Twenty Percent Cooler" it'll return 3 and so it won't work.
have u tested my fix? it works good in all what u said xd. Yes string.gsub it will return all spaces what has the sentence, of course, the limit of spaces can be set at variable "maxspaces"(?). Don't worry bro, i'm trying to help to make ur script work at 100%, just that.
 
If you say so :p But still your script needs to check if the param contains spaces and the beginning or at the end of it.

EDIT:
Small fix for the position of the last functions.
Lua:
local itemId, count, maxTextLenght, delay, newMethod = 1111, 1, 15, 2 * 1000, false
local blacklistParam = {"god", "cm", "gm", "tutor", "tester"}

function onSay(cid, words, param, channel)
	local oldName, guid, text, continue = getCreatureName(cid), getPlayerGUIDByName(oldName), "You will be kicked in 2 seconds.", true
	local spaceStart, spaceEnd = string.find(param, "%s*")
	if(getPlayerGUIDByName(param) ~= nil) then
		text, continue = "That name is already in use.", false
	elseif(getPlayerItemCount(cid, itemId) < count) then
		text, continue = "You do not have enough premium points.", false
	elseif(not getTilePzInfo(getCreaturePosition(cid))) then
		text, continue = "You must be inside a protection zone to use this command.", false
	elseif(not tostring(param)) then
		text, continue = "Invalid parameter.", false
	elseif(spaceStart == 1 or spaceEnd == string.len(tostring(param))) then
		text, continue = "The first or last characters cannot be spaces.", false
	elseif(string.find(param, "%a%s+") ~= nil) then
		text, continue = "Parameter contains too many spaces in between letters.", false
	elseif(string.len(tostring(param)) > maxTextLenght) then
		text, continue = "You can use a maximum of " .. maxTextLenght .. " characters.", false
	elseif(string.find(param:lower(), "[^%l%s]") ~= nil) then
		text, continue = "You can not use symbols.", false
	else
		for blacklist = 1, table.maxn(blacklistParam) do
			if(string.find(param:lower(), blacklistParam[blacklist]) ~= nil) then
				text, continue = "Invalid name entry.", false
				break
			end
		end
	end

	if(continue == false) then
		doPlayerSendCancel(cid, text)
		return true
	end

	doPlayerRemoveItem(cid, itemId, count)
	doPlayerSendTextMessage(cid, 25, text)
	if(getBooleanFromString(newMethod)) then
		doPlayerChangeName(guid, oldName, param) -- for 0.3.7+ (is it necessary to kick the player when using this?)
	else
		db.executeQuery("UPDATE `players` SET `name` = " .. db.escapeString(param) .. " WHERE `id` = " .. guid .. ";")
		addEvent(function(cid, forceLogout)
			if(isPlayer(cid)) then
				doRemoveCreature(cid, forceLogout)
			end
		end, delay, cid, false)
	end

	return true
end
 
If you say so :p But still your script needs to check if the param contains spaces and the beginning or at the end of it.

EDIT:
Small fix for the position of the last functions.
Lua:
local itemId, count, maxTextLenght, delay, newMethod = 1111, 1, 15, 2 * 1000, false
local blacklistParam = {"god", "cm", "gm", "tutor", "tester"}

function onSay(cid, words, param, channel)
	local oldName, guid, text, continue = getCreatureName(cid), getPlayerGUIDByName(oldName), "You will be kicked in 2 seconds.", true
	local spaceStart, spaceEnd = string.find(param, "%s*")
	if(getPlayerGUIDByName(param) ~= nil) then
		text, continue = "That name is already in use.", false
	elseif(getPlayerItemCount(cid, itemId) < count) then
		text, continue = "You do not have enough premium points.", false
	elseif(not getTilePzInfo(getCreaturePosition(cid))) then
		text, continue = "You must be inside a protection zone to use this command.", false
	elseif(not tostring(param)) then
		text, continue = "Invalid parameter.", false
	elseif(spaceStart == 1 or spaceEnd == string.len(tostring(param))) then
		text, continue = "The first or last characters cannot be spaces.", false
	elseif(string.find(param, "%a%s+") ~= nil) then
		text, continue = "Parameter contains too many spaces in between letters.", false
	elseif(string.len(tostring(param)) > maxTextLenght) then
		text, continue = "You can use a maximum of " .. maxTextLenght .. " characters.", false
	elseif(string.find(param:lower(), "[^%l%s]") ~= nil) then
		text, continue = "You can not use symbols.", false
	else
		for blacklist = 1, table.maxn(blacklistParam) do
			if(string.find(param:lower(), blacklistParam[blacklist]) ~= nil) then
				text, continue = "Invalid name entry.", false
				break
			end
		end
	end

	if(continue == false) then
		doPlayerSendCancel(cid, text)
		return true
	end

	doPlayerRemoveItem(cid, itemId, count)
	doPlayerSendTextMessage(cid, 25, text)
	if(getBooleanFromString(newMethod)) then
		doPlayerChangeName(guid, oldName, param) -- for 0.3.7+ (is it necessary to kick the player when using this?)
	else
		db.executeQuery("UPDATE `players` SET `name` = " .. db.escapeString(param) .. " WHERE `id` = " .. guid .. ";")
		addEvent(function(cid, forceLogout)
			if(isPlayer(cid)) then
				doRemoveCreature(cid, forceLogout)
			end
		end, delay, cid, false)
	end

	return true
end

Thank you man. I guess it's ok, i cant test because im in job
 
Nooo lol Don't tell me that tiny space in between "/changename" and "the name" is considered. Anyways, I'll come up with a solution tomorrow. I'm tired now. BTW, what if you put /changename"name" without spaces? (If it doesn't works it's because I'm not thinking now lol)

Woke up suddenly and came with this crazy idea:
Lua:
local itemId, count, maxTextLenght, delay, newMethod = 1111, 1, 15, 2 * 1000, false
local blacklistParam = {"god", "cm", "gm", "tutor", "tester"}
 
function onSay(cid, words, param, channel)
	local paramTemp, oldName, guid, text, continue = "", getCreatureName(cid), getPlayerGUIDByName(oldName), "You will be kicked in 2 seconds.", true
	for word in string.gmatch(param, "%a+") do
		paramTemp = "" .. paramTemp .. "" .. word .. " "
	end
	param = string.reverse(string.gsub(string.reverse(paramTemp), "%s*", "", 1))
	if(getPlayerGUIDByName(param) ~= nil) then
		text, continue = "That name is already in use.", false
	elseif(getPlayerItemCount(cid, itemId) < count) then
		text, continue = "You do not have enough premium points.", false
	elseif(not getTilePzInfo(getCreaturePosition(cid))) then
		text, continue = "You must be inside a protection zone to use this command.", false
	elseif(not tostring(param)) then
		text, continue = "Invalid parameter.", false
	elseif(string.len(tostring(param)) > maxTextLenght) then
		text, continue = "You can use a maximum of " .. maxTextLenght .. " characters.", false
	elseif(string.find(param:lower(), "[^%l%s]") ~= nil) then
		text, continue = "You can not use symbols.", false
	else
		for blacklist = 1, table.maxn(blacklistParam) do
			if(string.find(param:lower(), blacklistParam[blacklist]) ~= nil) then
				text, continue = "Invalid name entry.", false
				break
			end
		end
	end
 
	if(continue == false) then
		doPlayerSendCancel(cid, text)
		return true
	end
 
	doPlayerRemoveItem(cid, itemId, count)
	doPlayerSendTextMessage(cid, 25, text)
	if(getBooleanFromString(newMethod)) then
		doPlayerChangeName(guid, oldName, param) -- for 0.3.7+ (is it necessary to kick the player when using this?)
	else
		db.executeQuery("UPDATE `players` SET `name` = " .. db.escapeString(param) .. " WHERE `id` = " .. guid .. ";")
		addEvent(function(cid, forceLogout)
			if(isPlayer(cid)) then
				doRemoveCreature(cid, forceLogout)
			end
		end, delay, cid, false)
	end
 
	return true
end
 
Last edited:
Check
11:03 Boga Rula [80]: /changename - error in console
11:04 Boga Rula [80]: /changename Luquinhas - error in console
11:04 Boga Rula [80]: /changename"Luquinhas" - no error, nothing happens
11:04 Boga Rula [80]: /changename "Luquinhas" - error in console
11:04 Boga Rula [80]: /changename, Luquinhas - no error, nothing happens
 
What's the error?
Try:
Lua:
local itemId, count, maxTextLenght, delay, newMethod = 1111, 1, 15, 2 * 1000, false
local blacklistParam = {"god", "cm", "gm", "tutor", "tester"}
 
function onSay(cid, words, param, channel)
	if(param == '') then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
		return true
	end

	local paramTemp = ''
	for word in string.gmatch(param, "%a+") do
		paramTemp = "" .. paramTemp .. " " .. word .. ""
	end

	string.gsub(paramTemp, "%s*", "", 1)
	param = paramTemp
	local oldName, guid, text, continue = getCreatureName(cid), getPlayerGUIDByName(oldName), "You will be kicked in 2 seconds.", true
	if(getPlayerGUIDByName(param) ~= nil) then
		text, continue = "That name is already in use.", false
	elseif(getPlayerItemCount(cid, itemId) < count) then
		text, continue = "You do not have enough premium points.", false
	elseif(not getTilePzInfo(getCreaturePosition(cid))) then
		text, continue = "You must be inside a protection zone to use this command.", false
	elseif(not tostring(param)) then
		text, continue = "Invalid parameter.", false
	elseif(string.len(tostring(param)) > maxTextLenght) then
		text, continue = "You can use a maximum of " .. maxTextLenght .. " characters.", false
	elseif(string.find(param:lower(), "[^%l%s]") ~= nil) then
		text, continue = "You can not use symbols.", false
	else
		for blacklist = 1, table.maxn(blacklistParam) do
			if(string.find(param:lower(), blacklistParam[blacklist]) ~= nil) then
				text, continue = "Invalid name entry.", false
				break
			end
		end
	end

	if(continue == false) then
		doPlayerSendCancel(cid, text)
		return true
	end

	doPlayerRemoveItem(cid, itemId, count)
	doPlayerSendTextMessage(cid, 25, text)
	if(getBooleanFromString(newMethod)) then
		doPlayerChangeName(guid, oldName, param) -- for 0.3.7+ (is it necessary to kick the player when using this?)
	else
		db.executeQuery("UPDATE `players` SET `name` = " .. db.escapeString(param) .. " WHERE `id` = " .. guid .. ";")
		addEvent(function(cid, forceLogout)
			if(isPlayer(cid)) then
				doRemoveCreature(cid, forceLogout)
			end
		end, delay, cid, false)
	end
 
	return true
end
 
Last edited:
Error
16:42 boga rula [80]: /changename luquinhas
16:42 you will be kicked in 2 seconds.
Then error in console (character do not get kicked and when i relog name do not change)

qqqq.jpg
 
This:
Lua:
local itemId, count, maxTextLenght, delay, newMethod = 1111, 1, 15, 2 * 1000, false
local blacklistParam = {"god", "cm", "gm", "tutor", "tester"}
 
function onSay(cid, words, param, channel)
	if(param == '') then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
		return true
	end

	local paramTemp, oldName = '', getCreatureName(cid)
	for word in string.gmatch(param, "%a+") do
		paramTemp = "" .. paramTemp .. " " .. word .. ""
	end

	string.gsub(paramTemp, "%s*", "", 1)
	param = paramTemp
	local guid, text, continue = getPlayerGUIDByName(oldName), "You will be kicked in 2 seconds.", true
	if(getPlayerGUIDByName(param) ~= nil) then
		text, continue = "That name is already in use.", false
	elseif(getPlayerItemCount(cid, itemId) < count) then
		text, continue = "You do not have enough premium points.", false
	elseif(not getTilePzInfo(getCreaturePosition(cid))) then
		text, continue = "You must be inside a protection zone to use this command.", false
	elseif(not tostring(param)) then
		text, continue = "Invalid parameter.", false
	elseif(string.len(tostring(param)) > maxTextLenght) then
		text, continue = "You can use a maximum of " .. maxTextLenght .. " characters.", false
	elseif(string.find(param:lower(), "[^%l%s]") ~= nil) then
		text, continue = "You can not use symbols.", false
	else
		for blacklist = 1, table.maxn(blacklistParam) do
			if(string.find(param:lower(), blacklistParam[blacklist]) ~= nil) then
				text, continue = "Invalid name entry.", false
				break
			end
		end
	end

	if(continue == false) then
		doPlayerSendCancel(cid, text)
		return true
	end

	doPlayerRemoveItem(cid, itemId, count)
	doPlayerSendTextMessage(cid, 25, text)
	if(getBooleanFromString(newMethod)) then
		doPlayerChangeName(guid, oldName, param) -- for 0.3.7+ (is it necessary to kick the player when using this?)
	else
		db.executeQuery("UPDATE `players` SET `name` = " .. db.escapeString(param) .. " WHERE `id` = " .. guid .. ";")
		addEvent(function(cid, forceLogout)
			if(isPlayer(cid)) then
				doRemoveCreature(cid, forceLogout)
			end
		end, delay, cid, false)
	end

	return true
end
 
Last edited:
Nothing happens, no errors
17:45 Boga Rula [80]: /changename"Lucas"
17:46 Boga Rula [80]: /changename, Lucas
17:46 Boga Rula [80]: /changename Lucas
17:46 Boga Rula [80]: /changename
17:46 Boga Rula [80]: !changename
 
Back
Top