Ir para conteúdo

Posts Recomendados

To precisando de um npc que carregue a soft boots ou alguem que saiba arruma o meu npc. Pois o que eu tenho ele pega a worm soft boots e os 10k mais num da a soft boots carregada de volta...

 

Aqui em data\npc

 

<?xml version="1.0"?>

 

<npc name="Roy" script="data/npc/scripts/soft.lua" access="3" lookdir="3" walkinterval="2000" floorchange="0">

<mana now="800" max="800"/>

<health now="200" max="200"/>

<look type="151" head="114" body="1" legs="1" feet="76" addons="1" corpse="2212"/>

</npc>

E aqui e data\npc\scripts

 

local focuses = {}

local function isFocused(cid)

for i, v in pairs(focuses) do

if(v == cid) then

return true

end

end

return false

end

 

local function addFocus(cid)

if(not isFocused(cid)) then

table.insert(focuses, cid)

end

end

local function removeFocus(cid)

for i, v in pairs(focuses) do

if(v == cid) then

table.remove(focuses, i)

break

end

end

end

local function lookAtFocus()

for i, v in pairs(focuses) do

if(isPlayer(v) == TRUE) then

doNpcSetCreatureFocus(v)

return

end

end

doNpcSetCreatureFocus(0)

end

 

function onCreatureAppear(cid)

end

 

function onCreatureDisappear(cid)

if(isFocused(cid)) then

selfSay("Hmph!")

removeFocus(cid)

if(isPlayer(cid) == TRUE) then --Be sure he's online

closeShopWindow(cid)

end

end

end

 

 

function onCreatureSay(cid, type, msg)

if((msg == "hi") and not (isFocused(cid))) then

selfSay("Welcome, ".. getCreatureName(cid) .."Yes, my fathers was a great one blacksmith, it was a wise person , but when he decided to teach me he dies and i just learn about the lovely boots. So, did you bring me some boots? which one?", cid, TRUE)

selfSay("Do you want {specialised}?", cid)

addFocus(cid)

elseif((isFocused(cid)) and (msg == "boot" or msg == "specialised")) then

selfSay('I need 10k and worn soft boots , to give you the repared soft boots. Say {worn soft boots}.', cid)

 

------------------------------------------------ repare soft boots ------------------------------------------------

elseif((isFocused(cid)) and (msg == "soft boots" or msg == "soft boot" or msg == "worn soft boots" or msg == "worn soft boot")) then

if isPremium(cid) then

if getPlayerItemCount(cid,6530) >= 1 and getPlayerItemCount(cid,2152) >= 100 or getPlayerItemCount(cid,6530) >= 1 and getPlayerItemCount(cid,2160) >= 1 then

selfSay('Did you bring me 10k and worn soft boots?', cid)

talk_state = 1

else

selfSay('I need 10k and worn soft boots , to give you the repared soft boots. Come back when you have them.', cid)

talk_state = 0

end

else

selfSay('You need premmy account, to repare soft boots.')

talk_state = 0

end

------------------------------------------------ confirm yes ------------------------------------------------

elseif((isFocused(cid)) and (msg == "yeah" or msg == "yes")) and talk_state == 1 then

talk_state = 0

if getPlayerItemCount(cid,6530) >= 1 and getPlayerItemCount(cid,2152) >= 100 or getPlayerItemCount(cid,6530) >= 1 and getPlayerItemCount(cid,2160) >= 1 then

if doPlayerTakeItem(cid,6530,1) and doPlayerTakeItem(cid,2152,100) == 0 or doPlayerTakeItem(cid,6530,1) and doPlayerTakeItem(cid,2160,1) == 0 then

selfSay('Here you are.')

doPlayerAddItem(cid,2640,1)

end

else

selfSay('Sorry, you don\'t have these items.')

end

elseif((isFocused(cid)) and (msg == "bye" or msg == "goodbye" or msg == "cya")) then

selfSay("Goodbye!", cid, TRUE)

removeFocus(cid)

end

 

 

function onThink()

for i, focus in pairs(focuses) do

if(isCreature(focus) == FALSE) then

removeFocus(focus)

else

local distance = getDistanceTo(focus) or -1

if((distance > 4) or (distance == -1)) then

selfSay("Hmph!")

closeShopWindow(focus)

removeFocus(focus)

end

end

end

lookAtFocus()

end

end

 

 

o que tem de errado?

 

 

Link para o comentário
https://xtibia.com/forum/topic/116403-npc-soft-boots/
Compartilhar em outros sites

que script imenso e a maioria e desnecessario.

 

usa esse.

 

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

 

if(msgcontains(msg, 'worn soft boots') or msgcontains(msg, 'wsb')) then

selfSay('Do you want to repair your worn soft boots for 10000 gold coins?', cid)

talkState[talkUser] = 1

elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then

if(getPlayerItemCount(cid, 6530) >= 1) then

if(doPlayerRemoveMoney(cid, 10000) == TRUE) then

local item = getPlayerItemById(cid, TRUE, 6530)

doTransformItem(item.uid, 6132)

selfSay('Here you are.', cid)

else

selfSay('Sorry, you don\'t have enough gold.', cid)

end

else

selfSay('Sorry, you don\'t have the item.', cid)

end

end

 

if(msgcontains(msg, 'worn firewalker boots') or msgcontains(msg, 'wfb')) then

selfSay('Do you want to repair your worn firewalker boots for 10000 gold coins?', cid)

talkState[talkUser] = 2

elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2) then

if(getPlayerItemCount(cid, 9934) >= 1) then

if(doPlayerRemoveMoney(cid, 10000) == TRUE) then

local item = getPlayerItemById(cid, TRUE, 9934)

doTransformItem(item.uid, 9933)

selfSay('Here you are.', cid)

else

selfSay('Sorry, you don\'t have enough gold.', cid)

end

else

selfSay('Sorry, you don\'t have the item.', cid)

end

talkState[talkUser] = 0

elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then

talkState[talkUser] = 0

selfSay('Ok then.', cid)

end

 

return true

end

 

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

Editado por Marcryzius
Link para o comentário
https://xtibia.com/forum/topic/116403-npc-soft-boots/#findComment-763320
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.
×
×
  • Criar Novo...