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

Script on moving npc

Gothric

New Member
Joined
Feb 6, 2010
Messages
264
Reaction score
1
Can anyone write script for me on moving npc? its mean that in tibia is 19 o clock and npc is in town 1 but when in tibia is time 20 o clock then npc get teleport to the town 2

i can try to write this script but can anyone tell me what i should add to describe time?
 
Hmmm, maybe some better example:
Code:
function getHour()
	return os.time("%H")
end

So then:
Code:
function onThink()
	if(getHour() == 19) then
		doTeleportThing(cid, {x = 100, y = 100, z = 7})
	end
end

Of course it's only example, you'd need some better statements than simple hour.
 
You can add this function in any file inside ./data/lib/, and that onThink is not for creaturescripts, it's for NPCs scripts.
 
You can also do it with globalevents (timer). But in that case your NPC need to have unique name in game, otherwise it may teleport wrong creature.

This should do this: (just paste into globalevents.xml)
Code:
<globalevent name="moveNpc" time="21:35:11" event="buffer"><![CDATA[
	local npc = getCreatureByName("npc name here")
	if(npc and npc > 0 and not isPlayer(npc)) then
		doTeleportThing(npc, {x = 5, y = 5, z = 5})
	end
]]></globalevent>
 
Last edited:
Back
Top