• 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!

Lua Accept Trade

marcos16

Falkhonn
Joined
May 4, 2012
Messages
224
Reaction score
1
Hello.
I am using a trade vip command, after a while from the online server, after several transfer it stops working. The trade opens, but when the two accept the vip it will not ...
Could anyone help?
talkaction:
Code:
local config = {
    itemid = 5957,
    storage1 = 224413
}
function onSay(cid, words, param, param2, channel)
    if param == '' then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
        return true
    end
    local t = string.explode(param, ",")
    local creature = getCreatureByName(t[1])
    if not creature and isPlayer(creature) and not isPlayerGhost(creature) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid param specified.")
        return true
    end
    if os.time() > getPlayerStorageValue(cid, config.storage1) then
        local days = tonumber(t[2])
        if days < 2 then
        doPlayerSendCancel(cid, "O mínimo que você pode transferir é de 2 dias.")
            return true
    end
        if days and type(days) == 'number' and getPlayerPremiumDays(cid) - 2 >= days then
            doStartTrade(cid, creature, doPlayerAddItem(cid, config.itemid, 1))
            doPlayerSendTextMessage(creature, MESSAGE_INFO_DESCR, "O Jogador " .. getPlayerName(cid) .. " deu trade em você, e está disposto a trocar " .. days .. " dia(s) de VIP.")
            setPlayerStorageValue(cid, config.storage1, days)
        else
            doPlayerSendCancel(cid, "Você não pode transferir essa quantidade de VIP.")
        end

    end
    return true
end

creaturescript:
Code:
function onTradeAccept(cid, target, item)

local storage1 = 224413

if getPlayerStorageValue(cid, storage1) > 0 then
   local sto = getPlayerStorageValue(cid, storage2)
      doPlayerRemovePremiumDays(cid, sto)
      doPlayerAddPremiumDays(target, sto)
      doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você trocou "..sto.." dia(s) de premium, Parabéns.")
      doPlayerSendTextMessage(target, MESSAGE_STATUS_CONSOLE_BLUE, "Você realizou uma troca e adquiriu "..sto.." dia(s) de premium, Parabéns.")
      setPlayerStorageValue(cid, storage1, 0)
end

return true
end
 

Similar threads

Back
Top