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

[REQUEST] Simple NPC

Grehy

Killroy
Joined
Nov 21, 2008
Messages
2,631
Reaction score
33
Location
United States
I just want a npc when you say "xxx", it tps you to "x x x" with no message, and when you say "xxxx" it tps you to "xx xx xx" with no message (response)
 
Without 'hi'? Script:
PHP:
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)
	if(string.lower(msg) == 'text 1') then
		doTeleportThing(cid, {x=100,y=100,z=3}, TRUE)
	elseif(string.lower(msg) == 'text 2') then
		doTeleportThing(cid, {x=200,y=200,z=6}, TRUE)
	end
end
function onThink()                     npcHandler:onThink()                    end
NOT TESTED
With 'hi' and then position name:
PHP:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid)
talk_state[cid] = 0
npcHandler:onCreatureAppear(cid)
end
function onCreatureDisappear(cid)     
talk_state[cid] = 0        
npcHandler:onCreatureDisappear(cid)
end
function onCreatureSay(cid, type, msg)             npcHandler:onCreatureSay(cid, type, msg)        end
function onThink()                     npcHandler:onThink()                    end

function creatureSayCallback(cid, type, message)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
	if(string.lower(msg) == 'text 1') then
		doTeleportThing(cid, {x=100,y=100,z=3}, TRUE)
	elseif(string.lower(msg) == 'text 2') then
		doTeleportThing(cid, {x=200,y=200,z=6}, TRUE)
	end
    return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:setMessage(MESSAGE_GREET, 'Hi |PLAYERNAME|. Tell me teleport name.')
npcHandler:setMessage(MESSAGE_FAREWELL, 'Bye |PLAYERNAME|.')
npcHandler:setMessage(MESSAGE_WALKAWAY, 'Bye |PLAYERNAME|.')

npcHandler:addModule(FocusModule:new())
 
Back
Top