Ir para conteúdo
  • Cadastre-se

Promotion no Johnny por Items?!


Posts Recomendados

Boa Noite gente.

Queria pedir um favor à vocês, visto o nível de habilidade que o fórum apresenta, ficarei grato se conseguirem.

Eu tenho um NPC de Promotion, que cobra 20k para Promover o Player, gostaria que ao invés de 2x Crystal Coins, fossem usados 10x do item 7632.

 

Script;

 

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 = 'I can promote you for 10 Collossus Orbs. Do you want me to promote you?'})
node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 20000, level = 20, promotion = 1, text = 'Congratulations! You are now promoted.'})
node1:addChildKeyword({'no'}, 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
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 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
		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())

Link para o post
Compartilhar em outros sites
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 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
		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())

Primeiramente, desculpem repostar, mas eu encontrei uma pequena falha no script e precisava comunicar..

Garou, o Script como eu disse, funcionou perfeitamente, mas há um problema, a Promotion no meu server, é apenas para Players premium account, e com esse Script, mesmo não sendo premium, eu perco os 10x Items, o NPC diz "congratulations[...]" mas não sou promovido, poderia colocar uma função em que o NPC falasse "Sorry, you must be Premium Account to this feature." caso o player não fosse premium?!

Obrigado!!

Link para o post
Compartilhar em outros sites
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 doPlayerRemoveItem(cid, ITEM_ID, ITEM_COUNT) and isPremium(cid) then
				selfSay("Congratulations! You are now promoted!", cid)
				doPlayerSetPromotionLevel(cid, 1)
			else
				selfSay("Sorry, but you don't have premium or ".. ITEM_COUNT .." ".. (ITEM_COUNT > 1 and getItemInfo(ITEM_ID).plural or getItemNameById(ITEM_ID)) ..".")
				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())

Link para o post
Compartilhar em outros sites
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 doPlayerRemoveItem(cid, ITEM_ID, ITEM_COUNT) and isPremium(cid) then
				selfSay("Congratulations! You are now promoted!", cid)
				doPlayerSetPromotionLevel(cid, 1)
			else
				selfSay("Sorry, but you don't have premium or ".. ITEM_COUNT .." ".. (ITEM_COUNT > 1 and getItemInfo(ITEM_ID).plural or getItemNameById(ITEM_ID)) ..".")
				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())

Ele envia a mensagem "Sorry, but you don't have premium or 10 Collossus Orbs.", não promove o Player, mas tira os 10x Items do Player!!

@up

Link para o post
Compartilhar em outros sites
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)

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