Jump to content
  • 0

[Resolvido] Trade de Vip por comando


StrikersBR12

Question

4 answers to this question

Recommended Posts

  • 0
  • Diretor

Eu utilizei como base o meu sistema de points, estarei deixando no fim do post caso queira dar uma olhada. Dei uma editada rápida, o principal ta feito. Só tu configurar o ItemID nos dois scripts, e ajeitar a msg.

em creaturescripts crie um arquivo chamado tradevip.lua, cole:

Spoiler

local ItemID = 1964

function scanContainer(item, tables) -- by Yan Liima and Lordzetros
    if isContainer(item.uid) then
        for i = 0, getContainerSize(item.uid) do
            local item_ct = getContainerItem(item.uid, i)
            if (item_ct) then
            if isContainer(item.uid) then
                scanContainer(item_ct, tables)
            end
            table.insert(tables, item_ct.itemid)
         end
      end
   end
end

function PremiumAccount(item)
	return tonumber(getItemAttribute(item.uid, "premmy"))
end

function Success(fromplayer, toplayer, premmy)
   if getPlayerItemCount(toplayer, ItemID) >= 1 and getPlayerPremiumDays(fromplayer) >= premmy then
    	doPlayerRemovePremiumDays(fromplayer, premmy)
		doPlayerRemoveItem(toplayer, ItemID, 1)
		doPlayerAddPremiumDays(toplayer, premmy)
		doPlayerSendTextMessage(toplayer, MESSAGE_STATUS_WARNING, "Transfer successfully, you can now use the ".. premmy .." premium account!")
		doPlayerSendTextMessage(fromplayer, MESSAGE_STATUS_WARNING, "Was removed ".. premmy .." premium account of your account")
		return true
	end
end

function onTradeAccept(cid, target, item, targetItem)
	if isPlayer(cid) and isPlayer(target) then
	  if (item.itemid == ItemID and targetItem.itemid == ItemID) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You can not trade premmy for premmy, close the current trade, and try again.")
			doPlayerSendTextMessage(target, MESSAGE_STATUS_WARNING, "You can not trade premmy for premmy, close the current trade, and try again.")
			return false
      	end
       if item.itemid == ItemID then
			local premmy = PremiumAccount(item)
		if getPlayerPremiumDays(cid) >= premmy then
			addEvent(Success, 1, cid, target, premmy)
		    else
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You do not have ".. premmy .." premium account to perform this procedure.")
			doPlayerSendTextMessage(target, MESSAGE_STATUS_WARNING, "The buyer does not have ".. premmy .." premium account to perform this procedure.")
			return false
			end
		end
		if targetItem.itemid == ItemID then
			local premmy = PremiumAccount(targetItem)
		if getPlayerPremiumDays(target) >= premmy then
			addEvent(Success, 1, target, cid, premmy)
            else
			doPlayerSendTextMessage(target, MESSAGE_STATUS_WARNING, "You do not have ".. premmy .." premium account to perform this procedure.")
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "The buyer does not have ".. premmy .." premium account to perform this procedure.")
			return false
			end
		end
	end
	return true
end

function onTradeRequest(cid, target, item)
local tabela = {}
local black_list = {ItemID}
    scanContainer(item,tabela)
	for i = 1, #black_list do
		if isInArray(tabela, black_list[i]) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You can not place the ".. getItemNameById(ItemID) .." trade document in this trade, this document can only be used in trade outside containers (bag, backpack, etc).")
			return false
		end
	end
	return true
end

 

TAG:

<event type="tradeaccept" name="Trade_VIP" event="script" value="tradevip.lua"/>
<event type="traderequest" name="Trade_VIP_Request" event="script" value="tradevip.lua"/>

login.lua:

registerCreatureEvent(cid, "Trade_VIP")
registerCreatureEvent(cid, "Trade_VIP_Request")

LUA do NPC:

Spoiler

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end

function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end

local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

---- CONFIG ----
local ItemID = 1964 -- ID do papel
local money = 10000 -- Custo para comprar o Papel(em gold coin)
local min,max = 10, 110 -- Valor minimo e maximo do Premium Account em papel
----  FIM ----

	if talkState[cid] == nil or talkState[cid] == 0 then
		premmy = tonumber(msg)
		if (premmy>=min and premmy<=max) then
			selfSay("You can purchase a premium point transfer document that will transfer ".. premmy .." premium Account, right?", cid)
			talkState[talkUser] = 1
		else
			selfSay("I can only sell documents that transfer premium account between "..min.." and "..max..".", cid)
			talkState[talkUser] = 0
		end
	elseif talkState[cid] == 1 then
		if msgcontains(msg, 'yes') then
		if doPlayerRemoveMoney(cid, money) then
			local Paper = doCreateItemEx(ItemID)
			doItemSetAttribute(Paper, "name", "".. premmy .." premium account transfer Paper")
			doItemSetAttribute(Paper, "premmy", premmy)
			selfSay("You got one ".. getItemNameById(ItemID) .." so good ".. premmy .." premium account, it was a pleasure doing business with you.", cid)
			doPlayerAddItemEx(cid, Paper)
			talkState[talkUser] = 0
		else
			selfSay("You do not have enough money!", cid)
			talkState[talkUser] = 0
		  end
		else
		selfSay('OK then!', cid)
		talkState[talkUser] = 0
	   end
	end
	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

 

Tópico citado:

 

Link to comment
Share on other sites

  • 0
  • Diretor

Ao digitar esse comando abriria o trade ? Daria pra fazer, porém iria ser necessario uma alteração na sua source. Teria ela em mãos? Qual distro você usa?

 

Se achar melhor, daria pra usar um item como base, e ao dar trade com ele, ele faria as verificação necessarias, eu ao dar accept ele removeria/transferia os dias de premium.

Link to comment
Share on other sites

  • 0

sim tenho source , eu preferiria que fosse por item msm igual tu falo daria pra usar um item como base, e ao dar trade com ele, ele faria as verificação necessarias, eu ao dar accept ele removeria/transferia os dias de premium.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...