Moody
Member
- Joined
- Feb 8, 2020
- Messages
- 60
- Reaction score
- 5
when i travel in my server with captain i have exhaust for travel.
but when i exhausted npc take money too need to fix it 1.3 tfs
npc lua
exhaust module
remove money modules
but when i exhausted npc take money too need to fix it 1.3 tfs
npc lua
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
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
local voices = { {text = 'Passages to Thais, Venore, Carlin, Ab\'Dendriel, Port Hope, Edron, Darashia, Liberty Bay, Svargrond, Yalahar and Ankrahmun.'} }
npcHandler:addModule(VoiceModule:new(voices))
-- Travel
local function addTravelKeyword(keyword, cost, destination, condition)
if condition then
keywordHandler:addKeyword({keyword}, StdModule.say, {npcHandler = npcHandler, text = 'I\'m sorry but I don\'t sail there.'}, condition)
end
local travelKeyword = keywordHandler:addKeyword({keyword}, StdModule.say, {npcHandler = npcHandler, text = 'Do you seek a passage to ' .. keyword:titleCase() .. ' for |TRAVELCOST|?', cost = cost, discount = 'postman'})
travelKeyword:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = false, cost = cost, discount = 'postman', destination = destination})
travelKeyword:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, text = 'We would like to serve you some time.', reset = true})
end
addTravelKeyword('thais', 170, Position(32310, 32210, 6))
addTravelKeyword('venore', 40, Position(32954, 32022, 6))
addTravelKeyword('carlin', 130, Position(32387, 31820, 6))
addTravelKeyword('ab\'dendriel', 90, Position(32734, 31668, 6))
addTravelKeyword('edron', 40, Position(33173, 31764, 6))
addTravelKeyword('port hope', 160, Position(32527, 32784, 6))
addTravelKeyword('svargrond', 150, Position(32341, 31108, 6))
addTravelKeyword('liberty bay', 180, Position(32285, 32892, 6))
addTravelKeyword('yalahar', 185, Position(32816, 31272, 6), function(player) return player:getStorageValue(Storage.SearoutesAroundYalahar.Venore) ~= 1 and player:getStorageValue(Storage.SearoutesAroundYalahar.TownsCounter) < 5 end)
addTravelKeyword('ankrahmun', 150, Position(33092, 32883, 6))
-- Darashia
local travelNode = keywordHandler:addKeyword({'darashia'}, StdModule.say, {npcHandler = npcHandler, text = 'Do you seek a passage to Darashia for |TRAVELCOST|?', cost = 60, discount = 'postman'})
local childTravelNode = travelNode:addChildKeyword({'yes'}, StdModule.say, {npcHandler = npcHandler, text = 'I warn you! This route is haunted by a ghostship. Do you really want to go there?'})
childTravelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = false, cost = 60, discount = 'postman', destination = function(player) return math.random(10) == 1 and Position(33324, 32173, 6) or Position(33289, 32481, 6) end})
childTravelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, reset = true, text = 'We would like to serve you some time.'})
travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, reset = true, text = 'We would like to serve you some time.'})
-- Kick
--keywordHandler:addKeyword({'kick'}, StdModule.kick, {npcHandler = npcHandler, destination = {Position(32952, 32031, 6), Position(32955, 32031, 6), Position(32957, 32032, 6)}})
-- Basic
keywordHandler:addKeyword({'sail'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To {Thais}, {Venore}, {Carlin}, {Ab\'Dendriel}, {Port Hope}, {Edron}, {Darashia}, {Liberty Bay}, {Svargrond}, {Yalahar} or {Ankrahmun}?'})
keywordHandler:addKeyword({'passage'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To {Thais}, {Venore}, {Carlin}, {Ab\'Dendriel}, {Port Hope}, {Edron}, {Darashia}, {Liberty Bay}, {Svargrond}, {Yalahar} or {Ankrahmun}?'})
keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, text = 'I am the captain of this ship.'})
keywordHandler:addKeyword({'captain'}, StdModule.say, {npcHandler = npcHandler, text = 'I am the captain of this ship.'})
keywordHandler:addKeyword({'pyre'}, StdModule.say, {npcHandler = npcHandler, text = 'This is Pyre. Where do you want to go?'})
keywordHandler:addKeyword({'name'}, StdModule.say, {npcHandler = npcHandler, text = 'My name is Captain Barnacle from the Royal Tibia Line.'})
npcHandler:setMessage(MESSAGE_GREET, 'Welcome on board, |PLAYERNAME|. Where can I {sail} you today?')
npcHandler:setMessage(MESSAGE_FAREWELL, 'Good bye. Recommend us if you were satisfied with our service.')
npcHandler:setMessage(MESSAGE_WALKAWAY, 'Good bye then.')
npcHandler:addModule(FocusModule:new())
Lua:
local exhausts = 159321
if parameters.premium and not player:isPremium() then
npcHandler:say("I'm sorry, but you need a premium account in order to travel onboard our ships.", cid)
elseif parameters.level and player:getLevel() < parameters.level then
npcHandler:say("You must reach level " .. parameters.level .. " before I can let you go there.", cid)
elseif player:isPzLocked() then
npcHandler:say("First get rid of those blood stains! You are not going to ruin my vehicle!", cid)
elseif not player:removeMoneyNpc(cost) then
npcHandler:say("You don't have enough money.", cid)
elseif os.time() < getPlayerStorageValue(cid, exhausts) then
npcHandler:say('Sorry, but you need to wait two seconds before travel again.', cid)
player:getPosition():sendMagicEffect(CONST_ME_POFF)
else
npcHandler:releaseFocus(cid)
npcHandler:say(parameters.text or "Set the sails!", cid)
player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
local destination = parameters.destination
if type(destination) == 'function' then
destination = destination(player)
end
player:teleportTo(destination)
Position(destination):sendMagicEffect(CONST_ME_TELEPORT)
setPlayerStorageValue(cid, exhausts, 2 + os.time())
player:teleportTo(destination)
Position(destination):sendMagicEffect(CONST_ME_TELEPORT)
Code:
function Player.removeMoneyNpc(self, amount)
if type(amount) == 'string' then
amount = tonumber(amount)
end
local moneyCount = self:getMoney()
local bankCount = self:getBankBalance()
if amount > moneyCount + bankCount then
return false
end
self:removeMoney(math.min(amount, moneyCount))
if amount > moneyCount then
self:setBankBalance(bankCount - math.max(amount - moneyCount, 0))
if moneyCount == 0 then
self:sendTextMessage(MESSAGE_INFO_DESCR, ("Paid %d gold from bank account. Your account balance is now %d gold."):format(amount, self:getBankBalance()))
else
self:sendTextMessage(MESSAGE_INFO_DESCR, ("Paid %d from inventory and %d gold from bank account. Your account balance is now %d gold."):format(moneyCount, amount - moneyCount, self:getBankBalance()))
end
end
return true
end
local function getPlayerMoney(cid)
local player = Player(cid)
if player then
return player:getMoney() + player:getBankBalance()
end
return 0
end
local function doPlayerRemoveMoney(cid, amount)
local player = Player(cid)
if player then
return player:removeMoneyNpc(amount)
end
return false
end