• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[request] removing rec key

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.
 
PHP:
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
not tested, making in text field (forum here xd)
 
Code:
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>
 
Last edited:
You can use these functions (Not tested)

Code:
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

So, for example:
Code:
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
 
I use:
PHP:
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

In game return:
PHP:
01:06 Your RK is [1].
But my rk not is 1.
 
The problem that i can see is that you're trying to turn a string with dashes and letters into a number, which ain't gonna work unless your recovery key is something like... "1234123412341234"

Try this:

PHP:
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
 
Back
Top