Tópico Movido
Este tópico foi movido de "OTServ → Scripting → Downloads Scripts → NPCs, monsters e raids"
para "OTServ → Scripting → Suporte Scripting".
info
Grupo: Administrador
Registrado: 08/07/05
Posts: 5.8k
Reputação: +1.4k
Gênero: Outro

Tópico Movido
Este tópico foi movido de "OTServ → Scripting → Downloads Scripts → NPCs, monsters e raids"
para "OTServ → Scripting → Suporte Scripting".
info
Grupo: Campones
Registrado: 12/08/15
Posts: 84
Reputação: +7
é o seguinte, tenho um NPC de TASK, mas se tu tiver muitos itens ele da o premio varias vezes... quero apenas q ele de o premio 1x e depois não dê mais !
SCRIPT DELE
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 = string.lower(msg) --------- local need = { {id = 2092, qt = 1}, --diamond } local rewards = { {id = 14252, qt = 1}, --mega Stone {id = 12618, qt = 20}, --booststone } local stoFinish = 92119 --------- if msgcontains(msg, 'help') or msgcontains(msg, 'ajuda') then if getPlayerStorageValue(cid, stoFinish) >= 99 then selfSay("Sorry, you already had done this quest.", cid) talkState[talkUser] = 0 return true end selfSay("Olá meu amigo, sou o NPC de trocas, me dê 1 Bone Chave e lhe darei 1 Mega Stone ! Diga YES para trocarmos",cid) talkState[talkUser] = 1 return true elseif msgcontains(msg, 'yes') or msgcontains(msg, 'sim') and talkState[talkUser] == 1 then if getPlayerItemCount(cid, need[1].id) < need[1].qt then selfSay("Você não me trouxe a Bone Chave...", cid) selfSay("Lembre-se, eu preciso de 1 Bone Chave...", cid) talkState[talkUser] = 0 return true end local sto = getFreeTaskStorage(cid) if sto == -1 then selfSay("Você não pode fazer essa TASK NoVamente VocÊ ja fez o max de "..(maxTasks).." tasks!", cid) talkState[talkUser] = 0 return true end for i = 1, #need do doPlayerRemoveItem(cid, need[i].id, need[i].qt) end for i = 1, #rewards do doPlayerAddItem(cid, rewards[i].id, rewards[i].qt) doPlayerAddExperience(cid, 0) end selfSay("Obrigado, tchau!", cid) setPlayerStorageValue(cid, stoFinish, 1) talkState[talkUser] = 0 return true end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())