<?xml version="1.0" encoding="UTF-8"?>
<npc name="Npc Name" script="data/npc/scripts/script_name.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="130" head="2" body="37" legs="35" feet="47" addons="3"/>
</npc>
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 greet(cid) talkState[cid] = 0 return true end
function getNpcName()
return getCreatureName(getNpcId())
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
if msgcontains(msg, "job") then
selfSay("My job is to show the world how fashionable they can be!", cid)
elseif msgcontains(msg, "name") then
selfSay("My name is " .. getNpcName() .. ".", cid)
elseif msgcontains(msg, "travel") then
selfSay("Where would you like to travel? I can give you a list of places you can travel, if you wish.", cid)
elseif msgcontains(msg, "list") then
selfSay("I travel to Thais, Venore, Ab'Dendriel, Carlin and Edron.", cid)
elseif msgcontains(msg, "thais") then
selfSay("Would you like to travel to Thais for 140 gold?", cid)
talkState[talkUser] = 1
elseif msgcontains(msg, "venore") then
selfSay("Would you like to travel to Venore for 160 gold?", cid)
talkState[talkUser] = 2
elseif msgcontains(msg, "ab'dendriel") then
selfSay("Would you like to travel to Ab'Dendriel for 110 gold?", cid)
talkState[talkUser] = 3
elseif msgcontains(msg, "carlin") then
selfSay("Would you like to travel to Carlin for 120 gold?", cid)
talkState[talkUser] = 4
elseif msgcontains(msg, "edron") then
selfSay("Would you like to travel to Edron for 170 gold?", cid)
talkState[talkUser] = 5
elseif msgcontains(msg, "yes") and talkState[talkUser] >= 1 and talkState[talkUser] <= 5 then
if talkState[talkUser] == 1 and doPlayerRemoveMoney(cid, 140) then
selfSay("Setting sail to Thais!", cid)
talkState[talkUser] = 0
doTeleportThing(cid, {x = 1000, y = 1000, z = 7})
elseif talkState[talkUser] == 2 and doPlayerRemoveMoney(cid, 160) then
selfSay("Setting sail to Venore!", cid)
talkState[talkUser] = 0
doTeleportThing(cid, {x = 1000, y = 1000, z = 7})
elseif talkState[talkUser] == 3 and doPlayerRemoveMoney(cid, 110) then
selfSay("Setting sail to Ab'Dendriel!", cid)
talkState[talkUser] = 0
doTeleportThing(cid, {x = 1000, y = 1000, z = 7})
elseif talkState[talkUser] == 4 and doPlayerRemoveMoney(cid, 120) then
selfSay("Setting sail to Thais!", cid)
talkState[talkUser] = 0
doTeleportThing(cid, {x = 1000, y = 1000, z = 7})
elseif talkState[talkUser] == 5 and doPlayerRemoveMoney(cid, 170) then
selfSay("Setting sail to Thais!", cid)
talkState[talkUser] = 0
doTeleportThing(cid, {x = 1000, y = 1000, z = 7})
else
selfSay("You don't have enough money to travel there.", cid)
talkState[talkUser] = 0
end
end
return true
end
npcHandler:setCallback(CALLBACK_GREET, greet)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Oh, I'm so sorry.Thanks but is there a way to edit that script so it checks what vocation they are and if they are a certian vocation it travel them to the city?
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 greet(cid) talkState[cid] = 0 return true end
function getNpcName()
return getCreatureName(getNpcId())
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
if msgcontains(msg, "job") then
selfSay("My job is to show the world how fashionable they can be!", cid)
elseif msgcontains(msg, "name") then
selfSay("My name is " .. getNpcName() .. ".", cid)
elseif msgcontains(msg, "travel") then
selfSay("Where would you like to travel? I can give you a list of places you can travel, if you wish.", cid)
elseif msgcontains(msg, "list") then
selfSay("I give passage to Thais (for sorcerer's), Venore (for knight's), Ab'Dendriel(for druid's), Carlin(for women) and Edron(for paladin's).", cid)
elseif msgcontains(msg, "thais") then
if getPlayerVocation(cid) == 1 or getPlayerVocation(cid) == 5 then
selfSay("Would you like to travel to Thais for 140 gold?", cid)
talkState[talkUser] == 1
else
selfSay("Sorry. Only Sorcerer's may travel there.", cid)
talkState[talkUser] == 0
end
elseif msgcontains(msg, "venore") then
if getPlayerVocation(cid) == 4 or getPlayerVocation(cid) == 8 then
selfSay("Would you like to travel to Venore for 160 gold?", cid)
talkState[talkUser] == 2
else
selfSay("Sorry. Only Knight's may travel there.", cid)
talkState[talkUser] == 0
end
elseif msgcontains(msg, "ab'dendriel") then
if getPlayerVocation(cid) == 2 or getPlayerVocation(cid) == 6 then
selfSay("Would you like to travel to Ab'Dendriel for 110 gold?", cid)
talkState[talkUser] == 3
else
selfSay("Sorry. Only Druid's may travel there.", cid)
talkState[talkUser] == 0
end
elseif msgcontains(msg, "carlin") then
if getPlayerSex(cid) == 0 then
selfSay("Would you like to travel to Carlin for 120 gold?", cid)
talkState[talkUser] == 4
else
selfSay("Sorry. Only women may travel there.", cid)
talkState[talkUser] == 0
end
elseif msgcontains(msg, "edron") then
if getPlayerVocation(cid) == 3 or getPlayerVocation(cid) == 7 then
selfSay("Would you like to travel to Edron for 170 gold?", cid)
talkState[talkUser] == 5
else
selfSay("Sorry. Only Paladin's may travel there.", cid)
talkState[talkUser] == 0
end
elseif msgcontains(msg, "yes") and talkState[talkUser] >= 1 and talkState[talkUser] <= 5 then
if talkState[talkUser] == 1 and doPlayerRemoveMoney(cid, 140) then
selfSay("Setting sail to Thais!", cid)
talkState[talkUser] == 0
doTeleportThing(cid, {x = 1000, y = 1000, z = 7})
elseif talkState[talkUser] == 2 and doPlayerRemoveMoney(cid, 160) then
selfSay("Setting sail to Venore!", cid)
talkState[talkUser] == 0
doTeleportThing(cid, {x = 1000, y = 1000, z = 7})
elseif talkState[talkUser] == 3 and doPlayerRemoveMoney(cid, 110) then
selfSay("Setting sail to Ab'Dendriel!", cid)
talkState[talkUser] == 0
doTeleportThing(cid, {x = 1000, y = 1000, z = 7})
elseif talkState[talkUser] == 4 and doPlayerRemoveMoney(cid, 120) then
selfSay("Setting sail to Thais!", cid)
talkState[talkUser] == 0
doTeleportThing(cid, {x = 1000, y = 1000, z = 7})
elseif talkState[talkUser] == 5 and doPlayerRemoveMoney(cid, 170) then
selfSay("Setting sail to Thais!", cid)
talkState[talkUser] == 0
doTeleportThing(cid, {x = 1000, y = 1000, z = 7})
else
selfSay("You don't have enough money to travel there.", cid)
talkState[talkUser] == 0
end
end
return true
end
npcHandler:setCallback(CALLBACK_GREET, greet)
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 greet(cid) talkState[cid] = 0 return true end
function getNpcName()
return getCreatureName(getNpcId())
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
if msgcontains(msg, "job") then
selfSay("My job is to travel to you hell or heaven!", cid)
elseif msgcontains(msg, "name") then
selfSay("My name is " .. getNpcName() .. ".", cid)
elseif msgcontains(msg, "travel") then
selfSay("Where would you like to travel? I can take you to either heaven or hell, depending on what life you have chosen.", cid)
elseif msgcontains(msg, "list") then
selfSay("I give passage to Hell (for players who are truly) or Heaven (for players who are angelic beings).", cid)
elseif msgcontains(msg, "Hell") then
if getPlayerVocation(cid) = 9 or getPlayerVocation(cid) = 10 or getPlayerVocation(cid) = 11 or getPlayerVocation(cid) = 12 then
selfSay("Would you like to travel to Hell?", cid)
talkState[talkUser] == 1
else
selfSay("Sorry. Only players who are of off demonic descent may travel there.", cid)
talkState[talkUser] == 0
end
elseif msgcontains(msg, "Heaven") then
if getPlayerVocation(cid) = 13 or getPlayerVocation(cid) = 14 or getPlayerVocation(cid) = 15 or getPlayerVocation(cid) = 16 then
selfSay("Would you like to travel to Heaven?", cid)
talkState[talkUser] == 2
else
selfSay("Sorry. Only players who are truly pure of heart may travel there.", cid)
talkState[talkUser] == 0
end
elseif msgcontains(msg, "yes") and talkState[talkUser] >= 1 and talkState[talkUser] <= 5 then
if talkState[talkUser] == 1 and doPlayerRemoveMoney(cid, 0) then
selfSay("Setting sail to Hell!", cid)
talkState[talkUser] == 0
doTeleportThing(cid, {x = 800, y = 934, z = 7})
elseif talkState[talkUser] == 2 and doPlayerRemoveMoney(cid, 0) then
selfSay("Setting sail to Heaven!", cid)
talkState[talkUser] == 0
doTeleportThing(cid, {x = 1368, y = 1100, z = 7})
else
selfSay("You don't have enough money to travel there.", cid)
talkState[talkUser] == 0
end
end
return true
end
npcHandler:setCallback(CALLBACK_GREET, greet)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
When comparing values you need to use ==Hey iv edited that script slightly to that it will let certian voc's travel however im getting this error.
[3/7/2017 12:4:45] [Error - LuaInterface::loadFile] data/npc/scripts/Charon.lua:38: '=' expected near '==' [3/7/2017 12:4:45] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scripts/Charon.lua [3/7/2017 12:4:45] data/npc/scripts/Charon.lua:38: '=' expected near '=='
XML: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 greet(cid) talkState[cid] = 0 return true end function getNpcName() return getCreatureName(getNpcId()) 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 if msgcontains(msg, "job") then selfSay("My job is to travel to you hell or heaven!", cid) elseif msgcontains(msg, "name") then selfSay("My name is " .. getNpcName() .. ".", cid) elseif msgcontains(msg, "travel") then selfSay("Where would you like to travel? I can take you to either heaven or hell, depending on what life you have chosen.", cid) elseif msgcontains(msg, "list") then selfSay("I give passage to Hell (for players who are truly) or Heaven (for players who are angelic beings).", cid) elseif msgcontains(msg, "Hell") then if getPlayerVocation(cid) = 9 or getPlayerVocation(cid) = 10 or getPlayerVocation(cid) = 11 or getPlayerVocation(cid) = 12 then selfSay("Would you like to travel to Hell?", cid) talkState[talkUser] == 1 else selfSay("Sorry. Only players who are of off demonic descent may travel there.", cid) talkState[talkUser] == 0 end elseif msgcontains(msg, "Heaven") then if getPlayerVocation(cid) = 13 or getPlayerVocation(cid) = 14 or getPlayerVocation(cid) = 15 or getPlayerVocation(cid) = 16 then selfSay("Would you like to travel to Heaven?", cid) talkState[talkUser] == 2 else selfSay("Sorry. Only players who are truly pure of heart may travel there.", cid) talkState[talkUser] == 0 end elseif msgcontains(msg, "yes") and talkState[talkUser] >= 1 and talkState[talkUser] <= 5 then if talkState[talkUser] == 1 and doPlayerRemoveMoney(cid, 0) then selfSay("Setting sail to Hell!", cid) talkState[talkUser] == 0 doTeleportThing(cid, {x = 800, y = 934, z = 7}) elseif talkState[talkUser] == 2 and doPlayerRemoveMoney(cid, 0) then selfSay("Setting sail to Heaven!", cid) talkState[talkUser] == 0 doTeleportThing(cid, {x = 1368, y = 1100, z = 7}) else selfSay("You don't have enough money to travel there.", cid) talkState[talkUser] == 0 end end return true end npcHandler:setCallback(CALLBACK_GREET, greet) npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
getPlayerVocation(cid) = 1 -- incorrect
getPlayerVocation(cid) == 1 -- correct
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 greet(cid) talkState[cid] = 0 return true end
function getNpcName()
return getCreatureName(getNpcId())
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
if msgcontains(msg, "job") then
selfSay("My job is to travel to you hell or heaven!", cid)
elseif msgcontains(msg, "name") then
selfSay("My name is " .. getNpcName() .. ".", cid)
elseif msgcontains(msg, "travel") then
selfSay("Where would you like to travel? I can take you to either heaven or hell, depending on what life you have chosen.", cid)
elseif msgcontains(msg, "list") then
selfSay("I give passage to Hell (for players who are truly) or Heaven (for players who are angelic beings).", cid)
elseif msgcontains(msg, "Hell") then
if getPlayerVocation(cid) == 9 or getPlayerVocation(cid) == 10 or getPlayerVocation(cid) == 11 or getPlayerVocation(cid) == 12 then
selfSay("Would you like to travel to Hell?", cid)
talkState[talkUser] = 1
else
selfSay("Sorry. Only players who are of off demonic descent may travel there.", cid)
talkState[talkUser] = 0
end
elseif msgcontains(msg, "Heaven") then
if getPlayerVocation(cid) == 13 or getPlayerVocation(cid) == 14 or getPlayerVocation(cid) == 15 or getPlayerVocation(cid) == 16 then
selfSay("Would you like to travel to Heaven?", cid)
talkState[talkUser] = 2
else
selfSay("Sorry. Only players who are truly pure of heart may travel there.", cid)
talkState[talkUser] = 0
end
elseif msgcontains(msg, "yes") and talkState[talkUser] >= 1 and talkState[talkUser] <= 2 then
if talkState[talkUser] == 1 and doPlayerRemoveMoney(cid, 0) then
selfSay("Setting sail to Hell!", cid)
talkState[talkUser] = 0
doTeleportThing(cid, {x = 800, y = 934, z = 7})
elseif talkState[talkUser] == 2 and doPlayerRemoveMoney(cid, 0) then
selfSay("Setting sail to Heaven!", cid)
talkState[talkUser] = 0
doTeleportThing(cid, {x = 1368, y = 1100, z = 7})
else
selfSay("You don't have enough money to travel there.", cid)
talkState[talkUser] = 0
end
end
return true
end
npcHandler:setCallback(CALLBACK_GREET, greet)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
probably your Capitals in Heaven and Hell.Thanks for the script the npc works now just one small problem it wont travel the player to the pos that I have put there as everytime I say either hell or heaven it wont respond to me at all. Do you have any idea why this is occuring?
Is there any chance you would be able to make me one please if thats not too much to ask.