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

[Release] Forgotten Server Premium Npc

hi,


Oke i made this npc on request for people, anywais i released my advanced one since so many need it, ther MIGHT be some bugs since i made this in 10 min...

What does this npc do?
-It sells premium to players ofcourse
-You can buy as many premium days at once. example
player: buy 50 premium days
npc: Are u sure you want to buy 50 premmy days for COST?

Premmy.xml
Code:
<npc name="Premmy" script="data/npc/scripts/premmy.lua" autowalk="1" floorchange="0" access="5" level="1" maglevel="1">
	<health now="150" max="150"/>
	<look type="133" head="20" body="120" legs="75" feet="13" corpse="2212"/>
	<parameters>
<parameter key="message_greet" value="Hello |PLAYERNAME|, Would u like to buy some premium days?" />
<parameter key="message_farewell" value="Good bye |PLAYERNAME|, Let the god of World of Tramon be with you!" />
	</parameters>
</npc>
Code:
-- 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

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 days = (getCount(msg))
     no_money = 'You do not have enough of money'
		
		if msgcontains(msg, 'price') or msgcontains(msg, 'help') then
			selfSay('Hello, I sell 1 day of premium for 2k, How many days would u like to buy?')
			

elseif msgcontains(msg, 'premium') or msgcontains(msg, 'yes')  then
	selfSay('How many days of premium would u like to buy, Remember 1 day of premmium is 2k.')
			talk_state = 1
			
elseif isNumber(getCount(msg)) and talk_state == 1 then
talk_state = 0
local total = math.floor(days*2000)
if doPlayerRemoveMoney(cid, total) == TRUE then
doPlayerAddPremiumDays(cid, days)
selfSay('You have successfully bought '..days..' days of premium for '..total..' Gold pieces.')
else
selfSay(no_money)
end

		elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 2) then
			selfSay('Get out of my sight!')
			talk_state = 0
			end
	    return true
           end
	
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())





How to change price per day of premmy:
Code:
local total = math.floor(days*[COLOR="Red"]2000[/COLOR])

The 2000=2k you can simply change it example.

If you want to make 1 day of premmium 5k simply change the 2000 to 5000

If you want to make 1 day of premmium 10k simply change the 2000 to 10000


If u get getCOunt errors add this in npc.lua at the end:
Code:
	-- Function used to match a number value from a string. the getCount Module
function getCount(msg)
 local ret = -1
 local b, e = string.find(msg, "%d+")
    if b ~= nil and e ~= nil then
       ret = tonumber(string.sub(msg, b, e))
    end
 
    return ret
end

Gimmy some bloody rep now!

It works for the forgotten server i suppose? :p
 
It works for the forgotten server i suppose? :p

it's special made for TFS and it worked on it but i dont know if it works on other servers.. if the have the latest version of the npc system i gues it should work try it!
 
Small bug on line ~25:
You need to use...

isNumber(getCount(msg)) == TRUE

If you use only isNumber(getCount(msg)), when the npc say "How many days of premium would u like to buy, Remember 1 day of premmium is 2k." and you say a letter ("a", for example) you can buy without pay.
 
Small bug on line ~25:
You need to use...



If you use only isNumber(getCount(msg)), when the npc say "How many days of premium would u like to buy, Remember 1 day of premmium is 2k." and you say a letter ("a", for example) you can buy without pay.

Thank you for your bug report =) it has been fixed


Every one who is using this npc please update it(updated minor bug fix)
 
BUG??

Warning: [NpcScript::NpcScript] Can not load script. data/npc/scripts/xxx.Premmy.lua
data/npc/scripts/xxx.Premmy.lua:25: 'then' expected near ')'

************
line 25: elseif isNumber(getCount(msg)) == TRUE) and talk_state == 1
FIXED? plz help!
 
BUG??

Warning: [NpcScript::NpcScript] Can not load script. data/npc/scripts/xxx.Premmy.lua
data/npc/scripts/xxx.Premmy.lua:25: 'then' expected near ')'

************
line 25: elseif isNumber(getCount(msg)) == TRUE) and talk_state == 1
FIXED? plz help!

moment.. gone fix it


try this

Code:
elseif isNumber(getCount(msg) == TRUE) and talk_state == 1
 
I don't remember all servers called world of tramon,anyways good work
 
Try this:
elseif isNumber(getCount(msg)) == TRUE and talk_state == 1 then

I tryt to fix the bug really fast.. it was an bug to get free premmy but i dident test it yet going to test it the first thing in the morning thx!


anywais going to remake the Premmy npc with agreement example.
23:12 Premmy: How many days of Premium would u like to buy? Remember 1 day for 2k
23:12 Flikker [1]: 2
23:12 Premmy: Are u sure you want to buy 2 days of premium for 4000 Gold pieces?
23:12 Flikker [1]: yes
 
Last edited:
Updated The thread I'v added an new Premmy npc with that Npc You need to Confurm buying it!
 
Thanks again Moker. once again you have posted a great script, keep working. :D
 
Thanks again Moker. once again you have posted a great script, keep working. :D

Hehe thank you but i'm running out of ideas, i think i'm going to focus my self on Developening new things instead this big premmy script it could become.
this

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 node1 = keywordHandler:addKeyword({'premmy'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'How many days would u like to buy?'})
	node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 2000, days = 2, level = 20, text = 'Congratulations! You have perchaed premmy!'})
	node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Allright then. Come back when you are ready.', reset = true})

npcHandler:addModule(FocusModule:new())


but ofcourse it will calculate priseXdays =) but i think i wont make it since the other npc's work perfect
 
Back
Top