• 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!

Request Talkaction

You can try this, but I don't know if it will work.

Code:
!changename John, Jake

Lua:
("Fixed it in later post.")
 
Last edited:
You can try this, but I don't know if it will work.

Code:
!changename John, Jake

Lua:
function onSay(cid, w, p, channel)
	if not p or p == "" then
		doPlayerSendCancel(cid, "Command requires param.")
		return true
	end
	if w == "!changename" then
		if db.getResult("SELECT `id` FROM `players` WHERE `name` = " .. db.escapeString(p[1]) .. ";"):getID() == -1 then
			return doPlayerSendCancel(cid, "Sorry, but player [" .. p[1] .. "] does not exist.")
		elseif db.getResult("SELECT `id` FROM `players` WHERE `name` = " .. db.escapeString(p[2]) .. ";"):getID() == 1 then
			return doPlayerSendCancel(cid, "Sorry, but the name [" .. p[2] .. "] already exists.")
		end
		
		return db.executeQuery("UPDATE `players` SET `name` = '" .. p[2] .. "' WHERE name = '" .. p[1] .. "';"), doPlayerSave(cid, true), doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
	end
	
	return true
end

what if he says !changename Thisnameissodamlarge+-128uaheuahueahueaeeaeaeuaheae
 
what if he says !changename Thisnameissodamlarge+-128uaheuahueahueaeeaeaeuaheae

What if he doesn't? You want to play the "what if game" or help?

It's not hard to fix.

PHP:
!changename John, Jake

Lua:
local MIN = 5
local MAX = 10
function onSay(cid, w, p, channel)
	if not p or p == "" then
		doPlayerSendCancel(cid, "Command requires param.")
		return true
	end
	if w == "!changename" then
		local long = p[2]:len() > MAX
		local short = p[2]:len() < MIN
		if long or short then
			doPlayerSendCancel(cid, "Sorry, your name is too " .. (long and "long." or "short."))
			return true
		end
		
		if db.getResult("SELECT `id` FROM `players` WHERE `name` = " .. db.escapeString(p[1]) .. ";"):getID() == -1 then
			doPlayerSendCancel(cid, "Sorry, but player [" .. p[1] .. "] does not exist.")
			return true
		end
		
		if db.getResult("SELECT `id` FROM `players` WHERE `name` = " .. db.escapeString(p[2]) .. ";"):getID() == 1 then
			doPlayerSendCancel(cid, "Sorry, but the name [" .. p[2] .. "] already exists.")
			return true
		end
 
		doRemoveCreature(cid)
		addEventdb.executeQuery("UPDATE `players` SET `name` = '" .. p[2] .. "' WHERE name = '" .. p[1] .. "';")
	end
 
	return true
end
 
Last edited:
Back
Top