Ir para conteúdo

Featured Replies

Postado
local config = {
	gold = 20, -- Gold necessário
	cd = 2, -- Intervalo em minutos

	storage = 2612, -- Não necessita configurar
}

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
npcHandler.topic = {}

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(cid)                  		npcHandler:onThink(cid)                    end


local function creatureSayCallback(cid, type, msg)
	if not npcHandler:isFocused(cid) then
		return false
	end
	
	if msgcontains(msg, "promotion") or msgcontains(msg, "promote") then
		if getPlayerVocation(cid) > 4 then
			npcHandler:say("Sorry, you are already promoted.", cid)
		elseif not isPremium(cid) then
			npcHandler:say("Sorry, you must be premium to buy promotion.", cid)
		else
			npcHandler:say("Do you want to buy promotion for 20k?", cid)
			npcHandler.topic[cid] = 1
		end
	elseif msgcontains(msg, "yes") and npcHandler.topic[cid] == 1 then
		if doPlayerRemoveMoney(cid, 20000) then
			doPlayerSetVocation(cid, getPlayerVocation(cid) + 4)
			npcHandler:say("You are now promoted!", cid)
		else
			npcHandler:say("Sorry, you do not have enough money.", cid)
		end

		npcHandler.topic[cid] = 0
	elseif msgcontains(msg, "desbug") then
		if os.time() - getPlayerStorageValue(cid, config.storage) >= config.intervalo * 60 then
			npcHandler:say("Quer desbugar por ".. config.gold .." gold?", cid)
			npcHandler.topic[cid] = 2
		else
			npcHandler:say("Não posso te desbugar agora.")
		end
	elseif msgcontains(msg, "yes") and npcHandler.topic[cid] == 2 then
		if doPlayerRemoveMoney(cid, config.gold) then
			doPlayerAddLevel(cid, 1)
			setPlayerStorageValue(cid, config.storage, os.time())
			npcHandler:say("Pronto adicionado", cid)
		else
			npcHandler:say("Sorry, you do not have enough money.", cid)
		end

		npcHandler.topic[cid] = 0
	end


	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

-"Supra Omnes Lux Lucis"

- Acima de todos brilha a Luz -

5VGnDyBz.png

  • Respostas 6
  • Visualizações 394
  • Created
  • Última resposta

Top Posters In This Topic

Postado
  • Autor
local config = {
	gold = 20, -- Gold necessário
	cd = 2, -- Intervalo em minutos

	storage = 2612, -- Não necessita configurar
}

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
npcHandler.topic = {}

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(cid)                  		npcHandler:onThink(cid)                    end


local function creatureSayCallback(cid, type, msg)
	if not npcHandler:isFocused(cid) then
		return false
	end
	
	if msgcontains(msg, "promotion") or msgcontains(msg, "promote") then
		if getPlayerVocation(cid) > 4 then
			npcHandler:say("Sorry, you are already promoted.", cid)
		elseif not isPremium(cid) then
			npcHandler:say("Sorry, you must be premium to buy promotion.", cid)
		else
			npcHandler:say("Do you want to buy promotion for 20k?", cid)
			npcHandler.topic[cid] = 1
		end
	elseif msgcontains(msg, "yes") and npcHandler.topic[cid] == 1 then
		if doPlayerRemoveMoney(cid, 20000) then
			doPlayerSetVocation(cid, getPlayerVocation(cid) + 4)
			npcHandler:say("You are now promoted!", cid)
		else
			npcHandler:say("Sorry, you do not have enough money.", cid)
		end

		npcHandler.topic[cid] = 0
	elseif msgcontains(msg, "desbug") then
		if os.time() - getPlayerStorageValue(cid, config.storage) >= config.intervalo * 60 then
			npcHandler:say("Quer desbugar por ".. config.gold .." gold?", cid)
			npcHandler.topic[cid] = 2
		else
			npcHandler:say("Não posso te desbugar agora.")
		end
	elseif msgcontains(msg, "yes") and npcHandler.topic[cid] == 2 then
		if doPlayerRemoveMoney(cid, config.gold) then
			doPlayerAddLevel(cid, 1)
			setPlayerStorageValue(cid, config.storage, os.time())
			npcHandler:say("Pronto adicionado", cid)
		else
			npcHandler:say("Sorry, you do not have enough money.", cid)
		end

		npcHandler.topic[cid] = 0
	end


	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

 

Vou testar, volto pra pra dizer se funcionou ou não.

 

@Edit, deu erro aqui na linha 8

Editado por seminu (veja o histórico de edições)

5nJc23M.png

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.7k

Informação Importante

Confirmação de Termo