samuel157
/root
- Joined
- Mar 19, 2010
- Messages
- 447
- Solutions
- 3
- Reaction score
- 49
- Location
- São Paulo, Brazil
- GitHub
- Samuel10M
XML:
<?xml version="1.0"?>
<npc name="Hight Power" script="data/npc/scripts/scab.lua" access="5" lookdir="2" walkinterval="0">
<health now="200" max="200" />
<look type="111" head="95" body="95" legs="95" feet="95" addons="3" />
<parameters>
<parameter key="message_greet" value="Ola |PLAYERNAME|. Veio trocar uns scarabs coins por itens? Diga {trade}." />
</parameters>
</npc>
Lua:
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 = 2159 -- [ID DO SCARAB COIN]
local t = {
[10569] = {price = 1000000},
[12392] = {price = 1000000},
[11349] = {price = 1000000},
[2644] = {price = 1000000},
[11235] = {price = 1000000},
[11235] = {price = 1000000},
[8924] = {price = 1000000},
[7892] = {price = 1000000},
[7730] = {price = 1000000},
[8884] = {price = 1000000},
[11073] = {price = 1000000},
[11387] = {price = 1000000},
[6534] = {price = 1000000},
[8209] = {price = 1000000},
[12617] = {price = 1000000},
[11350] = {price = 1000000},
[2537] = {price = 1000000},
[8261] = {price = 1000000},
[9004] = {price = 1000000},
[8981] = {price = 1000000},
[7443] = {price = 1000000},
[7440] = {price = 1000000},
[10309] = {price = 1000000},
[10311] = {price = 1000000},
[10310] = {price = 1000000},
[8983] = {price = 1000000},
[12574] = {price = 1000000},
[12279] = {price = 1000000},
[8980] = {price = 1000000},
[10943] = {price = 1000000},
[5907] = {price = 1000000},
[6529] = {price = 1000000},
[6433] = {price = 1000000},
[10298] = {price = 1000000},
[9971] = {price = 1000000},
[11111] = {price = 1000000},
[9693] = {price = 1000000},
[2264] = {price = 1000000},
[2294] = {price = 1000000},
[2263] = {price = 1000000},
[2296] = {price = 1000000},
[2270] = {price = 1000000}
}
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())
Last edited: