Postado Fevereiro 6, 2015 10 anos Boa noite. Bom eu tenho um servidor de poketibia e gostaria de fazer uma task inicial. Tipo, o player entra, fala com o npc, pega a task, mata os bichos e entrega a task. depois disso ele recebe a recompensa. Simples assim. Eu ja tenho o script e ele funciona de boa. Mas o problema é que essa task pode ser feita varias vezes. Tipo, fez a primeira vez e entregou, poderá fazer a segunda vez e entregar, fazer a terceira vez e entregar e por aí vai. Eu gostaria que alguém pudesse me dar uma luz de forma que a pessoa só pudesse fazer a task uma única vez, ou seja, entrou no server ... pediu a task pro npc ... matou os bixos ... entrega a task ... recebe a recompensa e nunca mais faz essa task dnv com esse char. Obrigado desde já e desculpem-me se postei na seção errada. Segue o script em questão: 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 local task = { ["Zulu"] = {{"Gloom", 15}, {"Tangela", 5 }}, } if msgcontains(msg, 'task') or msgcontains(msg, 'Task') then if isMyTaskComplete(cid, getNpcCid()) then selfSay("Wow you have already complete my task! Ok then, take your reward!", cid) doPlayerAddExperience(cid, 80000) --premio doPlayerAddItem(cid, 11441, 2) doPlayerAddItem(cid, 11447, 2) doPlayerAddItem(cid, 11442, 2) doPlayerAddItem(cid, 11639, 1) local sto = getMyTaskSto(cid, getNpcCid()) setPlayerStorageValue(cid, sto, -1) setPlayerStorageValue(cid, 181603, 1) --storage da outfit talkState[talkUser] = 0 return true else selfSay("Then, is a simple task, i want to you kill {15 Gloom, 5 Tangela,}, you accept the task?", cid) talkState[talkUser] = 2 end elseif (msgcontains(msg, 'yes') or msgcontains(msg, 'Yes')) and talkState[talkUser] == 2 then if getMyTaskSto(cid, getNpcCid()) ~= -1 then selfSay("You are already doing my task! go end it!", cid) talkState[talkUser] = 0 return true end local sto = getFreeTaskStorage(cid) if sto == -1 then selfSay("You can't catch more tasks! You are already with the maximum of "..(maxTasks).." tasks!", cid) talkState[talkUser] = 0 return true end selfSay("OK then... Go kill your targets!", cid) setStorageArray(cid, sto, task) talkState[talkUser] = 0 return true end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
Postado Fevereiro 6, 2015 10 anos Tente assim... 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 local task = { ["Zulu"] = {{"Gloom", 15}, {"Tangela", 5 }}, } if msgcontains(msg, 'task') or msgcontains(msg, 'Task') then if isMyTaskComplete(cid, getNpcCid()) then selfSay("Wow you have already complete my task! Ok then, take your reward!", cid) doPlayerAddExperience(cid, 80000) --premio doPlayerAddItem(cid, 11441, 2) doPlayerAddItem(cid, 11447, 2) doPlayerAddItem(cid, 11442, 2) doPlayerAddItem(cid, 11639, 1) local sto = getMyTaskSto(cid, getNpcCid()) setPlayerStorageValue(cid, sto, -1) setPlayerStorageValue(cid, 181603, 1) --storage da outfit setPlayerStorageValue(cid, 182603, 2) talkState[talkUser] = 0 return true else selfSay("Then, is a simple task, i want to you kill {15 Gloom, 5 Tangela,}, you accept the task?", cid) talkState[talkUser] = 2 end elseif (msgcontains(msg, 'yes') or msgcontains(msg, 'Yes')) and talkState[talkUser] == 2 then if getMyTaskSto(cid, getNpcCid()) ~= -1 then selfSay("You are already doing my task! go end it!", cid) talkState[talkUser] = 0 return true end if getPlayerStorageValue(cid, 182603) >= 2 then selfSay("You have finished all task", cid) end local sto = getFreeTaskStorage(cid) if sto == -1 then selfSay("You can't catch more tasks! You are already with the maximum of "..(maxTasks).." tasks!", cid) talkState[talkUser] = 0 return true end selfSay("OK then... Go kill your targets!", cid) setStorageArray(cid, sto, task) talkState[talkUser] = 0 return true end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Te ajudei? Se você achar que eu mereço, me dê uma "rep+" e selecione meu post como "melhor resposta" Skype: JoadsonAion
Postado Fevereiro 6, 2015 10 anos Autor Não deu certo, cara... Agora ele diz: 01:38 Zulu: You have finished all task e logo em seguida diz: 01:38 Zulu: OK then... Go kill your targets! E task abre novamente pra ser feita e eu fiz pra testar. Realmente deu pra fazer. Não funcionou =(
Postado Fevereiro 6, 2015 10 anos Solução Okay, já sei onde modifcar... Breve edito aqui EDIT: Tente assim agora 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 local task = { ["Zulu"] = {{"Gloom", 15}, {"Tangela", 5 }}, } if msgcontains(msg, 'task') or msgcontains(msg, 'Task') then if isMyTaskComplete(cid, getNpcCid()) then selfSay("Wow you have already complete my task! Ok then, take your reward!", cid) doPlayerAddExperience(cid, 80000) --premio doPlayerAddItem(cid, 11441, 2) doPlayerAddItem(cid, 11447, 2) doPlayerAddItem(cid, 11442, 2) doPlayerAddItem(cid, 11639, 1) local sto = getMyTaskSto(cid, getNpcCid()) setPlayerStorageValue(cid, sto, 3) setPlayerStorageValue(cid, 181603, 1) --storage da outfit talkState[talkUser] = 0 return true else selfSay("Then, is a simple task, i want to you kill {15 Gloom, 5 Tangela,}, you accept the task?", cid) talkState[talkUser] = 2 end elseif (msgcontains(msg, 'yes') or msgcontains(msg, 'Yes')) and talkState[talkUser] == 2 then if getMyTaskSto(cid, getNpcCid()) ~= -1 then selfSay("You are already doing my task! go end it!", cid) talkState[talkUser] = 0 return true end local sto = getFreeTaskStorage(cid) if sto == -1 then selfSay("You can't catch more tasks! You are already with the maximum of "..(maxTasks).." tasks!", cid) talkState[talkUser] = 0 return true end selfSay("OK then... Go kill your targets!", cid) setStorageArray(cid, sto, task) talkState[talkUser] = 0 return true end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Editado Fevereiro 6, 2015 10 anos por joadson (veja o histórico de edições) Te ajudei? Se você achar que eu mereço, me dê uma "rep+" e selecione meu post como "melhor resposta" Skype: JoadsonAion
Postado Fevereiro 6, 2015 10 anos Autor Excelente mano. Funcionou. brigadão. Como eu faço pra dar rep+ ?
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.