• 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

Mokerhamer

Retired Global Mod
Senator
Joined
Aug 6, 2007
Messages
1,767
Reaction score
35
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...

The Getcount script at the bottum of the page is ONLy for the second premmy npc!

====With Confirming (You need to agree with "yes" to buy)Premmy===

-It sells premium to players ofcourse
-You can buy as many premium days at once. example
player: buy 50 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|, How many days of premium would u like to buy??" />
<parameter key="message_farewell" value="Good bye |PLAYERNAME|, Let the god of World of Tramon be with you!" />
	</parameters>
</npc>


Premmy.lua
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

function creatureSayCallback(cid, type, msg)
	if(npcHandler.focus ~= cid) then
		return false
	end

-----------------------------------------------------ONLY CHANGES THIS!!!!--------------------------------	
      prise = 2000  ------2000 Means  2k for eatch day change it if u want
------------------------------------------DONT CHANGE ANYTHING ELSE!!!!-------------------
	  
     no_money = 'You do not have enough of money'
		
if msgcontains(msg, 'days') or msgcontains(msg, 'day')and ShopModule:getCount(msg) <= 20 then
days = ShopModule:getCount(msg)
total = prise*days
selfSay('Are u sure you want to buy '..days..' premium days for '..total..' gold coins?')
talk_state = 1	

elseif msgcontains(msg, 'yes') and talk_state == 1 then
if doPlayerRemoveMoney(cid, total) == TRUE then
doPlayerAddPremiumDays(cid, days)
selfSay('You have successfully bought '..days..' day(s) of premium for '..total..' Gold pieces.')
else
selfSay(no_money)
end
		
		elseif msgcontains(msg, 'no') and talk_state == 1 then
			selfSay('Get out of my sight!')
			talk_state = 0
			end
	    return true
           end
	
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())







===Without Confirming (You dont have to sai "yes" to buy) Premmy===

What does this npc do?
-It sells premium to players ofcourse
-You can buy as many premium days at once.

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:
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

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)) == TRUE 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!
 
Last edited:
Added the getCount functions or the npc wont work :p nice other people dont have the getCOunt function
 
Hehe nice i hope loads of people will use this since it was my advanced one lol
 
i have maked one yet..
but the trick of getcount msg i don't now :D

thanks!
 
No problem i can give more nice comments like, nice again :D:D!

anywais keep this paige in the eye sight sinc i'm going to update it soon if you have some npc requests please tell me.
 
á, and THANKS FOR PREMMY NPC.
but, a Promotion+Premmy npc will be rox :X
 
but a promotion and premmy functions in same npc will be sweet ¬¬
 
Back
Top