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

(Simple?) NPC Script that teleports character.

GreenYoshi

New Member
Joined
Jul 6, 2009
Messages
46
Reaction score
0
I actually want a NPC that, when you say 'Rotworms' it will teleport you to location 502x, 284y and 8z.

I also have more text-teleports, so please make it easy for me to copy and paste everything :).

Also, I want, when the user say 'Overview' all npcs (Just a simple string test) will be said by the npc.

So:

Player: Hi
NPC: Hi there, where you want to go?
Player: Overview
NPC: You can went to Rotworms ... blahblah ... by my.
Player: Rotworms
NPC: Here you go!
< Player get teleported to preset location and conversation get end >

Thanks,
Dennis
 
PHP:
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
	house = {x = 834, y = 980, z = 6, stackpos=1}  -- <- Position! 
	if msgcontains(msg, 'travel') then
		selfSay('Chcesz plynac na wyspe House za 150 gp?', cid)
		talkState[talkUser] = 2

	elseif ((msgcontains(msg, 'yes') or msgcontains(msg, 'tak')) and talkState[talkUser] == 2) then
		doTeleportThing(cid,house)
		talkState[talkUser] = 0

	elseif ((msgcontains(msg, 'no') or msgcontains(msg, 'nie')) and talkState[talkUser] == 2) then
		selfSay('oki', cid)
		talkState[talkUser] = 0
	end
	


return TRUE	
end



npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
XML:
Code:
<parameter key="message_greet" value="Hi there, where you want to go?"/>

LUA (Edited Quas' Post :p):
Code:
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 travel_destination = {x = 834, y = 980, z = 6}

    if msgcontains(msg, 'overview') then
        selfSay('You can went to Rotworms ... blahblah ... by my.', cid)
        talkState[talkUser] = 2
    elseif ((msgcontains(msg, 'rotworms')) and talkState[talkUser] == 2) then
        doTeleportThing(cid, travel_destination)
        talkState[talkUser] = 0
    end

    return TRUE    
end



npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Back
Top