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