LucasFerraz
Systems Analyst
BOAT LIB V 2.1
Why should you use it?
1. Create lib: 204-boats.lua
2. Copy this code inside:
3. NPC Script:
4. Add your cities to lib and NPC script file
5. Set all your boat npcs to use this script
Missing:
1. Maybe optimize NPC script to use less code (I dont know how to do it yet)
2. Function GetActiveBoats() needs a review. I did my best doing that but its not the best solution.
Why should you use it?
- Easy to change prices
- Easy to change boat position to TP
- Easy to change messages
- Work with this vip system
- Vip accounts have % discount on all boats
- Use vip=true to restrict this city to vip accounts
- Enable and disable city access using active=true or false
- Enable BOAT_PREMIUM = true to restrict premium cities only to premium accounts
1. Create lib: 204-boats.lua
2. Copy this code inside:
Lua:
--[ BOAT LIB BY LUCAS FERRAZ ]--
BOAT_GREET = "Welcome on board, |PLAYERNAME|. Do you want to {travel}? I can take you to "
BOAT_FAREWELL = "Bye |PLAYERNAME|."
BOAT_WALKAWAY = "The minimum of education is essential for human beings."
BOAT_IDLETIMEOUT = "Don't waste my time, I have other things to do."
BOAT_PREMIUM = false
BOAT_VIP_DISCOUNT = 0.50 -- 50%
CUSTOMBOATS = {
[3] = {
active = true,
city = "Carlin",
price = 110,
premium = false,
vip = false,
pos = {x=32387, y=31820, z=6},
msg_tp = "It was a pleasure to take you.",
msg_price = "Come back when you have enough money. The price to go to Carlin is 110 gold coins? VIP has 50% off.",
msg_pz = "First get rid of those bloodstains! You will not soil my ship!",
msg_vip = "You need to be a VIP to travel to Carlin.",
msg_premium = "You need a premium account to travel to Carlin.",
effect = CONST_ME_TELEPORT
},
[4] = {
active = true,
city = "Thais",
price = 110,
premium = false,
vip = false,
pos = {x=32310, y=32210, z=6},
msg_tp = "It was a pleasure to take you.",
msg_price = "Come back when you have enough money. The price to go to Thais is 110 gold coins? VIP has 50% off.",
msg_pz = "First get rid of those bloodstains! You will not soil my ship!",
msg_vip = "You need to be a VIP to travel to Thais.",
msg_premium = "You need a premium account to travel to Thais.",
effect = CONST_ME_TELEPORT
},
[5] = {
active = true,
city = "Venore",
price = 110,
premium = false,
vip = false,
pos = {x=32952, y=32022, z=6},
msg_tp = "It was a pleasure to take you.",
msg_price = "Come back when you have enough money. The price to go to Venore is 110 gold coins? VIP has 50% off.",
msg_pz = "First get rid of those bloodstains! You will not soil my ship!",
msg_vip = "You need to be a VIP to travel to Venore.",
msg_premium = "You need a premium account to travel to Venore.",
effect = CONST_ME_TELEPORT
},
[6] = {
active = true,
city = "Ankrahmun",
price = 110,
premium = true,
vip = false,
pos = {x=33092, y=32883, z=6},
msg_tp = "It was a pleasure to take you.",
msg_price = "Come back when you have enough money. The price to go to Ankrahmun is 110 gold coins? VIP has 50% off.",
msg_pz = "First get rid of those bloodstains! You will not soil my ship!",
msg_vip = "You need to be a VIP to travel to Ankrahmun.",
msg_premium = "You need a premium account to travel to Ankrahmun.",
effect = CONST_ME_TELEPORT
},
[7] = {
active = true,
city = "ab'dendriel",
price = 110,
premium = false,
vip = false,
pos = {x=32734, y=31668, z=6},
msg_tp = "It was a pleasure to take you.",
msg_price = "Come back when you have enough money. The price to go to Ab'dendriel is 110 gold coins? VIP has 50% off.",
msg_pz = "First get rid of those bloodstains! You will not soil my ship!",
msg_vip = "You need to be a VIP to travel to Ab'dendriel.",
msg_premium = "You need a premium account to travel to Ab'dendriel.",
effect = CONST_ME_TELEPORT
},
[8] = {
active = true,
city = "Cormaya",
price = 110,
premium = true,
vip = false,
pos = {x=33287, y=31955, z=6},
msg_tp = "It was a pleasure to take you.",
msg_price = "Come back when you have enough money. The price to go to Cormaya is 110 gold coins? VIP has 50% off.",
msg_pz = "First get rid of those bloodstains! You will not soil my ship!",
msg_vip = "You need to be a VIP to travel to Cormaya.",
msg_premium = "You need a premium account to travel to Cormaya.",
effect = CONST_ME_TELEPORT
},
[9] = {
active = true,
city = "Darashia",
price = 110,
premium = true,
vip = false,
pos = {x=33289, y=32480, z=6},
msg_tp = "It was a pleasure to take you.",
msg_price = "Come back when you have enough money. The price to go to Darashia is 110 gold coins? VIP has 50% off.",
msg_pz = "First get rid of those bloodstains! You will not soil my ship!",
msg_vip = "You need to be a VIP to travel to Darashia.",
msg_premium = "You need a premium account to travel to Darashia.",
effect = CONST_ME_TELEPORT
},
[10] = {
active = true,
city = "Edron",
price = 110,
premium = true,
vip = false,
pos = {x=33173, y=31764, z=6},
msg_tp = "It was a pleasure to take you.",
msg_price = "Come back when you have enough money. The price to go to Edron is 110 gold coins? VIP has 50% off.",
msg_pz = "First get rid of those bloodstains! You will not soil my ship!",
msg_vip = "You need to be a VIP to travel to Edron.",
msg_premium = "You need a premium account to travel to Edron.",
effect = CONST_ME_TELEPORT
},
[11] = {
active = true,
city = "Farmine",
price = 110,
premium = true,
vip = false,
pos = {x=33025, y=31553, z=10},
msg_tp = "It was a pleasure to take you.",
msg_price = "Come back when you have enough money. The price to go to Farmine is 110 gold coins? VIP has 50% off.",
msg_pz = "First get rid of those bloodstains! You will not soil my ship!",
msg_vip = "You need to be a VIP to travel to Farmine.",
msg_premium = "You need a premium account to travel to Farmine.",
effect = CONST_ME_TELEPORT
},
[14] = {
active = true,
city = "Kazordoon",
price = 110,
premium = false,
vip = false,
pos = {x=32659, y=31958, z=15},
msg_tp = "It was a pleasure to take you.",
msg_price = "Come back when you have enough money. The price to go to Kazordoon is 110 gold coins? VIP has 50% off.",
msg_pz = "First get rid of those bloodstains! You will not soil my ship!",
msg_vip = "You need to be a VIP to travel to Kazordoon.",
msg_premium = "You need a premium account to travel to Port Kazordoon.",
effect = CONST_ME_TELEPORT
},
[15] = {
active = true,
city = "Liberty Bay",
price = 110,
premium = true,
vip = false,
pos = {x=32285, y=32891, z=6},
msg_tp = "It was a pleasure to take you.",
msg_price = "Come back when you have enough money. The price to go to Liberty Bay is 110 gold coins? VIP has 50% off.",
msg_pz = "First get rid of those bloodstains! You will not soil my ship!",
msg_vip = "You need to be a VIP to travel to Liberty Bay.",
msg_premium = "You need a premium account to travel to Port Liberty Bay.",
effect = CONST_ME_TELEPORT
},
[18] = {
active = false,
city = "Northport",
price = 110,
premium = false,
vip = false,
pos = {x=32486, y=31590, z=7},
msg_tp = "It was a pleasure to take you.",
msg_price = "Come back when you have enough money. The price to go to Northport is 110 gold coins? VIP has 50% off.",
msg_pz = "First get rid of those bloodstains! You will not soil my ship!",
msg_vip = "You need to be a VIP to travel to Northport.",
msg_premium = "You need a premium account to travel to Port Northport.",
effect = CONST_ME_TELEPORT
},
[21] = {
active = true,
city = "Port Hope",
price = 110,
premium = true,
vip = false,
pos = {x=32529, y=32784, z=6},
msg_tp = "It was a pleasure to take you.",
msg_price = "Come back when you have enough money. The price to go to Port Hope is 110 gold coins? VIP has 50% off.",
msg_pz = "First get rid of those bloodstains! You will not soil my ship!",
msg_vip = "You need to be a VIP to travel to Port Hope.",
msg_premium = "You need a premium account to travel to Port Hope.",
effect = CONST_ME_TELEPORT
},
[24] = {
active = true,
city = "Svargrond",
price = 110,
premium = true,
vip = false,
pos = {x=32341, y=31108, z=6},
msg_tp = "It was a pleasure to take you.",
msg_price = "Come back when you have enough money. The price to go to Svargrond is 110 gold coins? VIP has 50% off.",
msg_pz = "First get rid of those bloodstains! You will not soil my ship!",
msg_vip = "You need to be a VIP to travel to Svargrond.",
msg_premium = "You need a premium account to travel to Svargrond.",
effect = CONST_ME_TELEPORT
},
[25] = {
active = true,
city = "Yalahar",
price = 110,
premium = true,
vip = false,
pos = {x=32816, y=31272, z=6},
msg_tp = "It was a pleasure to take you.",
msg_price = "Come back when you have enough money. The price to go to Yalahar is 110 gold coins? VIP has 50% off.",
msg_pz = "First get rid of those bloodstains! You will not soil my ship!",
msg_vip = "You need to be a VIP to travel to Yalahar.",
msg_premium = "You need a premium account to travel to Yalahar.",
effect = CONST_ME_TELEPORT
}
}
function BoatProcedure(cid, param)
if (vip.getVip(cid) < 1 and (param.vip == true)) then
selfSay(param.msg_vip, cid)
return true
end
if (not isPremium(cid) and (param.vip == premium)) then
selfSay(param.msg_premium, cid)
return true
end
local price = param.price
if vip.getVip(cid) > 0 then
price = BOAT_VIP_DISCOUNT*price
end
if(getPlayerMoney(cid) >= price) then
doPlayerRemoveMoney(cid, price)
else
if(getPlayerBalance(cid) >= price) then
doPlayerSetBalance(cid, getPlayerBalance(cid) - price)
else
selfSay(param.msg_price, cid)
return true
end
end
if isPlayerPzLocked(cid) then
selfSay(param.msg_pz, cid)
return true
end
doTeleportThing(cid, param.pos)
doSendMagicEffect(getCreaturePosition(cid), param.effect)
selfSay(param.msg_tp, cid)
return true
end
function GetActiveBoats()
local param = ''
local first_city = 3
local last_city = 30
local temp = false
for i = first_city, last_city do
if(CUSTOMBOATS[i]) then
if(CUSTOMBOATS[i].active == true and CUSTOMBOATS[i].vip == false) then
if(i == first_city) then
param = '{'..CUSTOMBOATS[i].city..'}'
else
param = param..', {'..CUSTOMBOATS[i].city..'}'
end
end
if(CUSTOMBOATS[i].active == true and CUSTOMBOATS[i].vip == true) then
if(temp == false) then
param = param..'.\nI can also take you to '
temp = true
end
if(i == first_city) then
param = param..' {'..CUSTOMBOATS[i].city..'}'
elseif(i == last_city-1) then
param = param..'and {'..CUSTOMBOATS[i].city..'} but these locations requires VIP access.'
elseif(i == last_city-2) then
param = param..'{'..CUSTOMBOATS[i].city..'} '
else
param = param..'{'..CUSTOMBOATS[i].city..'}, '
end
end
end
end
return param
end
3. NPC Script:
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
npcHandler:setMessage(MESSAGE_GREET, BOAT_GREET..GetActiveBoats())
npcHandler:setMessage(MESSAGE_FAREWELL, BOAT_FAREWELL)
npcHandler:setMessage(MESSAGE_WALKAWAY, BOAT_WALKAWAY)
npcHandler:setMessage(MESSAGE_IDLETIMEOUT, BOAT_IDLETIMEOUT)
--[ Carlin ] --
local city = CUSTOMBOATS[3]
local node3
if (city.active == true) then
local function carlin(cid, message, keywords, parameters, node)
if(not npcHandler:isFocused(cid)) then
return false
end
BoatProcedure(cid, city)
npcHandler:resetNpc(cid)
return true
end
node3 = keywordHandler:addKeyword({'carlin'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to travel to '..city.city..' for '..city.price..' gold coins?'})
node3:addChildKeyword({'yes'}, carlin, {npcHandler = npcHandler, onlyFocus = true, reset = true})
node3:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ok then.', reset = true})
end
--[ Thais ] --
local city = CUSTOMBOATS[4]
local node4
if (city.active == true) then
local function thais(cid, message, keywords, parameters, node)
if(not npcHandler:isFocused(cid)) then
return false
end
BoatProcedure(cid, city)
npcHandler:resetNpc(cid)
return true
end
node4 = keywordHandler:addKeyword({'thais'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to travel to '..city.city..' for '..city.price..' gold coins?'})
node4:addChildKeyword({'yes'}, thais, {npcHandler = npcHandler, onlyFocus = true, reset = true})
node4:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ok then.', reset = true})
end
--[ Venore ] --
local city = CUSTOMBOATS[5]
local node5
if (city.active == true) then
local function venore(cid, message, keywords, parameters, node)
if(not npcHandler:isFocused(cid)) then
return false
end
BoatProcedure(cid, city)
npcHandler:resetNpc(cid)
return true
end
node5 = keywordHandler:addKeyword({'venore'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to travel to '..city.city..' for '..city.price..' gold coins?'})
node5:addChildKeyword({'yes'}, venore, {npcHandler = npcHandler, onlyFocus = true, reset = true})
node5:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ok then.', reset = true})
end
--[ Ankrahmun ] --
local city = CUSTOMBOATS[6]
local node6
if (city.active == true) then
local function ankrahmun(cid, message, keywords, parameters, node)
if(not npcHandler:isFocused(cid)) then
return false
end
BoatProcedure(cid, city)
npcHandler:resetNpc(cid)
return true
end
node6 = keywordHandler:addKeyword({'ankrahmun'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to travel to '..city.city..' for '..city.price..' gold coins?'})
node6:addChildKeyword({'yes'}, ankrahmun, {npcHandler = npcHandler, onlyFocus = true, reset = true})
node6:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ok then.', reset = true})
end
--[ Ab'dendriel ] --
local city = CUSTOMBOATS[7]
local node7
if (city.active == true) then
local function abdendriel(cid, message, keywords, parameters, node)
if(not npcHandler:isFocused(cid)) then
return false
end
BoatProcedure(cid, city)
npcHandler:resetNpc(cid)
return true
end
node7 = keywordHandler:addKeyword({"ab'dendriel"}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to travel to '..city.city..' for '..city.price..' gold coins?'})
node7:addChildKeyword({'yes'}, abdendriel, {npcHandler = npcHandler, onlyFocus = true, reset = true})
node7:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ok then.', reset = true})
end
--[ Cormaya ] --
local city = CUSTOMBOATS[8]
local node8
if (city.active == true) then
local function cormaya(cid, message, keywords, parameters, node)
if(not npcHandler:isFocused(cid)) then
return false
end
BoatProcedure(cid, city)
npcHandler:resetNpc(cid)
return true
end
node8 = keywordHandler:addKeyword({"cormaya"}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to travel to '..city.city..' for '..city.price..' gold coins?'})
node8:addChildKeyword({'yes'}, cormaya, {npcHandler = npcHandler, onlyFocus = true, reset = true})
node8:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ok then.', reset = true})
end
--[ Darashia ] --
local city = CUSTOMBOATS[9]
local node9
if (city.active == true) then
local function darashia(cid, message, keywords, parameters, node)
if(not npcHandler:isFocused(cid)) then
return false
end
BoatProcedure(cid, city)
npcHandler:resetNpc(cid)
return true
end
node9 = keywordHandler:addKeyword({"darashia"}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to travel to '..city.city..' for '..city.price..' gold coins?'})
node9:addChildKeyword({'yes'}, darashia, {npcHandler = npcHandler, onlyFocus = true, reset = true})
node9:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ok then.', reset = true})
end
--[ Edron ] --
local city = CUSTOMBOATS[10]
local node10
if (city.active == true) then
local function edron(cid, message, keywords, parameters, node)
if(not npcHandler:isFocused(cid)) then
return false
end
BoatProcedure(cid, city)
npcHandler:resetNpc(cid)
return true
end
node10 = keywordHandler:addKeyword({"edron"}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to travel to '..city.city..' for '..city.price..' gold coins?'})
node10:addChildKeyword({'yes'}, edron, {npcHandler = npcHandler, onlyFocus = true, reset = true})
node10:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ok then.', reset = true})
end
--[ Farmine ] --
local city = CUSTOMBOATS[11]
local node11
if (city.active == true) then
local function farmine(cid, message, keywords, parameters, node)
if(not npcHandler:isFocused(cid)) then
return false
end
BoatProcedure(cid, city)
npcHandler:resetNpc(cid)
return true
end
node11 = keywordHandler:addKeyword({"farmine"}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to travel to '..city.city..' for '..city.price..' gold coins?'})
node11:addChildKeyword({'yes'}, farmine, {npcHandler = npcHandler, onlyFocus = true, reset = true})
node11:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ok then.', reset = true})
end
--[ Kazordoon ] --
local city = CUSTOMBOATS[14]
local node14
if (city.active == true) then
local function kazordoon(cid, message, keywords, parameters, node)
if(not npcHandler:isFocused(cid)) then
return false
end
BoatProcedure(cid, city)
npcHandler:resetNpc(cid)
return true
end
node14 = keywordHandler:addKeyword({"kazordoon"}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to travel to '..city.city..' for '..city.price..' gold coins?'})
node14:addChildKeyword({'yes'}, kazordoon, {npcHandler = npcHandler, onlyFocus = true, reset = true})
node14:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ok then.', reset = true})
end
--[ Liberty Bay ] --
local city = CUSTOMBOATS[15]
local node15
if (city.active == true) then
local function libertybay(cid, message, keywords, parameters, node)
if(not npcHandler:isFocused(cid)) then
return false
end
BoatProcedure(cid, city)
npcHandler:resetNpc(cid)
return true
end
node15 = keywordHandler:addKeyword({"liberty bay"}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to travel to '..city.city..' for '..city.price..' gold coins?'})
node15:addChildKeyword({'yes'}, libertybay, {npcHandler = npcHandler, onlyFocus = true, reset = true})
node15:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ok then.', reset = true})
end
--[ Northport ] --
local city = CUSTOMBOATS[18]
local node18
if (city.active == true) then
local function northport(cid, message, keywords, parameters, node)
if(not npcHandler:isFocused(cid)) then
return false
end
BoatProcedure(cid, city)
npcHandler:resetNpc(cid)
return true
end
node18 = keywordHandler:addKeyword({"northport"}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to travel to '..city.city..' for '..city.price..' gold coins?'})
node18:addChildKeyword({'yes'}, northport, {npcHandler = npcHandler, onlyFocus = true, reset = true})
node18:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ok then.', reset = true})
end
--[ Port Hope ] --
local city = CUSTOMBOATS[21]
local node21
if (city.active == true) then
local function porthope(cid, message, keywords, parameters, node)
if(not npcHandler:isFocused(cid)) then
return false
end
BoatProcedure(cid, city)
npcHandler:resetNpc(cid)
return true
end
node21 = keywordHandler:addKeyword({"port hope"}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to travel to '..city.city..' for '..city.price..' gold coins?'})
node21:addChildKeyword({'yes'}, porthope, {npcHandler = npcHandler, onlyFocus = true, reset = true})
node21:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ok then.', reset = true})
end
--[ Svargrond ] --
local city = CUSTOMBOATS[24]
local node24
if (city.active == true) then
local function svargrond(cid, message, keywords, parameters, node)
if(not npcHandler:isFocused(cid)) then
return false
end
BoatProcedure(cid, city)
npcHandler:resetNpc(cid)
return true
end
node24 = keywordHandler:addKeyword({"svargrond"}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to travel to '..city.city..' for '..city.price..' gold coins?'})
node24:addChildKeyword({'yes'}, svargrond, {npcHandler = npcHandler, onlyFocus = true, reset = true})
node24:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ok then.', reset = true})
end
--[ Yalahar ] --
local city = CUSTOMBOATS[25]
local node25
if (city.active == true) then
local function yalahar(cid, message, keywords, parameters, node)
if(not npcHandler:isFocused(cid)) then
return false
end
BoatProcedure(cid, city)
npcHandler:resetNpc(cid)
return true
end
node25 = keywordHandler:addKeyword({"yalahar"}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to travel to '..city.city..' for '..city.price..' gold coins?'})
node25:addChildKeyword({'yes'}, yalahar, {npcHandler = npcHandler, onlyFocus = true, reset = true})
node25:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ok then.', reset = true})
end
npcHandler:addModule(FocusModule:new())
4. Add your cities to lib and NPC script file
5. Set all your boat npcs to use this script
Missing:
1. Maybe optimize NPC script to use less code (I dont know how to do it yet)
2. Function GetActiveBoats() needs a review. I did my best doing that but its not the best solution.
Last edited: