• 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!

Lua Boat Npc Problem

  • Thread starter Thread starter Deleted member 49793
  • Start date Start date
D

Deleted member 49793

Guest
Hey so this is my script, The positions are 100% accurate + im getting 0 errors in the console... Basicly what happens is he respond all fine then when you try and pick a destination (Moonlight/Birchvale) he just doesnt reply, Anyone know problem?

Rep++

Thanks

Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Shipmaster" script="default.lua" walkinterval="0" floorchange="0">
	<health now="150" max="150"/>
	<look type="151" head="76" body="106" legs="0" feet="114" addons="3"/>
    <parameters>
        <parameter key="module_travel" value="1"/>
		<parameter key="message_greet" value="Hello |PLAYERNAME|. I am the the captain of this ship I will take your anywhere for 50 gold coins, If you are wondering where i can take you say {travel}."/>
        <parameter key="travel_destinations" value="Moonlight,1067,1136,4,50;Birchvale,1122,1129,7,50;"/>
    </parameters>
</npc>
 
XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="XXXX" script="XXXX.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="129" head="79" body="113" legs="105" feet="86" addons="0"/>
        <parameters>
                <parameter key="message_greet" value="Hello |PLAYERNAME|, to teleport say {teleport}!"/>
                <parameter key="bye" value="Good bye |PLAYERNAME|, come back if you want to be teleported!."/>
    </parameters>
 
</npc>



LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
 
local Topic = {}
local chosen = {}
 
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)
	Topic[cid] = 0
	chosen[cid] = nil
	return true
end
 
local monsters = {	
						["edron"] = {pos = {x=89,y=126,z=7} , price = 500},  -- monster name,pos,price
						["yalahar"] = {pos = {x=92,y=132,z=7} , price = 800},
						["venore"] = {pos = {x=98,y=125,z=7} , price = 1500}
					}
 
function creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
        return false
    end
	local str = ""
	if msgcontains(msg, 'teleport') then
			for k,v in pairs(monsters) do
				str = str..""..(string.len(str) > 0 and ', ' or '').."{"..k.."}"
			end
			npcHandler:say("Where to? I can take you to "..str..".", cid) 
			Topic[cid] = 1
	elseif Topic[cid] == 1 then
		for k,v in pairs(monsters) do
			if msgcontains(msg, k) then 
				chosen[cid] = k
			end
		end
		if chosen ~= nil then
			selfSay("So do you want to go to {"..chosen[cid].."} for "..monsters[chosen[cid]].price.."?",cid)
			Topic[cid] = 2
		end
	elseif msgcontains(msg, 'yes') and Topic[cid] == 2 then
		if doPlayerRemoveMoney(cid,monsters[chosen[cid]].price) then
			selfSay("There you go.",cid)
			addEvent(doTeleportThing,200,cid,monsters[chosen[cid]].pos,false)
			addEvent(doSendMagicEffect,300,monsters[chosen[cid]].pos,10)
			Topic[cid] = 0
		else
			selfSay("Come back when you have money...",cid)
			Topic[cid] = 0
		end
	elseif msgcontains(msg, 'no') and Topic[cid] == 2 then	
		selfSay("Maybe later then.",cid)
		chosen[cid] = nil
		Topic[cid] = 0
	end
    return true
end 
 
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Back
Top