8408323
Hoster
- Joined
- Mar 6, 2009
- Messages
- 432
- Reaction score
- 26
Hello, I can't get the
command to work in this script (inside the last elseif)
Any thoughts on how to set sail=1, not sure why it doesn't work.
Thanks in advice,
8408323
Code:
sail = 1
Any thoughts on how to set sail=1, not sure why it doesn't work.
Code:
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 onPlayerEndTrade(cid) npcHandler:onPlayerEndTrade(cid) end
function onPlayerCloseChannel(cid) npcHandler:onPlayerCloseChannel(cid) end
function onThink() npcHandler:onThink() end
function creatureSayCallback(cid, type, msg)
local newPosition = {x=95, y=117, z=7}
local cost = 50
local sail = 0
local player = Player(cid)
local oldPosition = player:getPosition()
if (msgcontains(msg, "hello") or msgcontains(msg, "hi")) and (not npcHandler:isFocused(cid)) then
npcHandler:say('Hello there ' .. getPlayerName(cid) .. ', I only {sail} to Lake Arbor and back here. ' .. cost ..' gold for non-premium members, premium members sails for free.', cid)
npcHandler:addFocus(cid)
elseif(not npcHandler:isFocused(cid)) then
return false
elseif msgcontains(msg, "bye") or msgcontains(msg, "farewell") then
npcHandler:say("Goodbye, take care!", cid, TRUE)
npcHandler:releaseFocus(cid)
elseif msgcontains(msg, "sail") or msgcontains(msg, "travel") then
npcHandler:say("Would you like to sail to {Lake Arbor}?", cid)
sail = 1
elseif(msgcontains(msg, 'yes') and sail == 1) then
if isPremium(cid) then
cost = 0
end
if(doPlayerRemoveMoney(cid, cost) == TRUE) then
player:teleportTo(newPosition, true)
if not player:isInGhostMode() then
oldPosition:sendMagicEffect(CONST_ME_POFF)
newPosition:sendMagicEffect(CONST_ME_TELEPORT)
end
selfSay('You\'ve successfully arrived to Lake Arbor.', cid)
else
selfSay('Sorry, you don\'t have enough gold coins to sail with me.', cid)
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:setMessage(MESSAGE_WALKAWAY, "Well, you could at lest say goodbye!")
Thanks in advice,
8408323