• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

NPC City Guide, adding mapmarks to locations

Limos

Senator
Premium User
Joined
Jun 7, 2010
Messages
10,013
Solutions
8
Reaction score
3,056
Location
Netherlands
Tested with TFS 0.3.6pl1 8.54
75RwhB.gif



City Guide.xml
XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="City Guide" script="cityguide.lua" walkinterval="2000" floorchange="0">
	<health now="100" max="100"/>
	<look type="130" head="95" body="114" legs="118" feet="4" addons="0"/>
	<parameters>
		<parameter key="message_greet" value="Hello |PLAYERNAME|. I'm the city guide from xcity and I know almost every place in the city and around it. Just tell me where you want to go or where you want to hunt and I will add a mapmark to guide you there. You can also ask for more {information} about a location or I can show you the {list} of locations I know."/>
	</parameters>
</npc>

cityguide.lua
Lua:
-- City Guide, adding mapmarks to locations by Limos
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
 
local config = {
	["Riona"] = {mark = {x = 1000, y = 1000, z = 7}, type = MAPMARK_TICK, name = "Riona's Tool Shop", text = "find", info = "Riona sells tools and backpacks."},	
	["Deposit"] = {mark = {x = 1000, y = 1000, z = 7}, type = MAPMARK_TICK, name = "Deposit", text = "find the"},
	["Boat"] = {mark = {x = 1000, y = 1000, z = 7}, type = MAPMARK_TICK, name = "Boat", text = "find the", info = "You can use the boat to travel to other cities."},
	["Rotworms"] = {mark = {x = 1000, y = 1000, z = 7}, type = MAPMARK_TICK, name = "Rotworms", text = "hunt"},
	["Cyclops"] = {mark = {x = 1000, y = 1000, z = 7}, type = MAPMARK_TICK, name = "Cyclops", text = "hunt"},
	["Dragons"] = {mark = {x = 1000, y = 1000, z = 7}, type = MAPMARK_TICK, name = "Dragons", text = "hunt"},
	["Demons"] = {mark = {x = 1000, y = 1000, z = 7}, type = MAPMARK_TICK, name = "Demons", text = "hunt"}
}

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 function addCptl(first, rest)
  		return first:upper()..rest:lower()
	end
 
	local x = config[msg:gsub("(%a)([%w_']*)", addCptl)]
 
	if(x and talkState[talkUser] ~= 2) then 
		selfSay('Do you want me to add a mapmark where you can '..x.text..' '..msg..'?', cid)
		xmsg = msg
		talkState[talkUser] = 1
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then 
		x = config[xmsg:gsub("(%a)([%w_']*)", addCptl)]
		selfSay('Here you are.', cid)
		doPlayerAddMapMark(cid, x.mark,x.type,x.name)
		talkState[talkUser] = 0
	elseif(msgcontains(msg, 'no') and talkState[talkUser] == 1) then 
		selfSay('Ok then.', cid)
		talkState[talkUser] = 0
	elseif(msgcontains(msg, 'information')) then
		selfSay('About which location do you want more information?', cid)
		talkState[talkUser] = 2
	elseif(talkState[talkUser] == 2) then
		if(x) then
			if(x.info) then
				selfSay('' .. x.info, cid)
			else
				selfSay('Sorry, I can\'t give you any useful information about this location.', cid)
			end
		else
			selfSay('I don\'t know about this place, look in the {list} which locations I know.', cid)
		end
		talkState[talkUser] = 0
	elseif (msgcontains(msg, 'mapmark')) then
		selfSay("Which location do you want to go?", cid)
		talkState[talkUser] = 0
	elseif(msgcontains(msg, 'list')) then
		selfSay('Here is my list, tell me where you want to go or you can also ask me for {information} about a location.', cid)
		local text = 'Locations\n'
		for i, x in pairs(config) do
			text = text .. '\n' .. i .. ''
		end
		doShowTextDialog(cid, 1949, '' .. text)
		talkState[talkUser] = 0
	else
		local messages = {'Sorry, I have no idea what you mean with '..msg..'.', 'What?', 'What do you mean?', 'Hmm?', 'Tell me a location, you can look in the {list} which locations I know.'}
		selfSay(messages[math.random(#messages)], cid)
	end
	return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Ingame example
KiGTzDh.png

oILDWWi.png


Let me know if you have any questions, suggestions or bugs.


If you want to use a scroll instead of a NPC, look here.
http://otland.net/f82/mapmark-scroll-167597/
 
Last edited:
Lua:
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
msg = string.lower(msg)
	
      local config = {
			[{"shovel","rope","backpack","riona"}] = {type = MAPMARK_SHOVEL, pos = {x=149,y=47,z=7}, name = "Riona\'s Tool Shop"}, 
			[{"demon","demons"}] = {type = MAPMARK_TICK, pos = {x=133,y=38,z=7}, name = "Demons"}
    	}
    	
    	   for var, ret in pairs(config) do
				for _, check in pairs(var) do
					if msg == check then
						type,pos,name = ret.type,ret.pos,ret.name
						selfSay('Do you want me to add a mapmark '..msg..'? {yes}', cid)
						talkState[talkUser] = 1
					end
				end
			end
      	if(msgcontains(msg, 'yes') and talkState[talkUser] >= 1) then
		doPlayerAddMapMark(cid, pos,type,name)
      npcHandler:say('Here you are.', cid)
      talkState[talkUser] = 0
	elseif(msgcontains(msg, 'no') and talkState[talkUser] >= 1) then
		selfSay('Well then, hope you can find it yourself!', cid)
		talkState[talkUser] = 0
        npcHandler:releaseFocus(cid)
	end
	return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
I was thinking about making it with msg, but like this imo the english questions willl sound better and it's more easy to edit.
 
Im using OTServ r.6052 8.60 SVN so, of course, I'm getting an error. Is there anyway to add the function "addmapmark" for me or am I just missing out since I'm not using TFS?

Oh heres the script

Code:
-- City Guide, adding mapmarks to locations by Limos
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 config = {
    		mayor = {x=1056,y=1029,z=6}, -- Edit here the locations
    		demons = {x=1002,y=1002,z=7},
			trolls = {x=1001,y=1001,z=7}
    	}
 
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
 
	if(msgcontains(msg, 'mayor') or msgcontains(msg, 'bobbie') or msgcontains(msg, 'sewerwork') or msgcontains(msg, 'sewer')) or msgcontains(msg, 'sewer work') then
		selfSay('Do you want me to add a mapmark where the Mayor, Bobbie, is?', cid)
		talkState[talkUser] = 1
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
		doPlayerAddMapMark(cid,config.mayor,MAPMARK_STAR,"Riona\'s Tool Shop")
                npcHandler:say('Here you are.', cid)
 
	elseif(msgcontains(msg, 'wands') or msgcontains(msg, 'potions') or msgcontains(msg, 'runes') or msgcontains(msg, 'eryn')) then

line 29 is
doPlayerAddMapMark(cid,config.mayor,MAPMARK_STAR,"Riona\'s Tool Shop")

so obviously my server has a problem with the "doPlayerAddMapMark"
 

Attachments

  • cityguide error.jpg
    cityguide error.jpg
    54.9 KB · Views: 15 · VirusTotal
This script is uber awesome. Many people would love having it in their server. Cipsoft will probably steal your idea if they notice this thread (if they look at otland) :)

damn i made that idea a long time ago for animera, i just came back from being gone for a long time and it see 2 threads releasing it xD
however i got it just from cipsoft XD


btw leuke script je krijgt repp van me omdat ik de screenshot/mapping zo leuk vind:p
 
Bedankt Lagmacun :p

Im using OTServ r.6052 8.60 SVN so, of course, I'm getting an error. Is there anyway to add the function "addmapmark" for me or am I just missing out since I'm not using TFS?

Oh heres the script

Code:
-- City Guide, adding mapmarks to locations by Limos
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 config = {
    		mayor = {x=1056,y=1029,z=6}, -- Edit here the locations
    		demons = {x=1002,y=1002,z=7},
			trolls = {x=1001,y=1001,z=7}
    	}
 
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
 
	if(msgcontains(msg, 'mayor') or msgcontains(msg, 'bobbie') or msgcontains(msg, 'sewerwork') or msgcontains(msg, 'sewer')) or msgcontains(msg, 'sewer work') then
		selfSay('Do you want me to add a mapmark where the Mayor, Bobbie, is?', cid)
		talkState[talkUser] = 1
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
		doPlayerAddMapMark(cid,config.mayor,MAPMARK_STAR,"Riona\'s Tool Shop")
                npcHandler:say('Here you are.', cid)
 
	elseif(msgcontains(msg, 'wands') or msgcontains(msg, 'potions') or msgcontains(msg, 'runes') or msgcontains(msg, 'eryn')) then

line 29 is
doPlayerAddMapMark(cid,config.mayor,MAPMARK_STAR,"Riona\'s Tool Shop")

so obviously my server has a problem with the "doPlayerAddMapMark"

You can also try
Lua:
doAddMapMark
 
Updated, added a list and information about the locations.
 
Great script Limos :)

Im lazy, can someone make all npc from real tibia which giving real tibia posistion?
 
Updated, made it shorter and added different NPC messages when someone says a location that doesn't exist.
 
Back
Top