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

[Request] Softboots Npc for TFS 0.2 (Mystic Spirit)

Alexo

New Member
Joined
Aug 18, 2007
Messages
27
Reaction score
0
Can anyone make the script for the npc, or just post it here, i really need it and my old npc dont work for this version.
Thanks~~
 
Here you are, I just edited a script, i dont tested it so i dont know if it works :p, but try this:

PHP:
local focuses = {}
local function isFocused(cid)
	for i, v in pairs(focuses) do
		if(v == cid) then
			return true
		end
	end
	return false
end
 
local function addFocus(cid)
	if(not isFocused(cid)) then
		table.insert(focuses, cid)
	end
end
local function removeFocus(cid)
	for i, v in pairs(focuses) do
		if(v == cid) then
			table.remove(focuses, i)
			break
		end
	end
end
local function lookAtFocus()
	for i, v in pairs(focuses) do
		if(isPlayer(v) == TRUE) then
			doNpcSetCreatureFocus(v)
			return
		end
	end
	doNpcSetCreatureFocus(0)
end
 
---
 
 
function onCreatureAppear(cid)
end
 
function onCreatureDisappear(cid)
	if(isFocused(cid)) then
		selfSay("Hmph!")
		removeFocus(cid)
		if(isPlayer(cid) == TRUE) then --Be sure he's online
			closeShopWindow(cid)
		end
	end
end
 
function onCreatureSay(cid, type, msg)
	if((msg == "hi") and not (isFocused(cid))) then
		addFocus(cid)
		selfSay("Hello, ".. getCreatureName(cid) .." I can repair your {soft boots}", cid)

	elseif((isFocused(cid)) and (msg == "soft boots")) then
				selfSay("Do you want that I repair your soft boots?", cid)
				talk_state = 1
			
	elseif((isFocused(cid)) and (msg == "yes")) and talk_state == 1 then
	if doPlayerRemoveMoney(cid,300000) == 1 then
	        if doPlayerRemoveItem(cid,6530,1) == 1 then
	                doPlayerAddItem(cid,6132,1)
           		doPlayerSendTextMessage(cid,22,"Your pair of soft boots has been repaired.", cid) 
	else
        	doPlayerSendCancel(cid, "You need 30cc to repair your soft boots.", cid)
	end
		else 
		  	doPlayerSendCancel(cid, "You have not a worn soft boots.", cid)
		end
       
	elseif((isFocused(cid)) and (msg == "bye" or msg == "goodbye" or msg == "cya")) then
		selfSay("Goodbye!", cid)
		closeShopWindow(cid)
		removeFocus(cid)
	end
end
 
function onPlayerCloseChannel(cid)
	if(isFocused(cid)) then
		selfSay("Hmph!")
		removeFocus(cid)
	end
end
 
function onPlayerEndTrade(cid)
	selfSay("It was a pleasure doing business with you.", cid)
end
 
function onThink()
	for i, focus in pairs(focuses) do
		if(isCreature(focus) == FALSE) then
			removeFocus(focus)
		else
			local distance = getDistanceTo(focus) or -1
			if((distance > 4) or (distance == -1)) then
				selfSay("Hmph!")
				closeShopWindow(focus)
				removeFocus(focus)
			end
		end
	end
	lookAtFocus()
end

Edited

Say me what happens

Cya
 
Last edited:
Try this, I've been using this for a while now and it works fine.

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
 
-- OTServ event handling functions start
function onCreatureAppear(cid)                npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid)             npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg)     npcHandler:onCreatureSay(cid, type, msg) end
function onThink()                         npcHandler:onThink() end
-- OTServ event handling functions end

local talkNode = 0

function creatureSayCallback(cid, type, msg)
    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
    if(npcHandler.focus ~= cid) then
        return false
    end
        
	local player_gold = getPlayerItemCount(cid,2148)
	local player_plat = getPlayerItemCount(cid,2152)*100
	local player_crys = getPlayerItemCount(cid,2160)*10000
	local player_money = player_gold + player_plat + player_crys
       
	if msgcontains(msg, 'repair') then
		selfSay('Do you want me to repair your soft boots for 10k gold?')
		talkNode = 1
	elseif msgcontains(msg,'job') then
        selfSay('I\'m a soft boots repairer.')
    elseif msgcontains(msg,'yes') then
		if talkNode == 1 then
			if getPlayerItemCount(cid,6530) >= 1 then
				if player_money >= 10000 then
					doPlayerRemoveItem(cid,6530,1)
					doPlayerRemoveMoney(cid,10000)
					selfSay('Here you are.')
					doPlayerAddItem(cid,2640,1)
					talkNode = 0
				else
					selfSay('You don\'t have enough money.')
					talkNode = 0
				end
			else
				selfSay('You don\'t have any soft boots.')
				talkNode = 0
			end
		end
	elseif msgcontains(msg, 'no') then
		if talkNode == 1 then
			selfSay('Then keep them dirty.')
			talkNode = 0
		end
	end
	
	return TRUE
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Back
Top