- Joined
- Dec 22, 2007
- Messages
- 1,984
- Reaction score
- 2
As in the title, I'm requesting a script which takes an item and removes recovery key of the account (if rec key exists)
Thanks in advance.
Thanks in advance.
function onSay(cid, words, param)
local result = db.getResult("SELECT `id` FROM `accounts` WHERE `key` != '0' and name='"..getAccountName(cid).."' LIMIT 1")
if(result:getID() > 0)then
db.executeQuery("UPDATE `accounts` SET `key` = '0' WHERE `id` = ".. result:getDataInt("id"))
doPlayerSendTextMessage(cid, 19, "Your rec key have been deleted.")
else
doPlayerSendCancel(cid, "Your account have not registered rec key.")
end
return TRUE
end
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/reckey.lua:onSay
data/talkactions/scripts/reckey.lua:2: attempt to call global 'getAccountName' (a nil value)
stack traceback:
data/talkactions/scripts/reckey.lua:2: in function <data/talkactions/scripts/reckey.lua:1>
function setAccountRecoveryKey(accountId, newKey)
return db.executeQuery("UPDATE `accounts` SET `key` = " .. db.escapeString(newKey) .. " WHERE `id` = " .. accountId .. ";")
end
function getAccountRecoveryKey(accountId)
local recRes = db.getResult("SELECT `key` FROM `accounts` WHERE `id` = " .. accountId .. ";")
if(recRes:getID() == -1) then
error('Account not found.')
return LUA_ERROR
end
return tonumber(recRes:getDataInt("key"))
end
function onSay(cid, words, param)
local playerAccount = getPlayerAccoundId(cid)
if(getAccountRecoveryKey(playerAccount) == "") then
doPlayerSendCancel(cid, "Your account have not registered recovery key.")
return TRUE
end
doAccountSetRecoveryKey(playerAccount, "")
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your recovery key has been deleted.")
return TRUE
end
function getAccountRecoveryKey(accountId)
local recRes = db.getResult("SELECT `key` FROM `accounts` WHERE `id` = " .. accountId .. ";")
if(recRes:getID() == -1) then
error('Account not found.')
return LUA_ERROR
end
return tonumber(recRes:getDataInt("key"))
end
function onSay(cid, word)
doPlayerSendTextMessage(cid, 19, "Your RK is [" ..getAccountRecoveryKey(getPlayerAccountId(cid)).. "].")
return TRUE
end
01:06 Your RK is [1].
function getAccountRecoveryKey(accountId)
local recRes = db.getResult("SELECT `key` FROM `accounts` WHERE `id` = " .. accountId .. ";")
if(recRes:getID() == -1) then
error('Account not found.')
return LUA_ERROR
end
return recRes:getDataString("key")
end
function onSay(cid, word)
doPlayerSendTextMessage(cid, 19, "Your RK is [" ..getAccountRecoveryKey(getPlayerAccountId(cid)).. "].")
return TRUE
end