• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

NPC Engraving NPC

xxgoosexx

GoosioOT
Joined
Jul 10, 2007
Messages
298
Reaction score
2
FIXED BUG

Noob setup but it works - teleports player into room so no one can mess with them, then player puts item on basin, and then says what they want engraved then the item is engraved and the player is tp'd back out.

could use alot of work but meh enjoy, comment, etc

http://img56.imageshack.us/img56/8049/npcsq1.png

Code:
local focus = 0
local talk_start = 0
local target = 0
local days = 0
local msg = ''

function onThingMove(creature, thing, oldpos, oldstackpos)

end

function onCreatureAppear(creature)

end

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

function onCreatureTurn(creature)

end

function onCreatureSay(cid, type, msg)
	if (msgcontains(msg, 'hi') or msgcontains(msg, 'hello')) and (focus == 0) and getDistanceToCreature(cid) < 4 then
		doNpcSetCreatureFocus(cid)
 		selfSay('Hello ' .. getCreatureName(cid) .. '! Would you like an item "engraved"?')
 		focus = cid
 		talk_start = os.clock()
	elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
  		selfSay('Sorry, ' .. getCreatureName(cid) .. '! I\'ll talk to you in a moment.')
	elseif focus == cid then
		talk_start = os.clock()
		if msgcontains(msg, 'engrave') or msgcontains(msg, 'engraved') then
			doTeleportThing(cid,{x=1047,y=1032,z=7})
			doSendMagicEffect({x=1047,y=1032,z=7},10)
			selfSay('Place the item you want engraved on the basin and let me know when you are "ready".')
			talk_state = 1
		end
				
		if msgcontains(msg, 'ready') and talk_state == 1 then
			basin = getThingfromPos({x=1048,y=1032,z=7, stackpos=255})
			if basin.itemid ~= 0 then
 				selfSay('What do you wish to be engraved? It will cost 1,000 gp to do.')
				doRemoveItem(basin.uid,1) 
				doSendMagicEffect({x=1048,y=1032,z=7},15)
				talk_state = 2
				local msg = ''
			else
				selfSay('You did not place an item on the basin. Please do and let me know when you are "ready".')
				talk_state = 3
			end
		elseif talk_state == 2 and (msg ~= 'stop') then
			if doPlayerRemoveMoney(cid,1000) == TRUE then
	                	item = doPlayerAddItem(cid,basin.itemid,1)
				doSetItemSpecialDescription(item,msg)
				selfSay('Here you are. Please visit again soon.')
				doTeleportThing(cid,{x=1048,y=1028,z=7})
				doSendMagicEffect({x=1048,y=1028,z=7},10)
				focus = 0
				talk_start = 0
				talk_state = 0
			else
				doPlayerAddItem(cid,basin.itemid,1)
				selfSay('Come back when you have enough money.')
				doTeleportThing(cid,{x=1048,y=1028,z=7})
				doSendMagicEffect({x=1048,y=1028,z=7},31)				
				focus = 0
				talk_start = 0
				talk_state = 0
			end
		elseif talk_state == 3 then
			basin = getThingfromPos({x=1048,y=1032,z=7, stackpos=255})
			if basin.itemid ~= 0 then
 				selfSay('What do you wish to be engraved? It will cost 1,000 gp to do.')
				doRemoveItem(basin.uid,1) 
				doSendMagicEffect({x=1048,y=1032,z=7},15)
				talk_state = 2
				local msg = ''
			else
				selfSay('Please come back when you have an item to be engraved.')
				doTeleportThing(cid,{x=1048,y=1028,z=7})
				doSendMagicEffect({x=1048,y=1028,z=7},31)				
				focus = 0
				talk_start = 0
				talk_state = 0
			end
		end

		if msgcontains(msg, 'bye')  and getDistanceToCreature(cid) < 4 then
  			selfSay('Good bye.')
  			focus = 0
  			talk_start = 0
			talk_state = 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
 
Last edited:
Reall good idead but a little impractical, what if 2 people try it at the same time?
 
Reall good idead but a little impractical, what if 2 people try it at the same time?

it acts just like any other npc, if someone else says hi then they have to wait, its not the best way of doing it, but i wanted to be a little different :)
 
fixed bug allowed players to receive the last item that was engraved just by saying "hi, yes"
 
aaah niiice man surprisingly never thought of that Thanks for this great idea and release xxgoosexx!!
 
But let me ask you, will this work for the new TFS? :p oha nd what does the finished engraved product look like? just liek it says whats engraved when you click on it? and if so does it stay there after a restart?
 
But let me ask you, will this work for the new TFS? :p oha nd what does the finished engraved product look like? just liek it says whats engraved when you click on it? and if so does it stay there after a restart?

yes it works on TFS :) thats what i use, the item looks the same, when you look at it it will be like : You see a torch. it weighs 8.0 oz. I Engraved This Item., and yes it stays when the server is restarted
 
http://img56.imageshack.us/img56/8049/npcsq1.png

make a spot similar to that on your map, and then you'll have to edit the coordinates to fit your map :)

in your npc folder, name Engrave.xml or whatever, name the npc whatever you'd like and change the outfit etc..
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Engraver" script="data/npc/scripts/engrave.lua" walkinterval="2500" floorchange="0" access="5" level="1" maglevel="1">
	<health now="150" max="150"/>
	<look type="129" head="114" body="119" legs="114" feet="114" corpse="2212"/>
	<parameters>
	</parameters>
</npc>

then paste your script into the engrave.lua~ or whatever you want to call it according to the above npc script
 
tahnks, :p but what cordinates do i edit and which cordinates are the basin, place u get tped to and place u get tped back to? Thanks, TOny
 
tahnks, :p but what cordinates do i edit and which cordinates are the basin, place u get tped to and place u get tped back to? Thanks, TOny

in my script where ever it says
Code:
doTeleportThing(cid,{x=1048,y=1028,z=7})
the position you get tp'd when you exit


Code:
doTeleportThing(cid,{x=1047,y=1032,z=7})
the position in front of the basin


Code:
basin = getThingfromPos({x=1048,y=1032,z=7, stackpos=255})
the basin coordinates

maybe i'll rewrite it to be more configurable, it was just a test script to begin with
 
Back
Top