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 19:53

Vê esse tutorial que fiz: http://www.xtibia.com/forum/forum/374-globalevents-spells-e-creatureevents/?do=add

JosegvbJ
15 de maio de 2016 às 19:58
36 minutos atrás, Drazyn1291 disse:

 

link ta errado, você testou o script com + de 1 task? pq como eu disse, ele ta pegando a primeira sem problema mas as outras nao pega, testei refazer as tabelas e vi td la certinho, trokei o brave venusaur pro 2º e deixei o Furious Ampharos de 1º,  ai o npc começou a pegar o Furious Ampharos e ignorar o brave venusaur e thief da tabela

JosegvbJ
15 de maio de 2016 às 22:46

teria como me falar se voce testou as tasks com + de 1 bixo? ^^ pra eu testar o script denovo do 0, pois cmg ta funfando só com o 1º bixo, se coloca + na lista nem pega os dos outros apenas o primeiro, entao se com vc funfou pra + de 1 entao blz o erro esta em min

3 horas atrás, Drazyn1291 disse:

 

Editado Maio 15 por Josegvb

Luga03L
16 de maio de 2016 às 07:26
8 horas atrás, Josegvb disse:

teria como me falar se voce testou as tasks com + de 1 bixo? ^^ pra eu testar o script denovo do 0, pois cmg ta funfando só com o 1º bixo, se coloca + na lista nem pega os dos outros apenas o primeiro, entao se com vc funfou pra + de 1 entao blz o erro esta em min

 

pronto! Dei uma ajeitada no script e concertei o que estava faltando!

 

Npc:

 

