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

I beg you help me :/

andurz

Senior Member
Joined
Nov 1, 2008
Messages
126
Reaction score
0
Location
$wedeN
I really need your help, im getting error when im talking with NPC,
etc: Demon oak guy, this error comes up when i say hi

[17/02/2009 18:19:43] Lua Script Error: [Npc interface]
[17/02/2009 18:19:43] data/npc/scripts/oak info.lua:eek:nCreatureSay

[17/02/2009 18:19:43] data/npc/scripts/oak info.lua:36: attempt to compare nil with number
[17/02/2009 18:19:43] stack traceback:
[17/02/2009 18:19:43] data/npc/scripts/oak info.lua:36: in function <data/npc/scripts/oak info.lua:33>
 
Here is the script
Code:
local focus = 0
local talk_start = 0
local target = 0
local following = false
local attacking = false

function onThingMove(creature, thing, oldpos, oldstackpos)

end

function onCreatureAppear(creature)
end

function onCreatureDisappear(cid, pos)
	if focus == cid then
		selfSay('Good bye then.')
		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('Hi '..getPlayerName(cid)..'. Before you dare facing the Demon Oak, you should talk to my brother. Last time I heard from him he had settled down in a cave in the Sultans Castle. He had managed to dig a cave below his throne. Talk to him and then come back and ask me about the DEMON OAK.')
focus = cid
talk_start = os.clock()

elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('Sorry, ' .. creatureGetName(cid) .. '! I talk to you in a minute.')

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

if msgcontains(msg, 'demon oak') then
selfSay('So, you talked to my brother? Head south from here and use the mighty axe on the Oaks arms. If you defeat him, go talk to my brother again and ask him about the DEMON OAK.')
end

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

function onThink()

if (os.clock() - talk_start) > 15 then
if focus > 0 then
selfSay('Next Please...')
end
focus = 0
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 2 then
selfSay('Good bye then.')
focus = 0
end
end
end
 
Last edited:
Hmm it dosent work :/
Do you mean that i need to change all the DoPlayerSay to DoCreatureSay? I did that but it dident work
 
But Mikuch there no words as doPlayerSay in the text :eek: thats why i could not change them

Code:
[17/02/2009  18:54:30] Lua Script Error: [Npc interface] 
[17/02/2009  18:54:30] data/npc/scripts/oak info.lua:onCreatureSay

[17/02/2009  18:54:30] data/npc/scripts/oak info.lua:36: attempt to compare nil with number
[17/02/2009  18:54:30] stack traceback:
[17/02/2009  18:54:30] 	data/npc/scripts/oak info.lua:36: in function <data/npc/scripts/oak info.lua:33>
 
Last edited:
This script should work. I've tested it on 0.2. Dunno if it works on 0.3.

Code:
local focus = 0
local talk_start = 0
local target = 0
local following = false
local attacking = false

function onThingMove(creature, thing, oldpos, oldstackpos)

end


function onCreatureAppear(creature)

end


function onCreatureDisappear(cid, pos)
  	if focus == cid then
          selfSay('Good bye then.')
          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('Hi '..getPlayerName(cid)..'. Before you dare facing the Demon Oak, you should talk to my brother. Last time I heard from him he had settled down in a cave in the Sultans Castle. He had managed to dig a cave below his throne. Talk to him and then come back and ask me about the DEMON OAK.')
		focus = cid
		talk_start = os.clock()

	elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
		selfSay('Sorry, ' .. creatureGetName(cid) .. '! I talk to you in a minute.')

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

	if msgcontains(msg, 'demon oak') then
		selfSay('So, you talked to my brother? Head south from here and use the mighty axe on the Oaks arms. If you defeat him, go talk to my brother again and ask him about the DEMON OAK.')
	end

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

function onCreatureChangeOutfit(creature)

end



function onThink()
  	if (os.clock() - talk_start) > 30 then
  		if focus > 0 then
  			selfSay('Next Please...')
  		end
 		focus = 0
  	end
 	if focus ~= 0 then
 		if getDistanceToCreature(focus) > 5 then
 			selfSay('Good bye then.')
 			focus = 0
 		end
 	end
end

Plz rep++

Your's ballack13
 
This script should work. I've tested it on 0.2. Dunno if it works on 0.3.

Code:
local focus = 0
local talk_start = 0
local target = 0
local following = false
local attacking = false

function onThingMove(creature, thing, oldpos, oldstackpos)

end


function onCreatureAppear(creature)

end


function onCreatureDisappear(cid, pos)
  	if focus == cid then
          selfSay('Good bye then.')
          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('Hi '..getPlayerName(cid)..'. Before you dare facing the Demon Oak, you should talk to my brother. Last time I heard from him he had settled down in a cave in the Sultans Castle. He had managed to dig a cave below his throne. Talk to him and then come back and ask me about the DEMON OAK.')
		focus = cid
		talk_start = os.clock()

	elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
		selfSay('Sorry, ' .. creatureGetName(cid) .. '! I talk to you in a minute.')

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

	if msgcontains(msg, 'demon oak') then
		selfSay('So, you talked to my brother? Head south from here and use the mighty axe on the Oaks arms. If you defeat him, go talk to my brother again and ask him about the DEMON OAK.')
	end

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

function onCreatureChangeOutfit(creature)

end



