Ir para conteúdo

Featured Replies

  • Respostas 10
  • Visualizações 1.8k
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • "data/npcs/Gnomally.xml" : <?xml version="1.0" encoding="UTF-8"?> <npc name="Gnomally" script="Gnomally.lua" walkinterval="2000" floorchange="0"> <health now="100" max="100"/>

Postado

"data/npcs/Gnomally.xml" :

<?xml version="1.0" encoding="UTF-8"?>
<npc name="Gnomally" script="Gnomally.lua" walkinterval="2000" floorchange="0">
    <health now="100" max="100"/>
    <look type="507" head="13" body="111" legs="111" feet="115"/>
    <parameters>
        <parameter key="message_greet" value="Hi |PLAYERNAME|, I sell equipment for {minor} and {major} crystals."/>
        <parameter key="message_farewell" value="Good bye."/>
    </parameters>
</npc>

"data/npcs/scripts/Gnomally.lua" :

local keywordHandler = KeywordHandler:new() 
local npcHandler = NpcHandler:new(keywordHandler) 
NpcSystem.parseParameters(npcHandler) 
local talkState = {} 
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
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 greetCallback(cid)
talkState[talkUser] = 0
return true
end

local itemsSellMinor = {
	{itemId = 18215, quantCt = 2},
	{itemId = 18395, quantCt = 8},
	{itemId = 18509, quantCt = 10},
	{itemId = 18388, quantCt = 15},
	{itemId = 18393, quantCt = 15},
	{itemId = 18521, quantCt = 70},
	{itemId = 18518, quantCt = 70}
}
local minorCrystalId = 18422

local itemsSellMajor = {
	{itemId = 18398, quantCt = 10},
	{itemId = 18399, quantCt = 10},
	{itemId = 18400, quantCt = 10},
	{itemId = 18401, quantCt = 10},
	{itemId = 18403, quantCt = 10},
	{itemId = 18404, quantCt = 10},
	{itemId = 18405, quantCt = 10},	
	{itemId = 18406, quantCt = 10},
	{itemId = 18410, quantCt = 10},	
	{itemId = 18520, quantCt = 20},
	{itemId = 18517, quantCt = 20},
	{itemId = 18447, quantCt = 20},
	{itemId = 18448, quantCt = 20}
}
local majorCrystalId = 18423

function getMinor()
local textM = ""
for i=1, #itemsSellMinor do
	if i < #itemsSellMinor then
		textM = textM.. getItemNameById(itemsSellMinor[i].itemId) ..", "
	else
		textM = textM.. getItemNameById(itemsSellMinor[i].itemId) .."."
	end
end
return textM
end

function getMajor()
local textJ = ""
for i=1, #itemsSellMajor do
	if i < #itemsSellMajor then
		textJ = textJ.. getItemNameById(itemsSellMajor[i].itemId) ..", "
	else
		textJ = textJ.. getItemNameById(itemsSellMajor[i].itemId) .."."
	end
end
return textJ
end

function getArrayMinor()
local arrayMinor = {}
for i=1, #itemsSellMinor do
	arrayMinor[#arrayMinor+1] = getItemNameById(itemsSellMinor[i].itemId)
end
return arrayMinor
end

function getArrayMajor()
local arrayMajor = {}
for i=1, #itemsSellMajor do
	arrayMajor[#arrayMajor+1] = getItemNameById(itemsSellMajor[i].itemId)
end
return arrayMajor
end

function creatureSayCallback(cid, type, msg) 

local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local storageNpc = 495021

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

if msgcontains(msg, 'yes') and  getPlayerStorageValue(cid, storageNpc) > 0 then
	local item = getPlayerStorageValue(cid, storageNpc)
	for i=1, #itemsSellMinor do
		if itemsSellMinor[i].itemId == item then
			if doPlayerRemoveItem(cid, minorCrystalId, itemsSellMinor[i].quantCt) then
				doPlayerAddItem(cid, item, 1)
				selfSay("Pick up your item.", cid)
				setPlayerStorageValue(cid, storageNpc, -1)
			else
				selfSay("I dont have crystals for buy item!", cid)
				setPlayerStorageValue(cid, storageNpc, -1)
			end
			break
		end
	end
	for i=1, #itemsSellMajor do
		if itemsSellMajor[i].itemId == item then
			if doPlayerRemoveItem(cid, majorCrystalId, itemsSellMajor[i].quantCt) then
				doPlayerAddItem(cid, item, 1)
				selfSay("Pick up your item.", cid)
				setPlayerStorageValue(cid, storageNpc, -1)
			else
				selfSay("I dont have crystals for buy item!", cid)
				setPlayerStorageValue(cid, storageNpc, -1)
			end
			break
		end
	end
end

if msgcontains(msg, 'minor') then
	selfSay("I selling for minor crystals: "..getMinor(), cid)
elseif msgcontains(msg, 'major') then
	selfSay("I selling for major crystals: "..getMajor(), cid)
elseif isInArray(getArrayMinor(), msg)  then
	local item = getItemIdByName(msg)
	for i=1, #itemsSellMinor do
		if itemsSellMinor[i].itemId == item then
			selfSay("I selling ".. msg .." for ".. itemsSellMinor[i].quantCt .." minor, you accept my offer?", cid)
			setPlayerStorageValue(cid, storageNpc, item)
			break
		end
	end
elseif isInArray(getArrayMajor(), msg) then
	local item = getItemIdByName(msg)
	for i=1, #itemsSellMajor do
		if itemsSellMajor[i].itemId == item then
			selfSay("I selling ".. msg .." for ".. itemsSellMajor[i].quantCt .." minor, you accept my offer?", cid)
			setPlayerStorageValue(cid, storageNpc, item)
			break
		end
	end
end

return true
end

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

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