local exe_ret = {}
exe_ret["error"] = "success"
exe_ret["result"] = ""

--[[
	check condition
--]]
local ret = redis.call('EXISTS' , KEYS[1] )
if ret == 0 then
    exe_ret["error"] = "key not exists"
    exe_ret["result"] = "5002"
    return cjson.encode(exe_ret)
end
if #ARGV ~= 3 then
	exe_ret["error"] = "param error:not 3"
    return cjson.encode(exe_ret)
end

local playerId    = ARGV[1]
local oldNickname = ARGV[2]
local newNickname = ARGV[3]

-- 设置新的 account->playerID
redis.call('HSET' , KEYS[1], newNickname , playerId)

-- 删除旧的
redis.call('HDEL', KEYS[1], oldNickname)

return cjson.encode(exe_ret)

