Hello as topic say's i can't get it to work (this is not a script i have made and it is to avesta 7.4 ot server)
Lua:
_state = 0
_index = 0
_delay = 750
destinations = {}
destinations[0] = {name = 'carlin', pos = {x = 32387, y = 31821, z = 7}, price = 110}
destinations[1] = {name = 'ab\'dendriel', pos = {x=32733,y=31668,z=7}, price = 130}
destinations[2] = {name = 'edron', pos = {x = 33175, y = 31764, z = 7}, price = 160}
destinations[3] = {name = 'venore', pos = {x = 32954, y = 32023, z = 7}, price = 170}
function getNext()
nextPlayer = getQueuedPlayer()
if (nextPlayer ~= nil) then
if (getDistanceToCreature(nextPlayer) <= 4) then
updateNpcIdle()
setNpcFocus(nextPlayer)
greet(nextPlayer, _delay * 2)
return
else
getNext()
end
end
setNpcFocus(0)
resetNpcIdle()
end
function _selfSay(message)
selfSay(message, _delay)
updateNpcIdle()
end
local function greet(cid, delay)
local title = 'Sir'
if (getPlayerSex(cid) == 0) then
title = 'Madam'
end
selfSay('Welcome on board, ' .. title .. ' ' .. getCreatureName(cid) .. '.', delay)
end
function onCreatureAppear(cid)
end
function onCreatureDisappear(cid)
if (getNpcFocus() == cid) then
selfSay('Good bye. Recommend us, if you were satisfied with our service.')
getNext()
else
unqueuePlayer(cid)
end
end
function onCreatureMove(cid, oldPos, newPos)
if (getNpcFocus() == cid) then
faceCreature(cid)
end
end
function onCreatureSay(cid, type, msg)
if (getNpcFocus() == 0) and ((msgcontains(msg, 'hi') or msgcontains(msg, 'hello') or msgcontains(msg, 'hej')) and getDistanceToCreature(cid) <= 4) then
updateNpcIdle()
setNpcFocus(cid)
greet(cid, _delay)
elseif (getNpcFocus() ~= cid) and ((msgcontains(msg, 'hi') or msgcontains(msg, 'hello')) and getDistanceToCreature(cid) <= 4) then
selfSay('Just wait, ' .. getCreatureName(cid) .. '.', _delay)
queuePlayer(cid)
elseif (msgcontains(msg, 'bye')) then
selfSay('Good bye. Recommend us, if you were satisfied with our service.', _delay)
getNext()
elseif (_state == 1) and (msgcontains(msg, 'yes')) and (isPremium(cid) == 1) then
(doPlayerRemoveMoney(cid, destinations[_index].price)) then
_selfSay('Set the sails!')
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_ENERGYAREA)
doTeleportThing(cid, destinations[_index].pos)
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_ENERGYAREA)
getNext()
else
_selfSay('You don\'t have enough money.')
else
_selfSay('I\'m sorry, but you need a premium account in order to travel onboard our ships.')
end
getNext() and
selfSay('We would like to serve you some time.', _delay)
_state = 0
else
for n = 0, table.getn(destinations) do
if (msgcontains(msg, destinations[n].name)) then
_index = n
_state = 1
_selfSay('Do you seek a passage to ' .. destinations[_index].name .. ' for ' .. destinations[_index].price .. ' gold?')
break
end
end
end
function onThink()
if (getNpcFocus() ~= 0) then
if (isNpcIdle() or getDistanceToCreature(getNpcFocus()) > 4) then
selfSay('Good bye. Recommend us, if you were satisfied with our service.', _delay)
getNext()
end
end
end