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

[NPC] Teleporting npc

Inteligentny

Im not.
Joined
Aug 2, 2008
Messages
485
Reaction score
0
Hiho I have another request :p I need one npc that will be teleporting ppl:

if there are lower than 20 lvl FOR FREE
If they are 20-50 for 1k
if they are 50+ for 5k

anyone know how to do that?
 
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local voc = {}

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_PRIVATE and 0 or cid
	if msgcontains(msg, 'teleport') or msgcontains(msg, 'tp') then
		selfSay('Are you sure do you want be teleported?', cid)
		talkState[talkUser] = 1
end
	elseif talkState[talkUser] == 1 then
	if msgcontains(msg, 'yes') then

	local level = getPlayerLevel(cid)
	local position = {x=453, y=480, z=6, stackpos=1}

	if level >= 1 and level <= 20 then
			selfSay('There you go!.', cid)
			doTeleportThing(cid, position)
	elseif level >= 21 and level <= 50 and doPlayerRemoveMoney(cid,1000) == TRUE then
			selfSay('There you go!.', cid)
			doTeleportThing(cid, position)
	elseif level >= 51 and doPlayerRemoveMoney(cid,5000) == TRUE then
			selfSay('Good luck!.', cid)
			doTeleportThing(cid, Castle3)
else
			selfSay('You do not have enought money.', cid)
		talkState[talkUser] = 0
	end
end
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

UNTESTED!
 
there was some errors with "ends"

Its working, I just deleted 2 "ends" thanks reppppp if I can :p

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local voc = {}

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_PRIVATE and 0 or cid
	if msgcontains(msg, 'teleport') or msgcontains(msg, 'tp') then
		selfSay('Are you sure do you want be teleported?', cid)
		talkState[talkUser] = 1

	elseif talkState[talkUser] == 1 then
end
	if msgcontains(msg, 'yes') then

	local level = getPlayerLevel(cid)
	local position = {x=1026, y=1018, z=8, stackpos=1}

	if level >= 1 and level <= 20 then
			selfSay('There you go!.', cid)
			doTeleportThing(cid, position)
	elseif level >= 21 and level <= 50 and doPlayerRemoveMoney(cid,1000) == TRUE then
			selfSay('There you go!.', cid)
			doTeleportThing(cid, position)
	elseif level >= 51 and doPlayerRemoveMoney(cid,5000) == TRUE then
			selfSay('Good luck!.', cid)
			doTeleportThing(cid, Castle3)
else
			selfSay('You do not have enought money.', cid)
		talkState[talkUser] = 0
	end
end
end

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