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

[Request] 2 Teleport NPCs.

Eldin

Eldin Projects
Joined
Jun 12, 2008
Messages
1,334
Reaction score
614
Location
Sweden
Hello there.
I am currently looking for help to create two different NPCs,
those are very important to fullfill my server and no mather how I try, it wont work.

First NPC:
This NPC will teleport you when you give him an item(s),
lets say an apple as example.
He always wanted this certain item so you will get teleported to a certain x y z.
So an item, not money.

Second NPC:
This NPC will include teleport and a special ID.
The NPC is asking for an item, once you have given it you will be able to go back to the NPC and get teleported to a certain place whenever you want.

Some pro out there must be able to fix this,
it adds alot of RPG to a server. ;)

Thank you for atleast reading.

Kind Regards,
Eldin.
 
First NPC:
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
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
-- OTServ event handling functions end

function creatureSayCallback(cid, type, msg)
    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
    if(npcHandler.focus ~= cid) then
        return false
    end
    
local telePos = {x = 100, y = 100, z = 10} --change
    
    if msgcontains(msg, 'apple') then
        if doPlayerRemoveItem(cid,2674,1) == 1 then
            doTeleportThing(cid,telePos)
        else
            selfSay('Please bring me an apple, and I will teleport you.')
        end
    end
    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Second NPC:

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
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
-- OTServ event handling functions end

function creatureSayCallback(cid, type, msg)
    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
    if(npcHandler.focus ~= cid) then
        return false
    end
    
local telePos = {x = 100, y = 100, z = 10} --change
local storage = CHANGE
    
    if msgcontains(msg, 'apple') then
        if getPlayerStorageValue(cid,storage) == 0 then
            if doPlayerRemoveItem(cid,2674,1) == 1 then
                doTeleportThing(cid,telePos)
                setPlayerStorageValue(cid,storage,1)
            else
                selfSay('Please bring me an apple, and I will teleport you.')
            end
        else
            doTeleportThing(cid,telePos)
        end
    end
    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
The second NPC should only demand an item the first time,
then he'll teleport that person for free.

But thanks alot, I will try those ASAP.
REP+ for you.

Kind Regards,
Eldin.
 
Ah, sorry. Forgot about that. Lemme edit the second NPC.

EDIT: There we go. Fixed a small bug on both NPCs while I was at it anyway... ^^
 
Back
Top