function onThink()
  	if (os.clock() - talk_start) > 30 then
  		if focus > 0 then
  			selfSay('Next Please...')
  		end
 		focus = 0
  	end
 	if focus ~= 0 then
 		if getDistanceToCreature(focus) > 5 then
 			selfSay('Good bye then.')
 			focus = 0
 		end
 	end
end

Plz rep++

Your's ballack13

It dident work :/
 
Lol u propably know what you have downloaded here or??
Was is called The Forgotten Server 0.2 (Mystic Spirit)
Or was it The Forgotten Server 0.3 (Crying Damson) ???
 
Lol i dident find any file named Npc with xml format :/, but i only found Npc.Lua file

Code:
-- Include the Advanced NPC System
dofile('data/npc/lib/npcsystem/npcsystem.lua')

function doMessageCheck(message, keyword)
	if(type(keyword) == "table") then
		return table.isStrIn(keyword, message)
	else	
		local a, b = message:lower():find(keyword:lower())
		if(a ~= nil and b ~= nil) then
			return true
		end
	end

	return false
end

function selfGotoIdle()
	following = false
	attacking = false
	selfAttackCreature(0)
	target = 0
end

function selfMoveToCreature(id)
	if(id == 0 or id == nil) then
		selfGotoIdle()
	end

	local t = {}
	t.x, t.y, t.z = getCreaturePosition(id)
	if(t.x == nil) then
		selfGotoIdle()
	else
		moveToPosition(t.x, t.y, t.z)
	end
end

function getDistanceToCreature(id)
	if(id == 0 or id == nil) then
		selfGotoIdle()
	end

	local c = {}
	c.x, c.y, c.z = getCreaturePosition(id)
	if(c.x == nil) then
		return nil
	end

	local s = {}
	s.x, s.y, s.z = selfGetPosition()
	if(s.z ~= c.z) then
		return nil
	end

	return math.max(math.abs(s.x - c.x), math.abs(s.y - c.y))
end

function doNpcSellItem(cid, itemid, amount, subType, ignoreCap, inBackpacks, backpack)
	local amount = amount or 1
	local subType = subType or 0
	local ignoreCap = ignoreCap and TRUE or FALSE

	local item = 0
	if(isItemStackable(itemid) == TRUE) then
		item = doCreateItemEx(itemid, amount)
		if(doPlayerAddItemEx(cid, item, ignoreCap) ~= RETURNVALUE_NOERROR) then
			return 0, 0
		end

		return amount, 0
	end

	local a = 0
	if(inBackpacks) then
		local container = doCreateItemEx(backpack, 1)
		local b = 1
		for i = 1, amount do
			item = doAddContainerItem(container, itemid, subType)
			if(itemid == ITEM_PARCEL) then
				doAddContainerItem(item, ITEM_LABEL)
			end

			if(isInArray({(getContainerCapById(backpack) * b), amount}, i) == TRUE) then
				if(doPlayerAddItemEx(cid, container, ignoreCap) ~= RETURNVALUE_NOERROR) then
					break
				end

				a = i
				if(amount > i) then
					container = doCreateItemEx(backpack, 1)
					b = b + 1
				end
			end
		end
		return a, b
	end

	for i = 1, amount do
		item = doCreateItemEx(itemid, subType)
		if(itemid == ITEM_PARCEL) then
			doAddContainerItem(item, ITEM_LABEL)
		end

		if(doPlayerAddItemEx(cid, item, ignoreCap) ~= RETURNVALUE_NOERROR) then
			break
		end
		a = i
	end
	return a, 0
end

function doPosRemoveItem(_itemid, n, position)
	local thing = getThingFromPos({x = position.x, y = position.y, z = position.z, stackpos = 1})
	if(thing.itemid == _itemid) then
		doRemoveItem(thing.uid, n)
		return true
	end

	return false
end

function isPlayerPremiumCallback(cid)
	return isPremium(cid) == TRUE
end

function selfSayChannel(cid, message)
	return selfSay(message, cid, FALSE)
end

msgcontains = doMessageCheck
moveToPosition = selfMoveTo
moveToCreature = selfMoveToCreature
selfMoveToPosition = selfMoveTo
doNpcBuyItem = doPlayerRemoveItem
 
Okej i got 2 scripts that is with demon oak
Here is Demon Oak Info npc:
Code:
<npc name="Demon Oak Info" script="data/npc/scripts/oak info.lua" walkinterval="2000" floorchange="0" access="3" level="1" maglevel="1">
	<health now="150" max="150"/>
	<look type="57" head="115" body="113" legs="31" feet="38" addons="3" corpse="2212"/>
	<parameters>
		<parameter key="message_greet" value="Hello, |PLAYERNAME|!" />
		<parameter key="message_needmoremoney" value="Try again when you have more money."/>
		<parameter key="message_decline" value="Why would you tease me like that?"/>
	</parameters>
</npc>

Here is the Demon Oak Monk npc:

Code:
<npc name="Demon Oak Monk" script="data/npc/scripts/demon oak monk.lua" walkinterval="2000" floorchange="0" access="3" level="1" maglevel="1">
	<health now="150" max="150"/>
	<look type="57" head="115" body="113" legs="31" feet="38" addons="3" corpse="2212"/>
	<parameters>
		<parameter key="message_greet" value="Hello, |PLAYERNAME|!" />
		<parameter key="message_needmoremoney" value="Try again when you have more money."/>
		<parameter key="message_decline" value="Why would you tease me like that?"/>
	</parameters>
</npc>
 
Back
Top