Alavancas e báus
Alavancas
local coin = 9020 -- sua moeda vip local lever = { [6001] = {30,7429}, [6002] = {20,7366}, [6003] = {10,8926}, [6004] = {5,5978} } function onUse(cid,item,fromPosition,itemEx,toPosition) if doPlayerRemoveItem(cid,coin,lever[item.actionid][1]) == FALSE then return doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "você precisa de "..lever[item.actionid][1].." " ..getItemNameById(coin)) end doPlayerAddItem(cid,lever[item.actionid][2], isItemStackable(lever[item.actionid][2]) and 100 or 1) doPlayerSendTextMessage(cid,22,"você comprou um " .. getItemNameById(lever[item.actionid][2])) doSendMagicEffect(getCreaturePosition(cid), math.random(28,30)) doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945) return true end
Báus
local coin = 9020 -- sua moeda vip local lever = { [6001] = {30,7429}, [6002] = {20,7366}, [6003] = {10,8926}, [6004] = {5,5978} } function onUse(cid,item,fromPosition,itemEx,toPosition) if doPlayerRemoveItem(cid,coin,lever[item.actionid][1]) == FALSE then return doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "você precisa de "..lever[item.actionid][1].." " ..getItemNameById(coin)) end doPlayerAddItem(cid,lever[item.actionid][2], isItemStackable(lever[item.actionid][2]) and 100 or 1) doPlayerSendTextMessage(cid,22,"você comprou um " .. getItemNameById(lever[item.actionid][2])) doSendMagicEffect(getCreaturePosition(cid), math.random(28,30)) return true end
Configuração:
[6001] = {30,7429},
[ActionID do báu ou alavanca] = {Quanto vai custar, ID DO ITEM QUE SERÁ VENDIDO}
a tag é essa:
<action actionid="6001-6004" script="nome do seu script.lua"/>
lembrando que pode adicionar mais, e fazendo isso você deve aumentar na tag também, exemplo:
local lever = {
[6001] = {30,7429},
[6002] = {20,7366},
[6003] = {10,8926},
[6004] = {5,5978},
[6005] = {15,7708}
}
e a tag ficaria assim
<action actionid="6001-6005" script="nome do seu script.lua"/>
Npc's
Trade-say
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 local msg = string.lower(msg) local moeda = 9020 local t = { ["boots of haste"] = {15, 2195}, -- ["nome do item"] = {quanto vai custar, id do tem que sera vendido} ["demon helmet"] = {25, 2493}, ["frozen starlight"] = {30, 2361}, ["royal crossbow"] = {20, 8851}, ["solar axe"] = {30, 8925}, ["soft boots"] = {50, 2640}, ["demon armor"] = {100, 2494}, ["firewalker boots"] = {50, 9932}, ["magic plate armor"] = {70, 2472}, ["flame blade"] = {100, 8931} } if (msgcontains(msg, 'trade') or msgcontains(msg, 'TRADE'))then local str = "" str = str .. "Eu vendo estes items: " for name, pos in pairs(t) do str = str.." {"..name.."} = "..pos[1].." Moedas /" end str = str .. "." npcHandler:say(str, cid) elseif t[msg] then if doPlayerRemoveItem(cid,moeda,t[msg][1]) then doPlayerAddItem(cid,t[msg][2],1) npcHandler:say("Aqui está seu ".. getItemNameById(t[msg][2]) .."!", cid) else npcHandler:say("você não tem "..t[msg][1].." ".. getItemNameById(moeda), cid) end end return TRUE end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
Trade-Shop
OBS: Você precisará ter gps também na mochila, porém não serão removidos os gps, só as moedas vip.
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 local shopWindow = {} local moeda = 9020 local t = { [2195] = {price = 15}, -- [iD DO ITEM QUE SERÁ VENDIDO] = {QUANTO IRÁ CUSTAR} [2493] = {price = 25}, [2361] = {price = 30}, [8851] = {price = 20}, [8925] = {price = 30}, [2640] = {price = 50}, [2494] = {price = 100}, [9932] = {price = 50}, [2472] = {price = 70}, [8931] = {price = 100} } local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks) if t[item] and not doPlayerRemoveItem(cid, moeda, t[item].price) then selfSay("você não tem "..t[item].price.." "..getItemNameById(moeda), cid) else doPlayerAddItem(cid, item) selfSay("aqui está seu item!", cid) end return true end if (msgcontains(msg, 'trade') or msgcontains(msg, 'TRADE'))then for var, ret in pairs(t) do table.insert(shopWindow, {id = var, subType = 0, buy = ret.price, sell = 0, name = getItemNameById(var)}) end openShopWindow(cid, shopWindow, onBuy, onSell) end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())