• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

TalkAction Changename in-game

Now say "Parameter contains too much spaces"

I Triying /changename Jose Lkko /changename JoseLkko
 
Yeah I was thinking that was gonna happen. I left it like it was before.
 
Ok I did it like TGYoshi said (and learned how to use patterns in the process)...
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 stringSpaceStart, stringSpaceEnd = 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((stringSpaceEnd - stringSpaceStart) > 1) 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(), "[^%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%?
 
99%...it needs to check spaces for names with more than 1 space between them.
But anyways, yours doesn't check spaces too so it's the same :p
 
can you make script so its removes some like scarab coins
ht1.jpg
jh88.jpg
test.jpg
huang10
 
xDDD Bug..
/changename [espace][espace]
>.< *Char no have name D=


And i can put this char.. /changename a b c d e f ..
elseif((stringSpaceEnd - stringSpaceStart) > 1) then
This function no work.. i think..


Any fix for this?
 
Last edited:
Try this. This shouldn't allow more than 1 space. And the "a b c d e f" thing you said is fine. Although you could block 1-worded names but still the Account Manager or AAC allows it...so it would be for nothing.

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
	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(string.find(param, "%s+") ~= nil) then
		text, continue = "Parameter contains too many 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(), "[^%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
 
Mm i put
/changename lol lol ------and reciver error- Parameter contains too many spaces
And put
/changename [espace][espace][espace] -- and i can create character name empy >.<

13:15 You see (Level 129).
 
Try this:

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
	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((string.find(param, "%s", 1) ~= nil) or (string.find(param, "%s", string.len(tostring(param)) ~= nil))) 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
 
[Error - TalkAction Interface]
[26/8/2012 12:51:13] data/talkactions/scripts/changename.lua:eek:nSay
[26/8/2012 12:51:13] Description:
[26/8/2012 12:51:13] data/talkactions/scripts/changename.lua:35: bad argument #3 to 'find' (number expected, got boolean)
[26/8/2012 12:51:13] stack traceback:
[26/8/2012 12:51:13] [C]: in function 'find'
[26/8/2012 12:51:13] data/talkactions/scripts/changename.lua:35: in function <data/talkactions/scripts/changename.lua:25>

elseif((string.find(param, "%s", 1) ~= nil) or (string.find(param, "%s", string.len(tostring(param)) ~= nil))) then
text, continue = "The first or last characters cannot be spaces.", false

Thanks Your
 
Is it 100% now?

Try this:

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
	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((string.find(param, "%s", 1) ~= nil) or (string.find(param, "%s", string.len(tostring(param)) ~= nil))) 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
 
Remove this part:

Lua:
or (string.find(param, "%s", string.len(tostring(param)) ~= nil))
and try again, I wanna check something.
 
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 :)
 
Back
Top