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

I've serached but no results, someone have a Premium NPC for 0.3 alpha?

I know this functio, but the problem isnt that, my old NPC has this function, but anything changed in this version that dont allow to my NPC reply when I answer "premium" or "premmy".

Check that:
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 = 1000  ------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, 'premium') or msgcontains(msg, 'premmy') then
selfSay('Do you want to buy \'30\' premium days for \'25000\' gold coins?')
talk_state = 1    

elseif msgcontains(msg, 'yes') and talk_state == 1 then
if doPlayerRemoveMoney(cid, 25000) == TRUE then
doPlayerAddPremiumDays(cid, 30)
selfSay('You have successfully bought \'30\' days of premium for \'25000\' 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())
 
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local days = 30
local price = 1000

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)
	if(not npcHandler:isFocused(cid)) then
		return false
	end
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
        
	if msgcontains(msg, 'premium') or msgcontains(msg, 'premmy') then
	selfSay("Do you want to buy "..days.." premium days for "..price.." gold coins?", cid)
	talkState[talkUser] = 1    

	elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
		if doPlayerRemoveMoney(cid, price) == TRUE then
			doPlayerAddPremiumDays(cid, days)
			selfSay("You have successfully bought "..days.." days of premium for "..price.." gold pieces.", cid)
		else
			selfSay("You do not have enough money. "..days.." days of premium cost "..price.." gold coins.", cid)
		end
	talkState[talkUser] = 0
	elseif msgcontains(msg, 'no') and talkState[talkUser] == 1 then
	    selfSay("Then not.", cid)
	    talkState[talkUser] = 0
	end
	return TRUE
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
Moved to requests and support.

Please try to use our forum in the correct way.
 
Back
Top