JO
tfs 0.3.4

[PEDIDO] modificaçao desse script

Por Josegvb, 13 de mai. de 2016 em Scripts

35
3.2k
Luga03L
15 de maio de 2016 às 12:13

 

Coloca isso no configuration.lua lá no final

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."};}

Tu só vai usar essa tabela para configurar os 2 scripts!

 

Agora substitui o onKill por esse:

 

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 .. " para terminar a task.")                        return true                    end                end            end        end    return trueend

E substitui o Npc por esse:

 

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 ipairs(tasksss) do -- lê todas as tabelas        local name = configs.word        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())

Qual quer coisa já sabe né kk

Editado Maio 15 por Drazyn1291

JosegvbJ
15 de maio de 2016 às 12:20

@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>

Luga03L
15 de maio de 2016 às 12:23
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())

 

JosegvbJ
15 de maio de 2016 às 12:28

@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>

 

Luga03L
15 de maio de 2016 às 12:30

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

JosegvbJ
15 de maio de 2016 às 12:31
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 Maio 15 por Josegvb

JosegvbJ
15 de maio de 2016 às 12:42

@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 Maio 15 por Josegvb

Luga03L
15 de maio de 2016 às 13:25

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

JosegvbJ
15 de maio de 2016 às 13:27
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

Luga03L
15 de maio de 2016 às 16:26

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!

JosegvbJ
15 de maio de 2016 às 19:40

@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 Maio 15 por Josegvb

Luga03L
15 de maio de 2016 às 19:42

Você está usando qual tabela?

 

Remove todos os prints que estiver nos scripts

Editado Maio 15 por Drazyn1291

JosegvbJ
15 de maio de 2016 às 19:44
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())

 

Luga03L
15 de maio de 2016 às 19:46

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

JosegvbJ
15 de maio de 2016 às 19:50
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