Ir para conteúdo

Featured Replies

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

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

local ITEM_ID = 7632
local ITEM_COUNT = 10

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, "promotion") then
		selfSay("I can promote you for ".. ITEM_COUNT .." ".. (ITEM_COUNT > 1 and getItemInfo(ITEM_ID).plural or getItemNameById(ITEM_ID)) ..". Do you want to be promoted?", cid)
		talkState[talkUser] = 1
	end

	if talkState[talkUser] == 1  then
		if msgcontains(msg, "yes") then
			if isPremium(cid) then
				if doPlayerRemoveItem(cid, ITEM_ID, ITEM_COUNT) then
					selfSay("Congratulations! You are now promoted!", cid)
					doPlayerSetPromotionLevel(cid, 1)
				else
					selfSay("Sorry, but you don't have ".. ITEM_COUNT .." ".. (ITEM_COUNT > 1 and getItemInfo(ITEM_ID).plural or getItemNameById(ITEM_ID)) ..".")
					talkState[talkUser] = 0
					npcHandler:releaseFocus(cid)
				end
			else
				selfSay("Sorry, but you aren't premium.", cid)
				talkState[talkUser] = 0
				npcHandler:releaseFocus(cid)
			end
		elseif msgcontains(msg, "no") then
			selfSay("Alright then, come back when you are ready.")
			talkState[talkUser] = 0
			npcHandler:releaseFocus(cid)
		end
	end
	return true
end

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

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

  • Respostas 10
  • Visualizações 495
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} function onCreatureAppear(cid) npcHandler:o

  • local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} function onCreatureAppear(cid) npcHandler:o

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.6k

Informação Importante

Confirmação de Termo