--[[
!---------------------------------!
!---Created by Teh Maverick-------!
!-------www.otland.net------------!
!---------------------------------!
]]
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talktopic, town, vocation, destination, voc = {}, {}, {}, {}, {}
--!!Config!!--
--Vocation setup
local vocation1 = {name = "sorcerer", id = 1,
text = "Are you sure that a Sorcerer is what you wish to become? This decision is irreversible!"}
local vocation2 = {name = "druid", id = 2,
text = "Are you sure that a Druid is what you wish to become? This decision is irreversible!"}
local vocation3 = {name = "paladin", id = 3,
text = "Are you sure that a Paladin is what you wish to become? This decision is irreversible!"}
local vocation4 = {name = "knight", id = 4,
text = "Are you sure that a Knight is what you wish to become? This decision is irreversible!"}
--Item setup
local firstItems = {
{ -- sorcerer items
{itemid=2457, count=1}, -- Steel Helmet
{itemid=8819, count=1}, -- Magician's robe
{itemid=2649, count=1}, -- Leather legs
{itemid=2643, count=1}, -- Leather Boots
{itemid=2521, count=1}, -- Dark Shield
{itemid=2190, count=1}, -- Wand of vortex
{itemid=2152, count=25}, -- Platinum Coins
{itemid=2789, count=100}, -- Brown Mushrooms
},
{ -- druid items
{itemid=2457, count=1}, -- Steel Helmet
{itemid=8819, count=1}, -- Magician's robe
{itemid=2649, count=1}, -- Leather Legs
{itemid=2643, count=1}, -- Leather Boots
{itemid=2521, count=1}, -- Dark Shield
{itemid=2182, count=1}, -- Snakebite Rod
{itemid=2152, count=25}, -- Platinum Coins
{itemid=2789, count=100}, -- Brown Mushrooms
},
{ -- paladin items
{itemid=2457, count=1}, -- Steel Helmet
{itemid=2660, count=1}, -- Ranger's cloak
{itemid=2507, count=1}, -- Ranger legs
{itemid=2643, count=1}, -- Leather Boots
{itemid=2521, count=1}, -- Dark Shield
{itemid=2389, count=10}, -- Spears
{itemid=2544, count=100}, -- Arrows
{itemid=2456, count=1}, -- Bow
{itemid=2152, count=25}, -- Platinum Coins
{itemid=2789, count=100}, -- Brown Mushrooms
},
{ -- knight items
{itemid=2457, count=1}, -- Steel Helmet
{itemid=2463, count=1}, -- Plate Armor
{itemid=2647, count=1}, -- Plate Legs
{itemid=2643, count=1}, -- Leather Boots
{itemid=2521, count=1}, -- Dark Shield
{itemid=8602, count=1}, -- Jagged Sword
{itemid=8601, count=1}, -- Steel Axe
{itemid=2423, count=1}, -- Clerical Mace
{itemid=2152, count=25}, -- Platinum Coins
{itemid=2789, count=100}, -- Brown Mushrooms
}
}
--Home Town setup
local city1 = {name = "avondale", id = 2, destination = {x=702, y=1016, z=7},
text = "Avondale, eh? So what vocation do you wish to become? {"..vocation1.name .."}, {"..vocation2.name .."}, {"..vocation3.name .."} or {"..vocation4.name .."}?"}
local city2 = {name = "calria", id = 3, destination = {x=1153, y=1139, z=7},
text = "Calria, eh? So what vocation do you wish to become? {"..vocation1.name .."}, {"..vocation2.name .."}, {"..vocation3.name .."} or {"..vocation4.name .."}?"}
local towntext = "What city do you wish to live in? {".. city1.name .."} or {".. city2.name .."}?"
--Text setup
local requiredlevel = 8
local lowlevel = "COME BACK WHEN YOU ARE LEVEL 8!"
local refuse = "Then come back when you are ready."
local refuse_voc = "Then what vocation do you want to become?"
----End Config-----
for _, items in ipairs(firstItems) do
table.insert(items, item)
end
function onCreatureAppear(cid) npcHandlernCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandlernCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandlernCreatureSay(cid, type, msg) end
function onThink() npcHandlernThink() end
function greetCallback(cid)
if(getPlayerLevel(cid) < requiredlevel) then
npcHandler:say(lowlevel, cid)
return false
else
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
talktopic[talkUser], town[talkUser], vocation[talkUser], destination[talkUser], voc[talkUser] = 0, 0, 0, 0, 0
return true
end
end
function creatureSayCallback(cid, type, msg)
talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if(not npcHandler:isFocused(cid)) then
return false
end
--Select Home Town control
if talktopic[talkUser] == 0 and msgcontains(msg, "yes") then
talktopic[talkUser] = 1 --question one, what city do you want?
npcHandler:say(towntext, cid)
elseif talktopic[talkUser] == 0 and msgcontains(msg, "no") then
talktopic[talkUser] = 0
npcHandler:unGreet(cid)
elseif talktopic[talkUser] == 1 and msgcontains(msg, city1.name) then
town[talkUser] = city1.id
destination[talkUser] = city1.destination
npcHandler:say(city1.text, cid)
talktopic[talkUser] = 2 --question two, what vocation do you want?
elseif talktopic[talkUser] == 1 and msgcontains(msg, city2.name) then
town[talkUser] = city2.id
destination[talkUser] = city2.destination
npcHandler:say(city2.text, cid)
talktopic[talkUser] = 2 --question two, what vocation do you want?
end
--Select Vocation control
if talktopic[talkUser] == 2 and msgcontains(msg, vocation1.name) then
talktopic[talkUser] = 3 --confirm dicision: are you sure you want to become...
voc[talkUser] = vocation1.id
npcHandler:say(vocation1.text, cid)
elseif talktopic[talkUser] == 2 and msgcontains(msg, vocation2.name) then
talktopic[talkUser] = 3 --confirm dicision: are you sure you want to become...
voc[talkUser] = vocation2.id
npcHandler:say(vocation2.text, cid)
elseif talktopic[talkUser] == 2 and msgcontains(msg, vocation3.name) then
talktopic[talkUser] = 3 --confirm dicision: are you sure you want to become...
voc[talkUser] = vocation3.id
npcHandler:say(vocation3.text, cid)
elseif talktopic[talkUser] == 2 and msgcontains(msg, vocation4.name) then
talktopic[talkUser] = 3 --confirm dicision: are you sure you want to become...
voc[talkUser] = vocation4.id
npcHandler:say(vocation4.text, cid)
end
--Confirm your choice control
if talktopic[talkUser] == 3 and msgcontains(msg, 'yes') then
talktopic[talkUser] = 4
vocation[talkUser] = voc[talkUser]
elseif talktopic[talkUser] == 3 and msgcontains(msg, 'no') then
talktopic[talkUser] = 2
npcHandler:say(refuse_voc, cid)
voc[talkUser] = 0
end
if(destination[talkUser] ~= 0 and vocation[talkUser] ~= 0 and town[talkUser] ~= 0 and talktopic[talkUser] == 4) then
if(getPlayerLevel(cid) < requiredlevel) then
npcHandler:say('You must first reach level ' .. requiredlevel .. '!', cid)
npcHandler:resetNpc()
else
if(getPlayerVocation(cid) > 0) then
npcHandler:say('Sorry, You already have a vocation!', cid)
npcHandler:resetNpc()
else
doPlayerSetVocation(cid, vocation[talkUser])
doPlayerSetTown(cid, town[talkUser])
npcHandler:resetNpc()
local tmp = getCreaturePosition(cid)
doTeleportThing(cid, destination[talkUser])
doSendMagicEffect(tmp, CONST_ME_POFF)
doSendMagicEffect(destination, CONST_ME_TELEPORT)
itemThink(cid)
end
end
end
return true
end
function itemThink(cid)
talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local backpack = doCreateItemEx(1988, 1)
local giveItems = firstItems[vocation[talkUser]]
if giveItems ~= nil then
for _, v in ipairs(giveItems) do
doAddContainerItem(backpack, v.itemid, v.count or 1)
end
local addItem = doPlayerAddItemEx(cid, backpack, 0)
if (addItem == RETURNVALUE_NOERROR and getPlayerStorageValue(cid,9011) < 1) then
setPlayerStorageValue(cid,9011,1)
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,'You recieved items from the Oracle.')
return true
elseif addItem == RETURNVALUE_NOTENOUGHCAPACITY then
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,'you don\'t have enough capacity for your start items, please make capacity by dropping items.')
addEvent(itemThink,10000,cid)
return true
end
end
return true
end
npcHandler:setMessage(MESSAGE_GREET, "Hello |PLAYERNAME|. Are you prepared to face your destiny?")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Goodbye adventurer!")
npcHandler:setMessage(MESSAGE_FAREWELL, "come back when you are ready!")
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
--[[
!---------------------------------!
!---Created by Teh Maverick-------!
!-------www.otland.net------------!
!---------------------------------!
]]
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talktopic, town, vocation, destination, voc = {}, {}, {}, {}, {}
--!!Config!!--
--Vocation setup
local vocation1 = {name = "sorcerer", id = 1,
text = "Are you sure that a Sorcerer is what you wish to become? This decision is irreversible!"}
local vocation2 = {name = "druid", id = 2,
text = "Are you sure that a Druid is what you wish to become? This decision is irreversible!"}
local vocation3 = {name = "paladin", id = 3,
text = "Are you sure that a Paladin is what you wish to become? This decision is irreversible!"}
local vocation4 = {name = "knight", id = 4,
text = "Are you sure that a Knight is what you wish to become? This decision is irreversible!"}
--Item setup
local firstItems = {
{ -- sorcerer items
{itemid=2457, count=1}, -- Steel Helmet
{itemid=8819, count=1}, -- Magician's robe
{itemid=2649, count=1}, -- Leather legs
{itemid=2643, count=1}, -- Leather Boots
{itemid=2521, count=1}, -- Dark Shield
{itemid=2190, count=1}, -- Wand of vortex
{itemid=2152, count=25}, -- Platinum Coins
{itemid=2789, count=100}, -- Brown Mushrooms
},
{ -- druid items
{itemid=2457, count=1}, -- Steel Helmet
{itemid=8819, count=1}, -- Magician's robe
{itemid=2649, count=1}, -- Leather Legs
{itemid=2643, count=1}, -- Leather Boots
{itemid=2521, count=1}, -- Dark Shield
{itemid=2182, count=1}, -- Snakebite Rod
{itemid=2152, count=25}, -- Platinum Coins
{itemid=2789, count=100}, -- Brown Mushrooms
},
{ -- paladin items
{itemid=2457, count=1}, -- Steel Helmet
{itemid=2660, count=1}, -- Ranger's cloak
{itemid=2507, count=1}, -- Ranger legs
{itemid=2643, count=1}, -- Leather Boots
{itemid=2521, count=1}, -- Dark Shield
{itemid=2389, count=10}, -- Spears
{itemid=2544, count=100}, -- Arrows
{itemid=2456, count=1}, -- Bow
{itemid=2152, count=25}, -- Platinum Coins
{itemid=2789, count=100}, -- Brown Mushrooms
},
{ -- knight items
{itemid=2457, count=1}, -- Steel Helmet
{itemid=2463, count=1}, -- Plate Armor
{itemid=2647, count=1}, -- Plate Legs
{itemid=2643, count=1}, -- Leather Boots
{itemid=2521, count=1}, -- Dark Shield
{itemid=8602, count=1}, -- Jagged Sword
{itemid=8601, count=1}, -- Steel Axe
{itemid=2423, count=1}, -- Clerical Mace
{itemid=2152, count=25}, -- Platinum Coins
{itemid=2789, count=100}, -- Brown Mushrooms
}
}
--Home Town setup
local city1 = {name = "avondale", id = 2, destination = {x=702, y=1016, z=7},,
text = "Avondale, eh? So what vocation do you wish to become? {"..vocation1.name .."}, {"..vocation2.name .."}, {"..vocation3.name .."} or {"..vocation4.name .."}?"}
local city2 = {name = "calria", id = 3, destination = {x=1153, y=1139, z=7},
text = "Calria, eh? So what vocation do you wish to become? {"..vocation1.name .."}, {"..vocation2.name .."}, {"..vocation3.name .."} or {"..vocation4.name .."}?"}
local towntext = "What city do you wish to live in? {".. city1.name .."} or {".. city2.name .."}?"
--Text setup
local requiredlevel = 8
local lowlevel = "COME BACK WHEN YOU ARE LEVEL 8!"
local refuse = "Then come back when you are ready."
local refuse_voc = "Then what vocation do you want to become?"
----End Config-----
for _, items in ipairs(firstItems) do
table.insert(items, item)
end
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
function greetCallback(cid)
if(getPlayerLevel(cid) < requiredlevel) then
npcHandler:say(lowlevel, cid)
return false
else
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
talktopic[talkUser], town[talkUser], vocation[talkUser], destination[talkUser], voc[talkUser] = 0, 0, 0, 0, 0
return true
end
end
function creatureSayCallback(cid, type, msg)
talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if(not npcHandler:isFocused(cid)) then
return false
end
--Select Home Town control
if talktopic[talkUser] == 0 and msgcontains(msg, "yes") then
talktopic[talkUser] = 1 --question one, what city do you want?
npcHandler:say(towntext, cid)
elseif talktopic[talkUser] == 0 and msgcontains(msg, "no") then
talktopic[talkUser] = 0
npcHandler:unGreet(cid)
elseif talktopic[talkUser] == 1 and msgcontains(msg, city1.name) then
town[talkUser] = city1.id
destination[talkUser] = city1.destination
npcHandler:say(city1.text, cid)
talktopic[talkUser] = 2 --question two, what vocation do you want?
elseif talktopic[talkUser] == 1 and msgcontains(msg, city2.name) then
town[talkUser] = city2.id
destination[talkUser] = city2.destination
npcHandler:say(city2.text, cid)
talktopic[talkUser] = 2 --question two, what vocation do you want?
end
--Select Vocation control
if talktopic[talkUser] == 2 and msgcontains(msg, vocation1.name) then
talktopic[talkUser] = 3 --confirm dicision: are you sure you want to become...
voc[talkUser] = vocation1.id
npcHandler:say(vocation1.text, cid)
elseif talktopic[talkUser] == 2 and msgcontains(msg, vocation2.name) then
talktopic[talkUser] = 3 --confirm dicision: are you sure you want to become...
voc[talkUser] = vocation2.id
npcHandler:say(vocation2.text, cid)
elseif talktopic[talkUser] == 2 and msgcontains(msg, vocation3.name) then
talktopic[talkUser] = 3 --confirm dicision: are you sure you want to become...
voc[talkUser] = vocation3.id
npcHandler:say(vocation3.text, cid)
elseif talktopic[talkUser] == 2 and msgcontains(msg, vocation4.name) then
talktopic[talkUser] = 3 --confirm dicision: are you sure you want to become...
voc[talkUser] = vocation4.id
npcHandler:say(vocation4.text, cid)
end
--Confirm your choice control
if talktopic[talkUser] == 3 and msgcontains(msg, 'yes') then
talktopic[talkUser] = 4
vocation[talkUser] = voc[talkUser]
elseif talktopic[talkUser] == 3 and msgcontains(msg, 'no') then
talktopic[talkUser] = 2
npcHandler:say(refuse_voc, cid)
voc[talkUser] = 0
end
if(destination[talkUser] ~= 0 and vocation[talkUser] ~= 0 and town[talkUser] ~= 0 and talktopic[talkUser] == 4) then
if(getPlayerLevel(cid) < requiredlevel) then
npcHandler:say('You must first reach level ' .. requiredlevel .. '!', cid)
npcHandler:resetNpc()
else
if(getPlayerVocation(cid) > 0) then
npcHandler:say('Sorry, You already have a vocation!', cid)
npcHandler:resetNpc()
else
doPlayerSetVocation(cid, vocation[talkUser])
doPlayerSetTown(cid, town[talkUser])
npcHandler:resetNpc()
local tmp = getCreaturePosition(cid)
doTeleportThing(cid, destination[talkUser])
doSendMagicEffect(tmp, CONST_ME_POFF)
doSendMagicEffect(destination, CONST_ME_TELEPORT)
itemThink(cid)
end
end
end
return true
end
function itemThink(cid)
talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local backpack = doCreateItemEx(1988, 1)
local giveItems = firstItems[vocation[talkUser]]
if giveItems ~= nil then
for _, v in ipairs(giveItems) do
doAddContainerItem(backpack, v.itemid, v.count or 1)
end
local addItem = doPlayerAddItemEx(cid, backpack, 0)
if (addItem == RETURNVALUE_NOERROR and getPlayerStorageValue(cid,9011) < 1) then
setPlayerStorageValue(cid,9011,1)
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,'Yo u recieved items from the Oracle.')
return true
elseif addItem == RETURNVALUE_NOTENOUGHCAPACITY then
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,'yo u don\'t have enough capacity for your start items, please make capacity by dropping items.')
addEvent(itemThink,10000,cid)
return true
end
end
return true
end
npcHandler:setMessage(MESSAGE_GREET, "Hello |PLAYERNAME|. Are you prepared to face your destiny?")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Goodbye adventurer!")
npcHandler:setMessage(MESSAGE_FAREWELL, "come back when you are ready!")
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Can anyone make for me simple npc ?
Npc can teleport player to position 377 377 6 when player get lvl 8 and change his hometown to 2?
20:13 Captain : So what vocation do you wish to become? sorcerer, druid, paladin or knight?
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
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
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local newpos = {337,337,6}
if(msgcontains(msg, 'CITY_NAME') then
selfSay('MSG_INFO', cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if doPlayerRemoveMoney(cid, MONEY_YOU_WANT) then -- If you dont want to make player pay for this, remove this line.
doPlayerSetTown(cid, 2)
doTeleportThing(cid, newpos)
doSendMagicEffect(getThingPos(cid), 10)
selfSay('MSG_WHEN_YOU_GO_TO_NEWPOS.', cid)
talkState[talkUser] = 0
else
selfSay('Sorry, you don\'t have enough gold.', cid) -- If you dont want to make player pay for this, remove "else and this line.
end
talkState[talkUser] = 0
elseif(msgcontains(msg, 'no') talkState[talkUser]) == TRUE) then
talkState[talkUser] = 0
selfSay('Ok come back when you need this.', cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
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
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local newpos = {337,337,6}
if(msgcontains(msg, 'CITY_NAME')) then
selfSay('MSG_INFO', cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if doPlayerRemoveMoney(cid, MONEY_YOU_WANT) then -- If you dont want to make player pay for this, remove this line.
doPlayerSetTown(cid, 2)
doTeleportThing(cid, newpos)
doSendMagicEffect(getThingPos(cid), 10)
selfSay('MSG_WHEN_YOU_GO_TO_NEWPOS.', cid)
talkState[talkUser] = 0
else
selfSay('Sorry, you don\'t have enough gold.', cid) -- If you dont want to make player pay for this, remove "else and this line.
end
talkState[talkUser] = 0
elseif(msgcontains(msg, 'no') talkState[talkUser]) == TRUE) then
talkState[talkUser] = 0
selfSay('Ok come back when you need this.', cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())