-------------------------------- Change Name script by Nandonalt - Config Below
-- Time, in seconds, that the player will have to read the message.
local seconds = 4
--------------
local function changeName(param)
guid = getPlayerGUID(param.pid)
doRemoveCreature(param.pid)
db.executeQuery("UPDATE `players` SET `name` = '"..param.params[2].."' WHERE `id` = " .. guid .. ";")
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Player with name: '..param.params[1]..' changed to name: '..param.params[2]..'.')
end
function onSay(cid, words, param)
dofile("./config.lua")
name = getCreatureName(cid)
params = string.explode(param,",")
pid = getPlayerByNameWildcard(params[1])
if params[1] ~= "" and params[2] ~= "" then
if(not pid or (isPlayerGhost(pid) and getPlayerGhostAccess(pid) > getPlayerGhostAccess(cid))) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. params[1] .. " is not online.")
else
doPlayerPopupFYI(pid, name.." has changed your name to "..params[2]..".\nRelog your account when kicked.")
addEvent(changeName, seconds * 1000, {cid = cid, pid = pid, params = params})
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Will change player "..params[1].."'s name to "..params[2].." in "..seconds.." seconds.")
return true
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Usage: /changename Playername,Newname')
end
return 1
end