• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

NPC script - wrong answer teleport

Nemphis

Veteran OT User
Joined
Jun 22, 2009
Messages
699
Reaction score
441
Location
Sweden
Hello! I'd like to get some help with an npc!

He will ask you a question
-> What is the name of Bobs special dromedary?
-> your answer (Jaegermister)
-> if correct answer you get teleported to x, y, z (inside the quest area)
-> if wrong answer you get teleported to x, y, z (outside the quest area)

if you say anything BUT Jaegermister you get teleported (outside the quest area)

Pretty simple but advanced for a non-scripter ;D

If you need more info just tell me.
Thanks!
 
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 onPlayerEndTrade(cid)                npcHandler:onPlayerEndTrade(cid)            end
function onPlayerCloseChannel(cid)            npcHandler:onPlayerCloseChannel(cid)        end

function creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
    local teleportout = {x=6,y=5,z=7}
    local teleport = {x=5,y=5,z=5}
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
    if(msgcontains(msg, 'Jaegermister') or msgcontains(msg, 'jaegermister')) then
        doTeleportThing(cid, teleport)
        else
        doTeleportThing(cid, teleportout)
        end
        return true
        end

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

Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Destiny" script="destiny.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="215" head="20" body="30" legs="40" feet="50" corpse="6054"/>
    <parameters>
      <parameter key="message_greet" value="Greetings |PLAYERNAME|. What is the name of Bobs special dromedary.?" />
    </parameters>
  </npc>

if there is any mistakes tell me since i ain't advanced with npcs
 
Back
Top