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

Need a little help with this NPC!

Mooosie

mistofdeath.com
Premium User
Joined
Aug 2, 2008
Messages
741
Solutions
2
Reaction score
52
Location
Sweden
I did a NPC who gives quest and needs level to accept it.
And when i am trying to give it a command to give the players storagevalue it bugs. i am usuing Aries 0.4.0 based on 8.1:

The Script:

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('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('Hello ' .. creatureGetName(cid) .. '! You want quest?')
 		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, 'q') or msgcontains(msg, 'quest') then
 			if getPlayerLevel(cid) < 1337 then
				selfSay('Sorry, you need level 1337 to do this quest.')
				talk_state = 0
			elseif not isPremium(cid) then
				selfSay('Sorry, you must be premium to get your second promotion.')
				talk_state = 0
			elseif getPlayerStorageValue(cid, 21733, 1) then
				selfSay('Youve Already Done This Quest.')
				talk_state = 0
			else
				selfSay('Bring me 1 AOL')
				talk_state = 1
			end

		elseif talk_state == 1 then
			if msgcontains(msg, 'yes') then
				if(getPlayerItemCount(cid, 2173) >= 1) then
				doPlayerRemoveItem(cid, 2173, 1)
				doPlayerAddItem(cid, 2148, 100)
				doPlayerSetStorageValue(cid, 21733, 1)
				doPlayerAddExp(cid, 500)
					selfSay('Here are your reward, hope you enjoy the quest!')
				else
					selfSay('Bring me The ITEM!')
				end
 			end

  		elseif 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()
	doNpcSetCreatureFocus(focus)
  	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

The NPC:

Code:
<?xml version="1.0"?>

<npc name="Quest Giver Eric" script="data/npc/scripts/quest2.lua" access="3" lookdir="2">
	<mana now="800000" max="80000"/>
	<health now="200" max="200"/>
<look type="128" head="78" body="71" legs="82" feet="114" addon="3" />
</npc>
 
Back
Top