• 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] Traveler with Storage value.

witmar

New Member
Joined
Oct 21, 2008
Messages
248
Reaction score
0
Location
Poland, Dębica
Hello i need script to npc Traveler (captain of ship) which can teleport us if we have storage value 19273. Someone Can help me with this?
Ofc Rep++
 
try this.

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 onThink() 						npcHandler:onThink() end

local destinations = {
	['Venore'] = {location={x=1,y=1,z=1},cost=500}
}
	
local Topic = {}
function creatureSayCallback(cid, type, msg)
local r = destinations.param
	if getPlayerStorageValue(cid,19237) > 0 then
		if msgcontains(msg,r) then
			npcHandler:say('Do want to travel to '..param..' for {'..r.cost..'} gold?',cid)
			Topic[cid] = 1
		elseif Topic[cid] == 1 then
			if doPlayerRemoveMoney(cid,r.cost) then
				npcHandler:say('Farewell!',cid)
				doTeleportThing(cid,r.location)
				doSendMagicEffect(getThingPos(cid),10)
				Topic[cid] = 0
			else
				npcHandler:say('You don\'t have enough money!',cid)
				Topic[cid] = 0
			end
		end
	else
		npcHandler:say('I won\'t talk to you!',cid)
		npcHandler:releaseFocus(cid)
		Topic[cid] = 0
	end
	return true
end

npcHandler:setMessage(MESSAGE_WALKAWAY, "Farewell!")
npcHandler:setMessage(MESSAGE_FAREWELL, "Goodbye, |PLAYERNAME|.")
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
Lua:
[18:47:24.390] [Error - NpcScript Interface]
[18:47:24.390] (Unknown script file)
[18:47:24.390] Description:
[18:47:24.390] attempt to call a nil value
[18:47:24.390] stack traceback:

doesn't work;/
 
Lua:
[18:52:52.649] [Error - LuaInterface::loadFile] data/npc/scripts/aa.lua:19: '=' expected near '=='
[18:52:52.649] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scripts/aa.lua
[18:52:52.649] data/npc/scripts/aa.lua:19: '=' expected near '=='
 
[19:6:51.884] [Error - NpcScript Interface]
[19:6:51.885] data/npc/scripts/aa.lua:eek:nCreatureSay
[19:6:51.885] Description:
[19:6:51.885] data/npc/lib/npc.lua:54: attempt to index local 'keyword' (a nil value)
[19:6:51.885] stack traceback:
[19:6:51.885] data/npc/lib/npc.lua:54: in function 'msgcontains'
[19:6:51.885] data/npc/scripts/aa.lua:17: in function 'callback'
[19:6:51.885] data/npc/lib/npcsystem/npchandler.lua:383: in function 'onCreatureSay'
[19:6:51.885] data/npc/scripts/aa.lua:6: in function <data/npc/scripts/aa.lua:6>
What is wrong now?

I using tfs 0.4
 
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local Topic = {}
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 destinations = {
	['Venore'] = {pos={x=1,y=1,z=1}, cost=500, storage=19237}
}
	
function greetCallback(cid)
	Topic[cid] = nil
	return true
end

function creatureSayCallback(cid, type, msg)
	if Topic[cid] and msgcontains(msg, 'yes') then
		local v = destinations[Topic[cid]]
		if doPlayerRemoveMoney(cid, v.cost) then
			npcHandler:say('Set the sails!',cid)
			npcHandler:releaseFocus(cid)
			doTeleportThing(cid, v.pos)
			doSendMagicEffect(v.pos, CONST_ME_TELEPORT)
		else
			npcHandler:say('You don\'t have enough money.',cid)	
		end
		Topic[cid] = nil
		return true
	end

	for txt, v in pairs(destinations) do
		if msgcontains(msg:lower(), txt:lower()) then
			if not v.storage or getPlayerStorageValue(cid, v.storage) > 0 then
				Topic[cid] = txt
				npcHandler:say('Do want to travel go '..txt..' for {'..v.cost..'} gold?',cid)
			else
				npcHandler:say('You don\'t have the permission to travel here!',cid)
			end
			break
		end
	end
	return true
end

npcHandler:setMessage(MESSAGE_WALKAWAY, "Farewell!")
npcHandler:setMessage(MESSAGE_FAREWELL, "Goodbye, |PLAYERNAME|.")
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local Topic = {}
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 destinations = {
	['venore'] = {pos={x=1,y=1,z=1}, cost=500, storage=19237}
}
	
function greetCallback(cid)
	Topic[cid] = nil
	return true
end

function creatureSayCallback(cid, type, msg)
	if Topic[cid] and msgcontains(msg, 'yes') then
		local v = destinations[Topic[cid]]
		if doPlayerRemoveMoney(cid, v.cost) then
			npcHandler:say('Set the sails!',cid)
			npcHandler:releaseFocus(cid)
			doTeleportThing(cid, v.pos)
			doSendMagicEffect(v.pos, CONST_ME_TELEPORT)
		else
			npcHandler:say('You don\'t have enough money.',cid)	
		end
		Topic[cid] = nil
		return true
	end

	for txt, v in pairs(destinations) do
		if msgcontains(msg, txt) then
			if not v.storage or getPlayerStorageValue(cid, v.storage) < 1 then
				Topic[cid] = txt
				npcHandler:say('Do want to travel go '..param..' for {'..r.cost..'} gold?',cid)
			else
				npcHandler:say('You don\'t have the permission to travel here!',cid)
			end
			break
		end
	end
	return true
end

npcHandler:setMessage(MESSAGE_WALKAWAY, "Farewell!")
npcHandler:setMessage(MESSAGE_FAREWELL, "Goodbye, |PLAYERNAME|.")
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())


Lua:
[2:53:36.248] [Error - NpcScript Interface]
[2:53:36.248] data/npc/scripts/aa.lua:onCreatureSay
[2:53:36.248] Description:
[2:53:36.248] data/npc/scripts/aa.lua:38: attempt to index global 'r' (a nil value)
[2:53:36.248] stack traceback:
[2:53:36.248]   data/npc/scripts/aa.lua:38: in function 'callback'
[2:53:36.248]   data/npc/lib/npcsystem/npchandler.lua:383: in function 'onCreatureSay'
[2:53:36.248]   data/npc/scripts/aa.lua:7: in function <data/npc/scripts/aa.lua:7>
 
Lua:
[2:53:36.248] [Error - NpcScript Interface]
[2:53:36.248] data/npc/scripts/aa.lua:onCreatureSay
[2:53:36.248] Description:
[2:53:36.248] data/npc/scripts/aa.lua:38: attempt to index global 'r' (a nil value)
[2:53:36.248] stack traceback:
[2:53:36.248]   data/npc/scripts/aa.lua:38: in function 'callback'
[2:53:36.248]   data/npc/lib/npcsystem/npchandler.lua:383: in function 'onCreatureSay'
[2:53:36.248]   data/npc/scripts/aa.lua:7: in function <data/npc/scripts/aa.lua:7>

oww, fixed
 
Back
Top