Postado Junho 5, 2015 10 anos To precisando de 5 NPCs que devem ser simples Que vendam as 5 blesses Acho que é isso \/ doPlayerAddBlessing(cid, 1) doPlayerAddBlessing(cid, 2) doPlayerAddBlessing(cid, 3) doPlayerAddBlessing(cid, 4) doPlayerAddBlessing(cid, 5) Alguém pode fazer pra mim?
Postado Junho 5, 2015 10 anos Fiz o script com as configurações que você deve alterar, basta criar 5 NPC's alterando as configurações. Em "Data/npc/scripts", copie e cole um arquivo.LUA e renomeie para nome_desejado.lua, apague tudo e cole: local t = { palavras = {"bless", "first", "first bless"}, -- Palavras chaves para começar o dialogo. bless = 1, -- Numero da bless {1 a 5}. level = 50, -- Level necessário. price = 10000 -- Preço da bless. } 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 creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid msg = msg:lower(); if isInArray(t.palavras, msg) then if getPlayerBlessing(cid, t.bless) == false then if getPlayerLevel(cid) >= t.level then selfSay("Você deseja receber a benção The Spiritual Shielding por ".. t.price .." golds coins?", cid) talkState[talkUser] = 1 else selfSay("Você precisa ser level ".. t.level .. " para receber esta benção.", cid) end else selfSay("Você já tem essa benção.", cid) end elseif msgcontains(msg, "yes") then if talkState[talkUser] == 1 then if doPlayerRemoveMoney(cid, t.price) then selfSay("Você recebeu a benção The Spiritual Shielding.", cid) doPlayerAddBlessing(cid, t.bless) talkState[talkUser] = 0 else selfSay("Você não tem ".. t.price .." golds coins.", cid) talkState[talkUser] = 0 end end elseif msgcontains(msg, "no") then if talkState[talkUser] == 1 then selfSay("Ok...", cid) end end end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Em "Data/npc", copie e cole um arquivo.XML e renomeie para nome_desejado.xml, apague tudo e cole: <?xml version="1.0" encoding="UTF-8"?> <npc name="NOME_DO_NPC" script="data/npc/scripts/nome_desejado.lua" walkinterval="2000" floorchange="0"> <health now="100" max="100"/> <look type="131" head="22" body="22" legs="22" feet="57" addons="0"/> <parameters> <parameter key="message_greet" value="Bem-vindo, |PLAYERNAME|."/> <parameter key="message_farewell" value="Até mais |PLAYERNAME|!"/> </parameters> </npc> No XML não se esqueça de alterar o nome do script em script="data/npc/scripts/nome_desejado.lua". ➥ Regras | Seções OTServ | Seções BOT
Postado Junho 7, 2015 10 anos Autor Vou te dando uns reps ai, mas pq os meus scripts tão dando erro? Acho que é por causa do *, não é assim q é o sinal de multiplicar? local t = { palavras = {"bless", "blessed", "god"}, -- Palavras chaves para começar o dialogo. bless = 1, -- Numero da bless {1 a 5}. level = 1, -- Level necessário. price = getPlayerLevel(cid) * 250 -- Preço da bless. } 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 creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid msg = msg:lower(); if isInArray(t.palavras, msg) then if getPlayerBlessing(cid, t.bless) == false then if getPlayerLevel(cid) >= t.level then selfSay("Você deseja receber a benção The Spiritual Shielding por ".. t.price .." golds coins?", cid) talkState[talkUser] = 1 else selfSay("Você precisa ser level ".. t.level .. " para receber esta benção.", cid) end else selfSay("Você já tem essa benção.", cid) end elseif msgcontains(msg, "yes") then if talkState[talkUser] == 1 then if doPlayerRemoveMoney(cid, t.price) then selfSay("Você recebeu a benção The Spiritual Shielding.", cid) doPlayerAddBlessing(cid, t.bless) talkState[talkUser] = 0 else selfSay("Você não tem ".. t.price .." golds coins.", cid) talkState[talkUser] = 0 end end elseif msgcontains(msg, "no") then if talkState[talkUser] == 1 then selfSay("Ok...", cid) end end end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) local bless = {1, 2, 3, 4, 5} local cost = getPlayerLevel(cid) * 1500 function onSay(cid, words, param) if isPremium(cid) == FALSE then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Purchase at the NPC, only VIP players can use this command!") return TRUE end for i = 1, table.maxn(bless) do if(getPlayerBlessing(cid, bless[i])) then doPlayerSendCancel(cid, "You have all blesses.") return TRUE end end if(doPlayerRemoveMoney(cid, cost) == TRUE) then for i = 1, table.maxn(bless) do doPlayerAddBlessing(cid, bless[i]) end doCreatureSay(cid, "BLESS" ,19) doSendMagicEffect(getPlayerPosition(cid), 29) else doPlayerSendCancel(cid, "You dont have money.") end return TRUE end Editado Junho 7, 2015 10 anos por luccagomes (veja o histórico de edições)
Postado Junho 10, 2015 10 anos Autor atualizando com a img do erro que da no console talkaction dps do npc
Postado Junho 10, 2015 10 anos Solução Isso acontece pois você está tentando calcular o valor do level fora da callback, então cid não está definido. NPC: 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 creatureSayCallback(cid, type, msg) -- TAB -- local t = { palavras = {"bless", "first", "first bless"}, -- Palavras chaves para começar o dialogo. bless = 2, -- Numero da bless {1 a 5}. level = 50, -- Level necessário. price = getPlayerLevel(cid) * 250 -- Preço da bless. } -- TAB -- if(not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid msg = msg:lower(); if isInArray(t.palavras, msg) then if getPlayerBlessing(cid, t.bless) == false then if getPlayerLevel(cid) >= t.level then selfSay("Você deseja receber a benção The Spiritual Shielding por ".. t.price .." golds coins?", cid) talkState[talkUser] = 1 else selfSay("Você precisa ser level ".. t.level .. " para receber esta benção.", cid) end else selfSay("Você já tem essa benção.", cid) end elseif msgcontains(msg, "yes") then if talkState[talkUser] == 1 then if doPlayerRemoveMoney(cid, t.price) then selfSay("Você recebeu a benção The Spiritual Shielding.", cid) doPlayerAddBlessing(cid, t.bless) talkState[talkUser] = 0 else selfSay("Você não tem ".. t.price .." golds coins.", cid) talkState[talkUser] = 0 end end elseif msgcontains(msg, "no") then if talkState[talkUser] == 1 then selfSay("Ok...", cid) end end end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Talk: local bless = {1, 2, 3, 4, 5} function onSay(cid, words, param) local cost = getPlayerLevel(cid) * 1500 if isPremium(cid) == FALSE then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Purchase at the NPC, only VIP players can use this command!") return TRUE end for i = 1, table.maxn(bless) do if(getPlayerBlessing(cid, bless[i])) then doPlayerSendCancel(cid, "You have all blesses.") return TRUE end end if(doPlayerRemoveMoney(cid, cost) == TRUE) then for i = 1, table.maxn(bless) do doPlayerAddBlessing(cid, bless[i]) end doCreatureSay(cid, "BLESS" ,19) doSendMagicEffect(getPlayerPosition(cid), 29) else doPlayerSendCancel(cid, "You dont have money.") end return TRUE end ➥ Regras | Seções OTServ | Seções BOT
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.