• 01-04.05.2026 - DOUBLE EXP / SKILL EVENT!

-LUA & XML Travel NPC, storage, outfit

Status
Zamknięty.

Ceasar

Active User
Zarejestrowany
Dołączył
Maj 29, 2010
Posty
78
Liczba reakcji
4
Siemanko. Potrzebuj? skrypt na NPC od statk?w, tzn. co? bardziej skomplikowanego > przed podr??? musisz "do??czy?" do npc (przynosisz mu jaki? item, np. 5 white pocs, ten ci daje outfit i dopiero wtedy mo?esz u niego podr??owa?, oczywi?cie p?ac?c za ka?dy rejs)

Mo?e ?atwiej b?dzie z rozmowy:

Kod:
Me: hi
Npc: Hello.
Me: travel
Npc: You have to be one of us before travelling.
Me: join
Npc: If you want join to us, bring me 5 white pieces of cloth. You have these items?
Me: yes
Npc: Here you go. Now you're one of us, wear this outfit which I made for you. Now you can travel.
Me: travel
Npc: I can bring you to x1, x2, x3. Where you want to go?
Me: x1
Npc: You want to travel to x1 for 500 gold?
Me: yes

Sam pr?bowa?em co? zrobi?, ale totalnie mi nie wychodzi.
 
Odp: Travel NPC, storage, outfit

Wystarczy, ?e skrypt b?dzie zbudowany na zasadzie:

- getPlayerStorageValue
- setPlayerStorageValue
- getPlayerItemCount/Item
- doRemoveItem

Popatrz od innych NPC jak pobieraj? itemki w zamian za co?.
 
Odp: Travel NPC, storage, outfit

Z tego co widzia?em nie ma ?adnej funkcji dot. teleportacji gracza, wi?c skopiowa?em travelNode z jakiego? travel npc, ale teraz ?eby p?ywa? do x1, x2 i x3 nie trzeba ?adnego storage > jak to zmieni?? :v

Prymitywny kod, ale wszystko dzia?a opr?cz potrzebnego storage do p?ywania, bo nie wiem gdzie to ustawi?. :c

[LUA]local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local Topic = {}

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 (msgcontains(msg, "hello") or msgcontains(msg, "hi")) and (not npcHandler:isFocused(cid)) then
selfSay("Hello. How may I help you?", cid)
Topic[cid] = 0
npcHandler:addFocus(cid)


elseif msgcontains(msg, "join") and getPlayerStorageValue(cid, 38993) == -1 and npcHandler:isFocused(cid) then
selfSay("So you want to be one of us... Do you have me 5 pirate voodoo dolls?", cid)
Topic[cid] = 1
elseif Topic[cid] == 1 then
if msgcontains(msg, "yes") then
if doPlayerRemoveItem(cid, 5810, 5) then
selfSay("Now you're one of us, wear this outfit.", cid)
doPlayerAddOutfit(cid, 151)
doPlayerAddOutfit(cid, 155)
setPlayerStorageValue(cid, 38993, 1)
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
Topic[cid] = 0
else
selfSay("You don't have dolls.", cid)
Topic[cid] = 0
end
elseif msgcontains(msg, "no") then
selfSay("Okay then.", cid)
Topic[cid] = 0
end

elseif msgcontains(msg, "travel") and getPlayerStorageValue(cid, 38993) == 1 and npcHandler:isFocused(cid) then
selfSay("I can bring you to: {x1}, {x2} and {x3}. Where you want to go?", cid)

local travelNode = keywordHandler:addKeyword({'x1'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'You want to go to {x1} for 500 gold?'})
travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, level = 0, cost = 500, destination = {x=440, y=503, z=7} })
travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Mrgh'})

local travelNode = keywordHandler:addKeyword({'x2'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'You want to go to {x2} for 500 gold?'})
travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, level = 0, cost = 500, destination = {x=440, y=503, z=7} })
travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Mrgh'})

local travelNode = keywordHandler:addKeyword({'x3'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'You want to go to {x3} for 500 gold?'})
travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, level = 0, cost = 500, destination = {x=440, y=503, z=7} })
travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Mrgh'})


elseif(not npcHandler:isFocused(cid)) then
return false
elseif msgcontains(msg, "bye") or msgcontains(msg, "farewell") and npcHander:isFocused(cid) then
selfSay("Good bye.", cid, TRUE)
Topic[cid] = nil
npcHandler:releaseFocus(cid)
elseif msgcontains(msg, "job") then
selfSay("I'm a pirate.", cid)
Topic[cid] = 0
end
return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:setMessage(MESSAGE_WALKAWAY, "Good bye.")[/LUA]
 
Odp: Travel NPC, storage, outfit

Do??czam si? do sprawy / pytania.
 
Status
Zamknięty.
Back
Do góry