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?