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

[Help] Creating New NPCs

TibianWoW

New Member
Joined
Sep 12, 2011
Messages
3
Reaction score
0
Hello Everybody.
I've made a 8.60 OT server and i've tryied to make a NPC, a Elf with better Sprites, but it didn't Work...

I've made all the 12 Sprites(Since he is 1X1), I add it in the Tibia.spr, put in the paste of my MapEditor, add it in the creatures.xml of my MapEditor, add it to the server, made Its Script in the data/npc and add made its script in the data/npc/scripts (In this order, if it may help :p).

The server runed and when I would see the NPC(High Elf), My Tibia had a Critical error, Than I made my Own Client, but it didn't change nothing... (shouldn't make a client resolve the problem? Maybe I've done it wrong... But it runs the server. ).:p
After that I've tried Thousand times and nothing changes! :eek:

It Might Help That I've got the ID 368 from Dat Editor. I Got the number that was in the Item Type of the Dat Editor. If This isn't the ID for me to take, say it please :p
but, in the MapEditor ,the High Elf Sprite appeared normally.

Here are the Scripts for Better Help:

-------creatures.xml (MapEditor)
Code:
<creature looktype="368" name="Night Elf" head="20" body="30" legs="40" feet="50" type="npc"/>

-------High Elf.xml (data/npc, Server Code)
Code:
<?xml version="1.0"?>

<npc name="High Elf" script="data/npc/scripts/high_elf.lua" access="3" lookdir="2">
	<mana now="800" max="800"/>
	<health now="200" max="200"/>
<look type="368" head="20" body="30" legs="40" feet="50" corpse="2967"/>
</npc>

-------high_elf.lua (data/npc/scripts)
Code:
local focus = 0
local talk_start = 0
local target = 0
local days = 0

function onThingMove(creature, thing, oldpos, oldstackpos)

end


function onCreatureAppear(creature)

end


function onCreatureDisappear(cid, pos)
  	if focus == cid then
          selfSay('...')
          focus = 0
          talk_start = 0
  	end
end


function onCreatureTurn(creature)

end


function msgcontains(txt, str)
  	return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
end


function onCreatureSay(cid, type, msg)
  	msg = string.lower(msg)

  	if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
  		selfSay('Speak quick. Want to be a Knight? Or want to know more about us(KNIGHTS)? ')
 		focus = cid
 		talk_start = os.clock()

	elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
  		selfSay('You are waysting my time ' .. creatureGetName(cid) .. '... ')

  	elseif focus == cid then
		talk_start = os.clock()

		if msgcontains(msg, 'knights') then
			selfSay('For your surprise, we have good skills to tank, if with a healer, and to kill quick and Strong monsters.Want to be a knight?')	

		elseif msgcontains(msg, 'yes') then
 			selfSay('Go to the  Training Quarter and choose your destiny there.')
			focus = 0
			talk_start = 0

		elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
			selfSay('...')
			focus = 0
			talk_start = 0
  		end
  	end
end


function onCreatureChangeOutfit(creature)

end


function onThink()
	doNpcSetCreatureFocus(focus)
  	if (os.clock() - talk_start) > 45 then
  		if focus > 0 then
  			selfSay('...')
  		end
  			focus = 0
  	end
 	if focus ~= 0 then
 		if getDistanceToCreature(focus) > 5 then
 			selfSay('....')
 			focus = 0
 		end
 	end
end

Thanks for the atention. REP++ for any kind of Help :p
 
Back
Top