Ir para conteúdo
  • Cadastre-se

(Resolvido)-=[TFS]=- 0.4 8.60 NPC PROMOTION COM MOEDA VIP 11192 SÓ PODE COMPRA PROMOTION SE TIVER 100 MOEDAS VIP


Ir para solução Resolvido por Mateus Robeerto,

Posts Recomendados

 

-=[TFS]=- 0.4 8.60 NPC PROMOTION COM MOEDA VIP 11192

 

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

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 node1 = keywordHandler:addKeyword({'promot'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Voce Tem Que Ter 100 [VIP COINS]. E Ter Level 717217!'})
	node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 100, level = 717217, promotion = 1, text = 'Congratulations! You are now promoted.'})
	node1:addChildKeyword({'yes'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then, come back when you are ready.', reset = true})

npcHandler:addModule(FocusModule:new())
Link para o post
Compartilhar em outros sites
12 horas atrás, Muvukaa disse:

 

-=[TFS]=- 0.4 8.60 NPC PROMOTION COM MOEDA VIP 11192

 


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

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 node1 = keywordHandler:addKeyword({'promot'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Voce Tem Que Ter 100 [VIP COINS]. E Ter Level 717217!'})
	node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 100, level = 717217, promotion = 1, text = 'Congratulations! You are now promoted.'})
	node1:addChildKeyword({'yes'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then, come back when you are ready.', reset = true})

npcHandler:addModule(FocusModule:new())

 

data > npc > scripts > NomeDoNPC.lua

 

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

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 config = {
	itemID   = 11192, -- ID da Moeda VIP
	quantity = 100,   -- Quantidade de moedas que o jogador precisa ter na mochila
	minLevel = 8      -- Level minimo que o jogador precisa ter para comprar a promotion
}

local itemName = getItemNameById(config.itemID)

function checkPlayerHavePromotion(cid)
	local currentVocation  = getPlayerVocation(cid) - 4
    local vocationPromoted = getPromotedVocation(currentVocation) - 4

    return currentVocation == vocationPromoted;
end


function checkPlayerHaveItems(cid, message, keywords, parameters, node)

	if (not npcHandler:isFocused(cid)) then
		return false
	end

	if (config.minLevel ~= nil and getPlayerLevel(cid) < config.minLevel) then
		npcHandler:say('You must reach level '..config.minLevel..' to buy promotion.', cid)
		return true
	end

	if checkPlayerHavePromotion(cid) then
		npcHandler:say('You are already promoted!', cid)
		return true
	end

	if (not doPlayerRemoveItem(cid, config.itemID, config.quantity)) then
		npcHandler:say('You do not have enough '..itemName..'!', cid)
		return true
	end

	doPlayerSetVocation(cid, getPlayerVocation(cid) + 4)
	npcHandler:say(parameters.text, cid)
	return true
end


local node1 = keywordHandler:addKeyword({'promot'}, StdModule.say, {
	npcHandler = npcHandler,
	onlyFocus  = true,
	text 	   = "I can promote you for "..config.quantity.." {"..itemName.."}. Do you want me to promote you?"
})

node1:addChildKeyword({'yes'}, checkPlayerHaveItems, {
	npcHandler = npcHandler,
	text	   = "Congratulations! You are now promoted."
})

node1:addChildKeyword({'no'}, StdModule.say, {
	npcHandler = npcHandler,
	onlyFocus  = true,
	reset 	   = true,
	text	   = "Alright then, come back when you are ready."
})

npcHandler:addModule(FocusModule:new())


data > npc > NomeDoNPC.xml

 

<?xml version="1.0" encoding="UTF-8"?>
<npc name="NomeDoNPC" script="data/npc/scripts/NomeDoNPC.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="160" head="77" body="79" legs="56" feet="115" addons="0"/>
</npc>


 

Link para o post
Compartilhar em outros sites
  • Solução
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

local vocation = {
    [2] = 6,
    [3] = 7,
    [4] = 8
}

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 = cid
    msg = string.lower(msg)
    local level = 717217

    if isInArray({"promotion", "promote", "promo"}, msg) then
        selfSay("You need to have 100 VIP COINS and be at level 717217!", cid)
        talkState[talkUser] = 1
    elseif msg == "yes" and talkState[talkUser] == 1 then
        local playerVocation = getPlayerVocation(cid)
        if vocation[playerVocation] then
            if getPlayerLevel(cid) >= level then
                if getPlayerItemCount(cid, 11192) >= 100 then
                    doPlayerRemoveItem(cid, 11192, 100)
                    local newVocationId = vocation[playerVocation]
                    doPlayerSetVocation(cid, newVocationId)
                    doSendMagicEffect(getPlayerPosition(cid), 12)
                    selfSay("Congratulations, you've been promoted!", cid)
                else
                    selfSay("You do not have enough VIP COINS to be promoted.", cid)
                end
            else
                selfSay("Sorry, you need to be at level " .. level .. " or above to be promoted!", cid)
            end
        else
            selfSay("Sorry, you cannot receive promotion.", cid)
        end
        talkState[talkUser] = 0
    end

    return true
end

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

 

Link para o post
Compartilhar em outros sites

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

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo