Ir para conteúdo

Featured Replies

Postado

@FaaSouzax  mano configurei um script bem meio boca aqui pois não sei muito sobre LUA

caso te agrade ta ai o script \/ \/

 

local cfg = {
    watergem = 21699,
    watergemqnt = 1,    
    batwing = 24301,
    batwingqnt = 1,    
    applebite = 21699,
    applebiteqnt = 1,    
    reward2 = 0,
    reward2qnt = 0,
    reward3 = 0,
    reward3qnt = 0,
    palavra = "yes",
    mensagem = "Você precisa ter os itens e quantidades corretos.",
    concluir = "Obrigado! Pegue essa cruz e essa caixa como forma de gratidão!"
}
 
local messenge = {
errormsg = "Você ja me entregou os itens necessarios"
}
 
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
 
function playerHaveItems(cid, itemid)
local items = type(itemid) == "table" and itemid or {itemid}
for i = 1, #items do
if getPlayerItemCount(cid, items) <= 0 then
return false
end
end
return true
end
 
function doPlayerRemoveItems(cid, itemid, count)
local items = type(itemid) == "table" and itemid or {itemid}
for i = 1, #items do
doPlayerRemoveItem(cid, items, count ~= nil and count or 1)
end
return nil
end
 
function creatureSayCallback(cid, type, msg)
 
if(not npcHandler:isFocused(cid)) then
return false
end

if getPlayerStorageValue(cid, 56473) == 1 then
selfsay(messenge.errormsg)
return true
end 
 
if msgcontains(msg, cfg.palavra) then
if getPlayerStorageValue(cid, 56473) == -1 then
if getPlayerItemCount(cid, cfg.watergem) >= 1 and getPlayerItemCount(cid, cfg.batwing) >= 1 and getPlayerItemCount(cid, cfg.applebite) >= 1 then
doPlayerRemoveItem(cid, cfg.watergem, cfg.watergemqnt)
doPlayerRemoveItem(cid, cfg.batwing, cfg.batwingqnt)
doPlayerRemoveItem(cid, cfg.applebite, cfg.applebiteqnt)
doPlayerRemoveItem(cid, cfg.eggs, cfg.eggsqnt)
doPlayerAddItem(cid, cfg.reward2, cfg.reward2qnt)
doPlayerAddItem(cid, cfg.reward3, cfg.reward3qnt)
setPlayerStorageValue(cid, 56473, 1)
selfSay(cfg.concluir)
else
selfSay(cfg.mensagem)
end
end 
end
return true
 
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

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

  • Respostas 13
  • Visualizações 909
  • Created
  • Última resposta

Top Posters In This Topic

Posted Images

Postado

Tenta esse código meu chapa, modifiquei alguns erros que notei por cima:

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 items = {{21699, 1},{24301, 1}} --id do item, quantidade 

function creatureSayCallback(cid, type, msg)
	local msg, player = string.lower(msg), Player(cid)
	if not npcHandler:isFocused(cid) then
		if isInArray({"hi", "hello"}, msg) then
			npcHandler:addFocus(cid)
			if player:getStorageValue(56473) == -1 then
				if player:getStorageValue(56473) == -1 then
					npcHandler:say("Hi, ".. player:getName().."! hello young warrior, I realized that you are looking for some adventures, if you can {help} me I can ask one of my servants to take you to a mysterious island.?", cid)
					npcHandler.topic[cid] = 1
				elseif
				npcHandler:say("help, ".. player:getName().."! So you are interested? well, what I ask is simple, I have lost 3 chests with personal treasures through the forest, manholes and building, can you bring me the items that they contain??", cid)
				npcHandler.topic[cid] = 2
			else
				npcHandler:say("Hi, ".. player:getName().."! Can you find my treasures?", cid)
				npcHandler.topic[cid] = 3
			end
		else
			npcHandler:say("I have already told my servant that I can help you to reach such an island.", cid)
			npcHandler.topic[cid] = 0
			npcHandler:releaseFocus(cid)
		end
	elseif msgcontains(msg, "yes") and npcHandler.topic[cid] == 1 then
		player:setStorageValue(56473, 1)
		npcHandler:say("Ok, now I will wait for you. Be careful!", cid)
		npcHandler.topic[cid] = 0
		npcHandler:releaseFocus(cid)
	elseif msgcontains(msg, "yes") and npcHandler.topic[cid] == 2 then
		player:setStorageValue(56473, 1)
		npcHandler:say("Ok, now I will wait for you. Be careful!", cid)
		npcHandler.topic[cid] = 0
		npcHandler:releaseFocus(cid)
	elseif msgcontains(msg, "yes") and npcHandler.topic[cid] == 3 then
		if player:removeItem(items[1][1], items[1][2]) then
			player:setStorageValue(56473, 1)
			npcHandler:say("Thanks! I'll tell my servant that I can take you to the island.", cid)
			npcHandler.topic[cid] = 0
		else
			npcHandler:say("Sorry, but you still have not found all my treasures.", cid)
			npcHandler.topic[cid] = 0
		end
	elseif msgcontains(msg, "no") and npcHandler.topic[cid] == 2 then
		npcHandler:say("Ok, I will wait a bit more.", cid)
		npcHandler.topic[cid] = 0
	elseif msgcontains(msg, "bye") then
		npcHandler:say("Bye.", cid)
		npcHandler:releaseFocus(cid)
	else
		npcHandler:say("What?", cid)
		npcHandler.topic[cid] = 0
	end
	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

Você utilizou de modo errado a matriz (array dentro de array), você colocou 3 items dentro do array "items", sendo que o primeiro e o terceiro são iguais, então acho que o último é desnecessário.

OBS: Você tem dois items ainda dentro do array, mas só usa um, vou lhe explicar como funciona a matriz:

items = {
	{"a",1},
  	{"b",2}
}

Se você digitar:
 

print(items[1])

Retornará apenas o valor da tabela (matriz), mas se digitar:
 

print(items[1][2])

Resultará o segundo valor ([2]) da primeira ([1]) casa do array items:

1


 

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

Programador PHP, Lua, Java, database administrator.

 

"Nada é verdade, tudo é permitido."

Requiescat in pace.

Postado
  • Autor

@Nazo Sim, esqueci de editar o primeiro item ali como disse, coloquei 2 iguais, eu coloquei seu script e tudo mais, só que o erro persistiu ainda.

 


[Warning - NpcScript::NpcScript] Can not load script: Archery.lua
data/npc/scripts/Archery.lua:6: '}' expected near '{'
[Warning - NpcScript::NpcScript] Can not load script: Archery.lua
data/npc/scripts/Archery.lua:6: '}' expected near '{'
 

 

Eu tentei o que voce me mandou e dps tentei modificando só adicionando um item a mais.



 


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 items = {{21699, 1},{24301, 1}, {23495, 1}} --id do item, quantidade 

function creatureSayCallback(cid, type, msg)
    local msg, player = string.lower(msg), Player(cid)
    if not npcHandler:isFocused(cid) then
        if isInArray({"hi", "hello"}, msg) then
            npcHandler:addFocus(cid)
            if player:getStorageValue(56473) == -1 then
                if player:getStorageValue(56473) == -1 then
                    npcHandler:say("Hi, ".. player:getName().."! hello young warrior, I realized that you are looking for some adventures, if you can {help} me I can ask one of my servants to take you to a mysterious island.?", cid)
                    npcHandler.topic[cid] = 1
                elseif
                npcHandler:say("help, ".. player:getName().."! So you are interested? well, what I ask is simple, I have lost 3 chests with personal treasures through the forest, manholes and building, can you bring me the items that they contain??", cid)
                npcHandler.topic[cid] = 2
            else
                npcHandler:say("Hi, ".. player:getName().."! Can you find my treasures?", cid)
                npcHandler.topic[cid] = 3
            end
        else
            npcHandler:say("I have already told my servant that I can help you to reach such an island.", cid)
            npcHandler.topic[cid] = 0
            npcHandler:releaseFocus(cid)
        end
    elseif msgcontains(msg, "yes") and npcHandler.topic[cid] == 1 then
        player:setStorageValue(56473, 1)
        npcHandler:say("Ok, now I will wait for you. Be careful!", cid)
        npcHandler.topic[cid] = 0
        npcHandler:releaseFocus(cid)
    elseif msgcontains(msg, "yes") and npcHandler.topic[cid] == 2 then
        player:setStorageValue(56473, 1)
        npcHandler:say("Ok, now I will wait for you. Be careful!", cid)
        npcHandler.topic[cid] = 0
        npcHandler:releaseFocus(cid)
    elseif msgcontains(msg, "yes") and npcHandler.topic[cid] == 3 then
        if player:removeItem(items[1][1], items[1][2]) then
            player:setStorageValue(56473, 1)
            npcHandler:say("Thanks! I'll tell my servant that I can take you to the island.", cid)
            npcHandler.topic[cid] = 0
        else
            npcHandler:say("Sorry, but you still have not found all my treasures.", cid)
            npcHandler.topic[cid] = 0
        end
    elseif msgcontains(msg, "no") and npcHandler.topic[cid] == 2 then
        npcHandler:say("Ok, I will wait a bit more.", cid)
        npcHandler.topic[cid] = 0
    elseif msgcontains(msg, "bye") then
        npcHandler:say("Bye.", cid)
        npcHandler:releaseFocus(cid)
    else
        npcHandler:say("What?", cid)
        npcHandler.topic[cid] = 0
    end
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

 

 

E agradeço a explicação depois irei dar uma estudada a mais nisso

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

Postado

De nada, haha ^^
Se sua dúvida estiver sanada, marque a melhor resposta para você no botão esquerdo aos posts aqui.

Programador PHP, Lua, Java, database administrator.

 

"Nada é verdade, tudo é permitido."

Requiescat in pace.

Postado
  • Autor

@Nazo Então eu tentei ali, e arrumei a linha 6 que estava dando erro e apareceu esse outro

 


[Warning - NpcScript::NpcScript] Can not load script: Archery.lua
data/npc/scripts/Archery.lua:19: 'then' expected near 'npcHandler'
 

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