Cara eu fiz aqui mas não testei e tem duas coisas que preciso saber. Primeira: vc tem a função doStartTrade do Oneshot instalada? Segunda: quando eu uso essa função abre a janela de trade e eu ofereço o item que eu escolhi na função, mas como o target escolhe o item que ele oferece?
De qualquer jeito, aqui está o código, teste e poste o resultado. Fiz ele com base no addVip
crie sellpremium.lua em data/talkactions/scripts e coloca
function onSay(cid, words, param, channel)
if param == "" then
doPlayerSendCancel(cid, "Para vender seus dias de premium account, diga /trade premium dias playerName.")
return true
end
if param:lower():find('premium') == 1 and 3 then
local _,_,id,name = param:lower():find('premium (%d+) (.+)')
name = name or ""
id = tonumber(id or 1) or 1
if tonumber(id) == nil or getPlayerByName(name) == false then
return doPlayerSendTextMessage(cid,25,"Voce fez algo errado. Para vender seus dias de premium diga /trade premium dias playerName.")
end
if isPlayer(getPlayerByName(name)) then
if getPlayerPremiumDays(cid) < tonumber(id) then
doPlayerSendCancel(cid, "Voce tem menos que " .. tonumber(id) .. " dias de premium.")
return false
end
local document = doPlayerAddItem(cid, 1952, 1)
local days = doItemSetAttribute(document, "description", tonumber(id))
doStartTrade(cid, getPlayerByName(name), days)
doPlayerSendTextMessage(cid, 25, "O jogador " .. name .. " quer te vender " .. tonumber(id) .. " dias de Premium Acount.")
else
doPlayerSendTextMessage(cid,22,name.." nao esta online ou nao existe.")
end
end
return true
end
tag no talkactions.xml
<talkaction log="yes" words="/trade" event="script" value="sellpremium.lua" />
Em data/creaturescripts/scripts cria sellpremium.lua e coloca:
function onTradeAccept(cid, target, item, targetItem)
local days = string.sub(getItemDescriptions(item.uid), 1, 2)
if isPlayer(cid) and isPlayer(target) then
if item.itemid == 1952 then
doPlayerAddPremiumDays(cid, -days)
doPlayerAddPremiumDays(target, days)
doPlayerSendTextMessage(cid, 25, "Voce vendeu " .. days .. " de Premium Account para " .. getCreatureName(target) .. "!")
doPlayerSendTextMessage(target, 25, "Voce comprou " .. days .. " de Premium Account do jogador " .. getCreatureName(cid) .. "!")
end
end
return true
end
No login.lua vc registra essa linha junto com as outras dessaregisterCreatureEvent(cid, "sellPremium")
Em creaturescripts.xml vc coloca<event type="tradeaccept" name="sellPremium" event="script">
Acho muito difícil isso funcionar... Mas tenta aí e me avisa.