• 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]Premium NPC for TFS

Status
Not open for further replies.

onli

New Member
Joined
Aug 10, 2007
Messages
42
Reaction score
0
Hello, I'm searching for premium npc for Forgotten Server 0.2.3. I will be glad if u upload it here :)
 
Add this to npc/lib/npc.lua
Code:
function msgcontains(message, keyword)
	local a, b = string.find(message, keyword)
	if(a == nil or b == nil) then
		return false
	end
	return true
end

function pay(cid, cost)
	if doPlayerRemoveMoney(cid, cost) == 1 then
		return true
	else
		return false
	end
end
Premium & Promotion NPC
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
function creatureSayCallback(cid, type, msg)
-- OTServ event handling functions end
   
	if(npcHandler.focus ~= cid) then
		return false
	end

local node1 = keywordHandler:addKeyword({'promotion'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can promote you for 20000 gold coins. Do you want me to promote you?'})
	node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 20000, level = 20, text = 'Congratulations! You are now promoted.'})
	node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Allright then. Come back when you are ready.', reset = true})

	if msgcontains(msg, 'premium') then
		selfSay('Do you want to buy 7 days of premium for 7k?')
		talk_state = 1
		
	elseif talk_state == 1 then
		if msgcontains(msg, 'yes') then
			if pay(cid,7000) then
				doPlayerAddPremiumDays(cid, 7)
				selfSay('You have 7 days of premium more!')
			else
				selfSay('Sorry, you do not have enough money.')
			end
 		end
		talk_state = 0
	end
	return true
	
end	
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
No, it isnt included. Promote npc is only included.
Thx for this code, i will check it .
Ok, i tested it and it works. Thank u very much :)
 
Last edited:
Status
Not open for further replies.
Back
Top