Dantez
Moim sekretem jest ciasto
- Joined
- May 22, 2008
- Messages
- 1,206
- Reaction score
- 202
Author: Dantez
Platform: The Forgotten Server 0.3.6pl1
Platform: The Forgotten Server 0.3.6pl1

npc/name.xml
[XML]<?xml version="1.0" encoding="UTF-8"?>
<npc name="Captain Jack" script="travel.lua" walkinterval="2000" floorchange="0">
<health now="150" max="150"/>
<look type="96" head="78" body="115" legs="118" feet="39" corpse="2212"/>
<parameters>
<parameter key="message_greet" value="Arr |PLAYERNAME|. Maybe you want {travel} somewhere?"/>
</parameters>
</npc>[/XML]
npc/scripts/travel.lua
[LUA]
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
function onCreatureAppear(cid) npcHandler
function onCreatureDisappear(cid) npcHandler
function onCreatureSay(cid, type, msg) npcHandler
function onThink() npcHandler
function greetCallback(cid)
talkState[talkUser] = 0
return true
end
function creatureSayCallback(cid, type, msg)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if(not npcHandler:isFocused(cid)) then
return false
end
local trade = {
-- Kazde id musi by? inne! buy - cena; pos - pozycja, na kt?r? nas wysy?a; name - nazwa miasta
{id=2113, buy=230, pos={x=1000, y=1010, z=7}, name="Thais"},
{id=2180, buy=160, pos={x=1005, y=1009, z=7}, name="Lazienka iSanto"},
}
local items = {}
for _, item in ipairs(trade) do
items[item.id] = {pos = item.pos, item_id = item.id, buyPrice = item.buy, subType = 0, realName = item.name}
end
local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks)
doPlayerRemoveMoney(cid, items[item].buyPrice)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE , "You have travelled to "..items[item].realName..".")
doTeleportThing(cid, items[item].pos)
doSendMagicEffect(getCreaturePosition(cid), 29)
end
if msgcontains(msg, 'travel') or msgcontains(msg, 'passage') then
openShopWindow(cid, trade, onBuy, onSell)
selfSay("Where do you want go?", cid)
end
return true
end
npcHandler:setMessage(MESSAGE_WALKAWAY, "See you soon!")
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())[/LUA]
Co do dodawania nowych miast - KA?DE ID MUSI BY? INNE!