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
!changename John, Jake
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