bpm91
Intermediate OT User
- Joined
- May 23, 2019
- Messages
- 934
- Solutions
- 7
- Reaction score
- 129
- Location
- Brazil
- YouTube
- caruniawikibr
Hi guys, I'm trying to add storage to the travel function to implement the postman quest, however my character does not receive storage when traveling. As my tfs 1.5 doesn't exist, I added the functions to lib\core\string
the error no longer appears in titlecase, but the character does not receive storage, for example from this line
If anyone knows how to make the NPC consider the storage and give me the storage I would be grateful.
addTravelKeyword('carlin', 110, Position(32387, 31820, 6), function(player) if player:getStorageValue(PlayerStorageKeys.postman.Mission01) == 1 then player:setStorageValue(PlayerStorageKeys.postman.Mission01, 2) end end)
the implementation I already did was.
lib\string and lib\core\core and add function lib\string
my script complet
the error no longer appears in titlecase, but the character does not receive storage, for example from this line
If anyone knows how to make the NPC consider the storage and give me the storage I would be grateful.
addTravelKeyword('carlin', 110, Position(32387, 31820, 6), function(player) if player:getStorageValue(PlayerStorageKeys.postman.Mission01) == 1 then player:setStorageValue(PlayerStorageKeys.postman.Mission01, 2) end end)
the implementation I already did was.
lib\string and lib\core\core and add function lib\string
Lua:
string.split = function(str, sep)
local res = {}
for v in str:gmatch("([^" .. sep .. "]+)") do
res[#res + 1] = v
end
return res
end
string.trim = function(str)
return str:match'^()%s*$' and '' or str:match'^%s*(.*%S)'
end
string.starts = function(str, substr)
return string.sub(str, 1, #substr) == substr
end
string.titleCase = function(str)
return str:gsub("(%a)([%w_']*)", function(first, rest) return first:upper() .. rest:lower() end)
end
my script complet
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 Carlin, Ab\'Dendriel, Edron, Venore, Port Hope, Liberty Bay and Svargrond.'} }
npcHandler:addModule(VoiceModule:new(voices))
-- Travel
local function addTravelKeyword(keyword, cost, destination, action)
local travelKeyword = keywordHandler:addKeyword({keyword}, StdModule.say, {npcHandler = npcHandler, text = 'Do you seek a passage to ' .. keyword:titleCase() .. ' for '.. cost ..' gold coins?', cost = cost, discount = 'postman'})
travelKeyword:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, cost = cost, discount = 'postman', destination = destination}, nil, action)
travelKeyword:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, text = 'We would like to serve you some time.', reset = true})
end
addTravelKeyword('carlin', 110, Position(32387, 31820, 6), function(player) if player:getStorageValue(PlayerStorageKeys.postman.Mission01) == 1 then player:setStorageValue(PlayerStorageKeys.postman.Mission01, 2) end end)
addTravelKeyword('ab\'dendriel', 130, Position(32734, 31668, 6))
addTravelKeyword('edron', 160, Position(33175, 31764, 6))
addTravelKeyword('venore', 170, Position(32954, 32022, 6))
addTravelKeyword('port hope', 160, Position(32527, 32784, 6))
addTravelKeyword('svargrond', 180, Position(32341, 31108, 6))
addTravelKeyword('liberty bay', 180, Position(32285, 32892, 6))
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())
Last edited: