Ir para conteúdo
  • 0

[PEDIDO] modificaçao desse script


Josegvb

Pergunta

olá o script esta funfando perfeitamente porem tem algumas coisas q estao faltando e o autor esta muito ocupado pra me ajudar :/ entao alguem me ajuda ai pfv 

modifacaçao que eu quero:

1º queria mudar o script pra ele perguntar pra a pessoa se quizer aceitar a task pq no momento você só falta o nome do bixo pra matar e ele fala qt estao faltando mas nao faz entregue da task, alias vc nao pega... só conta mesmo se vc nao tivese pegado

2º queria que ele tivese um COUNTER alias q quando matase o bixo, aparesça "0000 Mounstros restantes pra finalizar sua task." pq no momento vc n sabe qt falta pra finalizar ;/:

3º ele ta entregando a exp, mas nao esta aparescendo aquele txt animado da exp q vc ta pegando, alias simplemente adiciona a exp no seu char de um jeito invisivel

 

o script:

funçao onkill

Spoiler

function onKill(cid, target)

local configs = {
{name = "War Gyarados", storage = 10294},
{name = "War Heracross", storage = 10295}
}

for _, t in ipairs(configs) do

if getCreatureName(target) == t.name then
if getPlayerStorageValue(cid, t.storage) < 0 then
setPlayerStorageValue(cid, t.storage, 1)
else
setPlayerStorageValue(cid, t.storage, getPlayerStorageValue(cid, t.storage) + 1)
return true
end
end

end

return true
end

 

script do npc:

Spoiler

local configs = {
{word = "War Gyarados", itemid = 0, itemcount = 0, money = 0, rewardid = 15589, rewardcount = 20, rewardexp = 10000000, storageid = 5455, storagevalue = os.time() + 1*24*60*60, storagerequest = 10294, valuerequest = 1000, text = "Congratulations! You finished this task. In 24h, you will be able to do it again."};
{word = "War Heracross", itemid = 0, itemcount = 0, money = 0, rewardid = 15589, rewardcount = 20, rewardexp = 10000000, storageid = 5455, storagevalue = os.time() + 1*24*60*60, storagerequest = 10295, valuerequest = 1000, text = "Congratulations! You finished this task. In 24h, you will be able to do it again."};
{word = "xxx", itemid = xxx, itemcount = xxx, money = xxx, rewardid = xxx, rewardcount = xxx, rewardexp = xxx, storageid = xxx, storagevalue = xxx, storagerequest = xxx, valuerequest = xxx, text = "xxx"};
}
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
for _, npc in ipairs(configs) do
    if(msgcontains(msg, ''..npc.word..'')) then
              if getPlayerStorageValue(cid, npc.storageid) < os.time() then
              if getPlayerStorageValue(cid, npc.storagerequest) >= npc.valuerequest then
              doPlayerAddItem(cid, npc.rewardid, npc.rewardcount)
              setPlayerStorageValue(cid, npc.storagerequest, getPlayerStorageValue(cid, npc.storagerequest) - npc.valuerequest)     
              setPlayerStorageValue(cid, npc.storageid, npc.storagevalue)
              doPlayerAddExperience(cid, npc.rewardexp)
              selfSay(''..npc.text..'', cid)   
    talkState[talkUser] = 0  
              else
              selfSay('You need to kill '..(npc.valuerequest - getPlayerStorageValue(cid, npc.storagerequest))..' '..npc.word..' to gain a reward.')
    talkState[talkUser] = 0  
              end
              else
              selfSay('You already did this task, player. Wait '..math.ceil((getPlayerStorageValue(cid, npc.storageid) - os.time())/(60*60))..' hours to do it again.', cid)
    talkState[talkUser] = 0  
              end
              end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 tomara q alguem me ajude ;..; valeu

Link para o comentário
Compartilhar em outros sites

Posts Recomendados

  • 0

@Drazyn1291

[15/05/2016 11:23:25] [Error - Npc interface] 
[15/05/2016 11:23:25] data/npc/scripts/lixeiro.lua:onCreatureSay
[15/05/2016 11:23:25] Description: 
[15/05/2016 11:23:25] data/npc/scripts/lixeiro.lua:14: bad argument #1 to 'ipairs' (table expected, got nil)
[15/05/2016 11:23:25] stack traceback:
[15/05/2016 11:23:25]     [C]: in function 'ipairs'
[15/05/2016 11:23:25]     data/npc/scripts/lixeiro.lua:14: in function 'callback'
[15/05/2016 11:23:25]     data/npc/lib/npcsystem/npchandler.lua:391: in function 'onCreatureSay'
[15/05/2016 11:23:25]     data/npc/scripts/lixeiro.lua:7: in function <data/npc/scripts/lixeiro.lua:7>

Link para o comentário
Compartilhar em outros sites

  • 0
local keywordHandler = KeywordHandler:new()local npcHandler = NpcHandler:new(keywordHandler)NpcSystem.parseParameters(npcHandler)local talkState = {}function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) endfunction onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) endfunction onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) endfunction onThink() npcHandler:onThink() endfunction creatureSayCallback(cid, type, msg)    if(not npcHandler:isFocused(cid)) then        return false    end    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid    for _, configss in pairs(tasksss) do -- lê todas as tabelas        local name = configss.name        local m_sto = configss.sto        local time_sto = configss.time_sto        local count_sto = configss.sto_count        local total_count = configss.count        local rest = total_count - getPlayerStorageValue(cid, count_sto)        if msgcontains(msg, name) then -- Verifica se o player falou o nome da criatura            if getPlayerStorageValue(cid, time_sto) < os.time() then -- verifica se o player ainda está no prazo                if getPlayerStorageValue(cid, m_sto) <= 0 then -- verifica se o player não pegou está task                    selfSay('Are you sure you want to do the task '.. total_count ..' '.. name ..'?', cid)                    if isInArray({'yes', 'sim', 'claro', 'yeah'}, msg) then                        selfSay('Ready! Now you need kill a '.. total_count .. ' '.. name .. '!', cid)                        setPlayerStorageValue(cid, m_sto, 1)                        talkState[talkUser] = 0                      end                                  else                    if rest <= 0 then -- Verifica se o player matou todos os monstros nescessários                        doPlayerAddItem(cid, configss.rewardid, configss.rewardcount)                        setPlayerStorageValue(cid, count_sto, 0)                         setPlayerStorageValue(cid, m_sto, 0)                         setPlayerStorageValue(cid, time_sto, os.time() + configss.time)                        doPlayerAddExperience(cid, configss.rewardexp)                        doSendAnimatedText(getCreaturePosition(cid), configss.rewardexp, 215)                        selfSay(configss.text, cid)                         talkState[talkUser] = 0                    else                        selfSay('You need to kill '..rest..' '..name..' to gain a reward.')                        talkState[talkUser] = 0                    end                end            else                selfSay('You already did this task, player. Wait '..math.ceil((getPlayerStorageValue(cid, time_sto) - os.time())/(60*60))..' hours to do it again.', cid)                talkState[talkUser] = 0            end        end        return true    endendnpcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)npcHandler:addModule(FocusModule:new())

 

Link para o comentário
Compartilhar em outros sites

  • 0

@Drazyn1291

 

[15/05/2016 11:30:45] [Error - Npc interface] 
[15/05/2016 11:30:45] data/npc/scripts/lixeiro.lua:onCreatureSay
[15/05/2016 11:30:45] Description: 
[15/05/2016 11:30:45] data/npc/scripts/lixeiro.lua:14: bad argument #1 to 'pairs' (table expected, got nil)
[15/05/2016 11:30:45] stack traceback:
[15/05/2016 11:30:45]     [C]: in function 'pairs'
[15/05/2016 11:30:45]     data/npc/scripts/lixeiro.lua:14: in function 'callback'
[15/05/2016 11:30:45]     data/npc/lib/npcsystem/npchandler.lua:391: in function 'onCreatureSay'
[15/05/2016 11:30:45]     data/npc/scripts/lixeiro.lua:7: in function <data/npc/scripts/lixeiro.lua:7>

 

Link para o comentário
Compartilhar em outros sites

  • 0
35 minutos atrás, Drazyn1291 disse:

Coloca a tabela que te passei no mesmo lugar do arquivo do onKill e do Npc

	tasksss = {   {name = "Brave Venusaur",  sto = 10289, count = 1000, time_sto = 5458, time = 1*24*60*60, sto_count = 14130, money = 0, rewardid = 15589, rewardcount = 20, rewardexp = 10000000,  text = "Congratulations! You finished this task. In 24h, you will be able to do it again."};   {name = "Furious Ampharos",  sto = 10290, count = 1000, time_sto = 5458, time = 1*24*60*60, sto_count = 14129, money = 0, rewardid = 15589, rewardcount = 20, rewardexp = 10000000,  text = "Congratulations! You finished this task. In 24h, you will be able to do it again."};   {name = "Thief",  sto = 10299, count = 12, time_sto = 5457, time = 1*24*60*60, sto_count = 14129, money = 0, rewardid = 15590, rewardcount = 100, rewardexp = 10000000,  text = "Congratulations! You finished this task. In 24h, you will be able to do it again."};}function onKill(cid, target)        for _, t in ipairs(tasksss) do            local total_count = t.count            local m_sto = t.storage            local count_sto = t.sto_count            local rest = total_count - getPlayerStorageValue(cid, count_sto)            if getPlayerStorageValue(cid, m_sto) >= 1 then                if getCreatureName(target) == t.name then                    if rest > 0 then                        setPlayerStorageValue(cid, count_sto, getPlayerStorageValue(cid, count_sto) + 1)                        doPlayerSendTextMessage(cid, 20, "Missing ".. rest .." " .. t.name .. " to finish the task.")                        return true                    end                end            end        end    return trueend

tendi vo testar aki

Editado por Josegvb
Link para o comentário
Compartilhar em outros sites

  • 0

@Drazyn1291 teste mas agora só pega o Brave Venusaur e quando você fala sim, ele nao responde nada

 

e73e9ed9901ab09efbbe0c680ac3e487.png

 

quando vocè mata tudos os bixos, o npc n ta entregando nada nem exp nem item

resumindo o npc só fala hi, Brave Venusaur

n faz + nada

onkill:

Spoiler

    tasksss = {
   {name = "Brave Venusaur",  sto = 10289, count = 1000, time_sto = 5458, time = 1*24*60*60, sto_count = 14130, money = 0, rewardid = 15589, rewardcount = 20, rewardexp = 10000000,  text = "Congratulations! You finished this task. In 24h, you will be able to do it again."};
   {name = "Furious Ampharos",  sto = 10290, count = 1000, time_sto = 5458, time = 1*24*60*60, sto_count = 14129, money = 0, rewardid = 15589, rewardcount = 20, rewardexp = 10000000,  text = "Congratulations! You finished this task. In 24h, you will be able to do it again."};
   {name = "Thief",  sto = 10299, count = 12, time_sto = 5457, time = 1*24*60*60, sto_count = 14129, money = 0, rewardid = 15590, rewardcount = 100, rewardexp = 10000000,  text = "Congratulations! You finished this task. In 24h, you will be able to do it again."};
}

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
    for _, configss in pairs(tasksss) do -- lê todas as tabelas
        local name = configss.name
        local m_sto = configss.sto
        local time_sto = configss.time_sto
        local count_sto = configss.sto_count
        local total_count = configss.count
        local rest = total_count - getPlayerStorageValue(cid, count_sto)
        if msgcontains(msg, name) then -- Verifica se o player falou o nome da criatura
            if getPlayerStorageValue(cid, time_sto) < os.time() then -- verifica se o player ainda está no prazo
                if getPlayerStorageValue(cid, m_sto) <= 0 then -- verifica se o player não pegou está task
                    selfSay('Are you sure you want to do the task '.. total_count ..' '.. name ..'?', cid)
                    if isInArray({'yes', 'sim', 'claro', 'yeah'}, msg) then
                        selfSay('Ready! Now you need kill a '.. total_count .. ' '.. name .. '!', cid)
                        setPlayerStorageValue(cid, m_sto, 1)
                        talkState[talkUser] = 0  
                    end                  
                else
                    if rest <= 0 then -- Verifica se o player matou todos os monstros nescessários
                        doPlayerAddItem(cid, configss.rewardid, configss.rewardcount)
                        setPlayerStorageValue(cid, count_sto, 0) 
                        setPlayerStorageValue(cid, m_sto, 0) 
                        setPlayerStorageValue(cid, time_sto, os.time() + configss.time)
                        doPlayerAddExperience(cid, configss.rewardexp)
                        doSendAnimatedText(getCreaturePosition(cid), configss.rewardexp, 215)
                        selfSay(configss.text, cid) 
                        talkState[talkUser] = 0
                    else
                        selfSay('You need to kill '..rest..' '..name..' to gain a reward.')
                        talkState[talkUser] = 0
                    end
                end
            else
                selfSay('You already did this task, player. Wait '..math.ceil((getPlayerStorageValue(cid, time_sto) - os.time())/(60*60))..' hours to do it again.', cid)
                talkState[talkUser] = 0
            end
        end
        return true
    end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

npc:

Spoiler

    tasksss = {
   {name = "Brave Venusaur",  sto = 10289, count = 1000, time_sto = 5458, time = 1*24*60*60, sto_count = 14130, money = 0, rewardid = 15589, rewardcount = 20, rewardexp = 10000000,  text = "Congratulations! You finished this task. In 24h, you will be able to do it again."};
   {name = "Furious Ampharos",  sto = 10290, count = 1000, time_sto = 5458, time = 1*24*60*60, sto_count = 14129, money = 0, rewardid = 15589, rewardcount = 20, rewardexp = 10000000,  text = "Congratulations! You finished this task. In 24h, you will be able to do it again."};
   {name = "Thief",  sto = 10299, count = 12, time_sto = 5457, time = 1*24*60*60, sto_count = 14129, money = 0, rewardid = 15590, rewardcount = 100, rewardexp = 10000000,  text = "Congratulations! You finished this task. In 24h, you will be able to do it again."};
}

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
    for _, configss in pairs(tasksss) do -- lê todas as tabelas
        local name = configss.name
        local m_sto = configss.sto
        local time_sto = configss.time_sto
        local count_sto = configss.sto_count
        local total_count = configss.count
        local rest = total_count - getPlayerStorageValue(cid, count_sto)
        if msgcontains(msg, name) then -- Verifica se o player falou o nome da criatura
            if getPlayerStorageValue(cid, time_sto) < os.time() then -- verifica se o player ainda está no prazo
                if getPlayerStorageValue(cid, m_sto) <= 0 then -- verifica se o player não pegou está task
                    selfSay('Are you sure you want to do the task '.. total_count ..' '.. name ..'?', cid)
                    if isInArray({'yes', 'sim', 'claro', 'yeah'}, msg) then
                        selfSay('Ready! Now you need kill a '.. total_count .. ' '.. name .. '!', cid)
                        setPlayerStorageValue(cid, m_sto, 1)
                        talkState[talkUser] = 0  
                    end                  
                else
                    if rest <= 0 then -- Verifica se o player matou todos os monstros nescessários
                        doPlayerAddItem(cid, configss.rewardid, configss.rewardcount)
                        setPlayerStorageValue(cid, count_sto, 0) 
                        setPlayerStorageValue(cid, m_sto, 0) 
                        setPlayerStorageValue(cid, time_sto, os.time() + configss.time)
                        doPlayerAddExperience(cid, configss.rewardexp)
                        doSendAnimatedText(getCreaturePosition(cid), configss.rewardexp, 215)
                        selfSay(configss.text, cid) 
                        talkState[talkUser] = 0
                    else
                        selfSay('You need to kill '..rest..' '..name..' to gain a reward.')
                        talkState[talkUser] = 0
                    end
                end
            else
                selfSay('You already did this task, player. Wait '..math.ceil((getPlayerStorageValue(cid, time_sto) - os.time())/(60*60))..' hours to do it again.', cid)
                talkState[talkUser] = 0
            end
        end
        return true
    end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

Editado por Josegvb
Link para o comentário
Compartilhar em outros sites

  • 0
34 minutos atrás, Drazyn1291 disse:

Vou ver isso do NPC, mas está contando os kills quando mata os bixos?

 

sim, e quando fica no 1 para de contar :P: acho q deberia falar task complete quando ficar em 0, mas estaria pedindo mt aueaueae nessa parte ta bom, ai fui falar com o npc denovo e nao resetou o counter

Link para o comentário
Compartilhar em outros sites

  • 0

Eu editei tudo, testei e tudo mais e está 100%!! Só não consegui fazer a parte de confirmar se o player realmente que aquela task!

 

Npc:

 

local tasksss = {   {name = "Blastoise", sto = 10212, count = 3, time_sto = 5457, time = 1*24*60*60, sto_count = 14129, money = 100, rewardid = 7721, rewardcount = 100, rewardexp = 10000000,  text = "Congratulations! You finished this task. In 24h, you will be able to do it again."},}local keywordHandler = KeywordHandler:new()local npcHandler = NpcHandler:new(keywordHandler)NpcSystem.parseParameters(npcHandler)local talkState = {}function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) endfunction onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) endfunction onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) endfunction onThink() npcHandler:onThink() endfunction creatureSayCallback(cid, type, msg)    if(not npcHandler:isFocused(cid)) then        return false    end    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid    for _, configss in pairs(tasksss) do -- lê todas as tabelas        local name = configss.name        local m_sto = configss.sto        local time_sto = configss.time_sto        local count_sto = configss.sto_count        local total_count = configss.count        local rest = total_count - getPlayerStorageValue(cid, count_sto)        if msgcontains(msg, name) then -- Verifica se o player falou o nome da criatura            if getPlayerStorageValue(cid, time_sto) < os.time() then -- verifica se o player ainda está no prazo                if getPlayerStorageValue(cid, m_sto) <= 0 then -- verifica se o player não pegou está task                    --selfSay('Are you sure you want to do the task '.. total_count ..' '.. name ..'?', cid)                    --if msgcontains(msg, 'yes') then                        print(total_count)                        selfSay('Ready! Now you need kill a '.. total_count .. ' '.. name .. '!', cid)                        setPlayerStorageValue(cid, m_sto, 1)                        setPlayerStorageValue(cid, total_count, 0)                        talkState[talkUser] = 0                      --end                              else                    if rest <= 0 then -- Verifica se o player matou todos os monstros nescessários                        doPlayerAddItem(cid, configss.rewardid, configss.rewardcount)                        setPlayerStorageValue(cid, count_sto, 0)                         setPlayerStorageValue(cid, m_sto, -1)                         setPlayerStorageValue(cid, time_sto, os.time() + configss.time)                        doPlayerAddExperience(cid, configss.rewardexp)                        doSendAnimatedText(getCreaturePosition(cid), configss.rewardexp, 215)                        selfSay(configss.text, cid)                         talkState[talkUser] = 0                    else                        selfSay('You need to kill '..rest..' '..name..' to gain a reward.', cid)                        talkState[talkUser] = 0                    end                end            else                selfSay('You already did this task, player. Wait '..math.ceil((getPlayerStorageValue(cid, time_sto) - os.time())/(60*60))..' hours to do it again.', cid)                talkState[talkUser] = 0            end        end        return true    endendnpcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)npcHandler:addModule(FocusModule:new())

e substitua o kill por esse:

 

local tasksss = {   {name = "Blastoise",  sto = 10212, count = 3, time_sto = 5457, time = 1*24*60*60, sto_count = 14129, money = 100, rewardid = 7721, rewardcount = 100, rewardexp = 10000000,  text = "Congratulations! You finished this task. In 24h, you will be able to do it again."},}function onKill(cid, target)        for _, t in ipairs(tasksss) do            local total_count = t.count            local m_sto = t.sto            local count_sto = t.sto_count            print(m_sto)            if getPlayerStorageValue(cid, m_sto) ~= -1 then                if getCreatureName(target) == t.name then                	if (total_count - getPlayerStorageValue(cid, count_sto)) == 0 then                    	doPlayerSendTextMessage(cid, 20, "You killed ".. getPlayerStorageValue(cid, count_sto) .." " .. t.name .. " and finished the task!")                    	return true                    elseif (total_count - getPlayerStorageValue(cid, count_sto)) > 0 then                        setPlayerStorageValue(cid, count_sto, getPlayerStorageValue(cid, count_sto) + 1)                        doPlayerSendTextMessage(cid, 20, "Missing ".. (total_count - getPlayerStorageValue(cid, count_sto)) .." " .. t.name .. " kills to finish the task.")                        return true                    end                end            end        end        print(getPlayerStorageValue(cid, count_sto))    return trueend

Está entregando task e tudo mais!

Link para o comentário
Compartilhar em outros sites

  • 0

@Drazyn1291 malz nao tinham me notificado q vc respondeu, testei aki e só ta pegando a primeira task, só os Brave Venusaur o resto n responde nada n

e é normal esse spam no log?

118ed928cb56fffa04f274c92f381618.png

as outras tasks ele n ta pegando

Editado por Josegvb
Link para o comentário
Compartilhar em outros sites

  • 0

Você está usando qual tabela?

 

Remove todos os prints que estiver nos scripts

Editado por Drazyn1291
Link para o comentário
Compartilhar em outros sites

  • 0
34 minutos atrás, Drazyn1291 disse:

Você está usando qual tabela?

 

Remove todos os prints que estiver nos scripts

 

local tasksss = { {name = "Brave Venusaur",  sto = 10289, count = 1000, time_sto = 5458, time = 1*24*60*60, sto_count = 14130, money = 0, rewardid = 15589, rewardcount = 20, rewardexp = 10000000,  text = "Congratulations! You finished this task. In 24h, you will be able to do it again."};   {name = "Furious Ampharos",  sto = 10290, count = 1000, time_sto = 5458, time = 1*24*60*60, sto_count = 14129, money = 0, rewardid = 15589, rewardcount = 20, rewardexp = 10000000,  text = "Congratulations! You finished this task. In 24h, you will be able to do it again."};   {name = "Thief",  sto = 10299, count = 12, time_sto = 5457, time = 1*24*60*60, sto_count = 14129, money = 0, rewardid = 15590, rewardcount = 100, rewardexp = 10000000,  text = "Congratulations! You finished this task. In 24h, you will be able to do it again."};function onKill(cid, target)        for _, t in ipairs(tasksss) do            local total_count = t.count            local m_sto = t.sto            local count_sto = t.sto_count            print(m_sto)            if getPlayerStorageValue(cid, m_sto) ~= -1 then                if getCreatureName(target) == t.name then                	if (total_count - getPlayerStorageValue(cid, count_sto)) == 0 then                    	doPlayerSendTextMessage(cid, 20, "You killed ".. getPlayerStorageValue(cid, count_sto) .." " .. t.name .. " and finished the task!")                    	return true                    elseif (total_count - getPlayerStorageValue(cid, count_sto)) > 0 then                        setPlayerStorageValue(cid, count_sto, getPlayerStorageValue(cid, count_sto) + 1)                        doPlayerSendTextMessage(cid, 20, "Missing ".. (total_count - getPlayerStorageValue(cid, count_sto)) .." " .. t.name .. " kills to finish the task.")                        return true                    end                end            end        end        print(getPlayerStorageValue(cid, count_sto))    return trueend}

 

Spoiler

local tasksss = {

   {name = "Brave Venusaur",  sto = 10289, count = 1000, time_sto = 5458, time = 1*24*60*60, sto_count = 14130, money = 0, rewardid = 15589, rewardcount = 20, rewardexp = 10000000,  text = "Congratulations! You finished this task. In 24h, you will be able to do it again."},

   {name = "Furious Ampharos",  sto = 10290, count = 1000, time_sto = 5458, time = 1*24*60*60, sto_count = 14129, money = 0, rewardid = 15589, rewardcount = 20, rewardexp = 10000000,  text = "Congratulations! You finished this task. In 24h, you will be able to do it again."},

   {name = "Thief",  sto = 10299, count = 12, time_sto = 5457, time = 1*24*60*60, sto_count = 14129, money = 0, rewardid = 15590, rewardcount = 100, rewardexp = 10000000,  text = "Congratulations! You finished this task. In 24h, you will be able to do it again."},

}

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

    for _, configss in pairs(tasksss) do -- lê todas as tabelas

        local name = configss.name

        local m_sto = configss.sto

        local time_sto = configss.time_sto

        local count_sto = configss.sto_count

        local total_count = configss.count

        local rest = total_count - getPlayerStorageValue(cid, count_sto)

        if msgcontains(msg, name) then -- Verifica se o player falou o nome da criatura

            if getPlayerStorageValue(cid, time_sto) < os.time() then -- verifica se o player ainda está no prazo

                if getPlayerStorageValue(cid, m_sto) <= 0 then -- verifica se o player não pegou está task

                    --selfSay('Are you sure you want to do the task '.. total_count ..' '.. name ..'?', cid)

                    --if msgcontains(msg, 'yes') then

                        print(total_count)

                        selfSay('Ready! Now you need kill a '.. total_count .. ' '.. name .. '!', cid)

                        setPlayerStorageValue(cid, m_sto, 1)

                        setPlayerStorageValue(cid, total_count, 0)

                        talkState[talkUser] = 0  

                    --end              

                else

                    if rest <= 0 then -- Verifica se o player matou todos os monstros nescessários

                        doPlayerAddItem(cid, configss.rewardid, configss.rewardcount)

                        setPlayerStorageValue(cid, count_sto, 0) 

                        setPlayerStorageValue(cid, m_sto, -1) 

                        setPlayerStorageValue(cid, time_sto, os.time() + configss.time)

                        doPlayerAddExperience(cid, configss.rewardexp)

                        doSendAnimatedText(getCreaturePosition(cid), configss.rewardexp, 215)

                        selfSay(configss.text, cid) 

                        talkState[talkUser] = 0

                    else

                        selfSay('You need to kill '..rest..' '..name..' to gain a reward.', cid)

                        talkState[talkUser] = 0

                    end

                end

            else

                selfSay('You already did this task, player. Wait '..math.ceil((getPlayerStorageValue(cid, time_sto) - os.time())/(60*60))..' hours to do it again.', cid)

                talkState[talkUser] = 0

            end

        end

        return true

    end

end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

 

Link para o comentário
Compartilhar em outros sites

  • 0
34 minutos atrás, Drazyn1291 disse:

Na tabela, você separar por ',' (virgula) e não por ';' (ponto e virgula), edita aí a tabela

 

coloquei o ; agora, pq no começo deixei com , e nao pego por isso mudei pro o ;

testei denovo com o , e nao deu

 

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...