local tasksss = {   [1] = {name = "Blastoise",  sto = 10212, count = 3, time_sto = 5457, time = 1*24*60*60, sto_count = 14129, money = 100, rewardid = 7621, rewardcount = 100, rewardexp = 10000,  text = "Congratulations! You finished this task. In 24h, you will be able to do it again."},   [2] = {name = "Charizard",  sto = 10213, count = 5, time_sto = 5458, time = 1*24*60*60, sto_count = 14130, money = 100, rewardid = 7621, rewardcount = 100, rewardexp = 10000,  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    value = -1    for i = 1, #tasksss do        if msgcontains(msg, tasksss[i].name) and not value ~= -1 then            value = i        end    end    if value == -1 then        selfSay('I don\'t have a this task!', cid)        talkState[talkUser] = 0        return true    end    local configss = tasksss[value]    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 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('Ready! Now you need kill a '.. total_count .. ' '.. name .. '!', cid)                setPlayerStorageValue(cid, m_sto, 1)                setPlayerStorageValue(cid, total_count, 0)                talkState[talkUser] = 0                           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        endendnpcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)npcHandler:addModule(FocusModule:new())

Kill:

 

local tasksss = {   {name = "Blastoise",  sto = 10212, count = 3, time_sto = 5457, time = 1*24*60*60, sto_count = 14129, money = 100, rewardid = 7621, rewardcount = 100, rewardexp = 10000,  text = "Congratulations! You finished this task. In 24h, you will be able to do it again."},   {name = "Charizard",  sto = 10213, count = 5, time_sto = 5458, time = 1*24*60*60, sto_count = 14130, money = 100, rewardid = 7621, rewardcount = 100, rewardexp = 10000,  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            if getPlayerStorageValue(cid, m_sto) ~= -1 then                if getCreatureName(target) == t.name then                	if (total_count - getPlayerStorageValue(cid, count_sto)) == 1 then                		setPlayerStorageValue(cid, count_sto, getPlayerStorageValue(cid, count_sto) + 1)                    	doPlayerSendTextMessage(cid, 20, "You are killed ".. getPlayerStorageValue(cid, count_sto) .." " .. t.name .. " and finished the task!")                    	return true                    elseif (total_count - getPlayerStorageValue(cid, count_sto)) >= 1 then                        setPlayerStorageValue(cid, count_sto, getPlayerStorageValue(cid, count_sto) + 1)                        doPlayerSendTextMessage(cid, 20, "You are killed ".. getPlayerStorageValue(cid, count_sto) .." of ".. total_count .." " .. t.name .. " kills to finish the task.")                        return true                    end                end            end        end    return trueend

Testei com mais de um monstro configurado na tabela funcionou! Está mandando mensagem de quando termina a task e quantos faltam e quando fala com o npc e o mostro não está na tabela, o npc diz que não tem essa task!

JosegvbJ
16 de maio de 2016 às 12:20
5 horas atrás, Drazyn1291 disse:

pronto! Dei uma ajeitada no script e concertei o que estava faltando!

 

Npc:

 

local tasksss = {   [1] = {name = "Blastoise",  sto = 10212, count = 3, time_sto = 5457, time = 1*24*60*60, sto_count = 14129, money = 100, rewardid = 7621, rewardcount = 100, rewardexp = 10000,  text = "Congratulations! You finished this task. In 24h, you will be able to do it again."},   [2] = {name = "Charizard",  sto = 10213, count = 5, time_sto = 5458, time = 1*24*60*60, sto_count = 14130, money = 100, rewardid = 7621, rewardcount = 100, rewardexp = 10000,  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    value = -1    for i = 1, #tasksss do        if msgcontains(msg, tasksss[i].name) and not value ~= -1 then            value = i        end    end    if value == -1 then        selfSay('I don\'t have a this task!', cid)        talkState[talkUser] = 0        return true    end    local configss = tasksss[value]    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 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('Ready! Now you need kill a '.. total_count .. ' '.. name .. '!', cid)                setPlayerStorageValue(cid, m_sto, 1)                setPlayerStorageValue(cid, total_count, 0)                talkState[talkUser] = 0                           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        endendnpcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)npcHandler:addModule(FocusModule:new())

Kill:

 

local tasksss = {   {name = "Blastoise",  sto = 10212, count = 3, time_sto = 5457, time = 1*24*60*60, sto_count = 14129, money = 100, rewardid = 7621, rewardcount = 100, rewardexp = 10000,  text = "Congratulations! You finished this task. In 24h, you will be able to do it again."},   {name = "Charizard",  sto = 10213, count = 5, time_sto = 5458, time = 1*24*60*60, sto_count = 14130, money = 100, rewardid = 7621, rewardcount = 100, rewardexp = 10000,  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            if getPlayerStorageValue(cid, m_sto) ~= -1 then                if getCreatureName(target) == t.name then                	if (total_count - getPlayerStorageValue(cid, count_sto)) == 1 then                		setPlayerStorageValue(cid, count_sto, getPlayerStorageValue(cid, count_sto) + 1)                    	doPlayerSendTextMessage(cid, 20, "You are killed ".. getPlayerStorageValue(cid, count_sto) .." " .. t.name .. " and finished the task!")                    	return true                    elseif (total_count - getPlayerStorageValue(cid, count_sto)) >= 1 then                        setPlayerStorageValue(cid, count_sto, getPlayerStorageValue(cid, count_sto) + 1)                        doPlayerSendTextMessage(cid, 20, "You are killed ".. getPlayerStorageValue(cid, count_sto) .." of ".. total_count .." " .. t.name .. " kills to finish the task.")                        return true                    end                end            end        end    return trueend

Testei com mais de um monstro configurado na tabela funcionou! Está mandando mensagem de quando termina a task e quantos faltam e quando fala com o npc e o mostro não está na tabela, o npc diz que não tem essa task!

daeeeeew agora sim viu kkkkkkkk :D eu fikei batendo a cabeça na parede pq achei q tava fazendo alguma coisa errada ;/: 

valeu querido, se tiver 1 chance me ajuda com o meu login no script das botinhas =x servidor ficou crashando mt