LU
dúvida

Ajuda script quest Omega!

Por luccagomes, 20 de set. de 2013 em Scripts

resolvido
script
6
694
luccagomesL
20 de setembro de 2013 às 14:09

Fiz tudo certinho do jeito q ele falou, mas meu script de quest n funciona, qnd eu dou use no bau da isso:

 

[Error - Action Interface]
data/actions/scripts/quests.lua:onUse
Description:
data/actions/scripts/quests.lua:16: attempt to call global 'getPlayerWeightById' <a nil value>
stack traceback:
data/actions/scripts/quests.lua:16: in function <data/actions/scripts/quests.lua:1>

 

uso a rev 3884, 8.60

 

script:

 


function onUse(cid, item, fromPos, item2, toPos)
local _ = {
[1] = {aid = 8000, item = 2427},
[2] = {aid = 8001, item = 2466},
[3] = {aid = 8002, item = 2171},
[4] = {aid = 8003, item = 2520},
}

-- Reservando os storages a partir de 202049 até o 202049 + número de baús nessa action
for i = 1, #_ do
_.storage = 202049 + i
end

for i, valor in ipairs(_) do
if item.actionid == valor.aid then
if getPlayerFreeCap(cid) >= getPlayerWeightById(valor.item, 1) then
if getPlayerStorageValue(cid, valor.storage) == -1 then
if doPlayerAddItem(cid, valor.item, 1, false) then
doPlayerSendTextMessage(cid, 22, 'You have found a '..getItemNameById(valor.item)..'.')
setPlayerStorageValue(cid, valor.storage, 1)
else
doPlayerSendTextMessage(cid, 22, 'You have found a '..getItemNameById(valor.item)..', but you need a free slot.')
end
else
doPlayerSendTextMessage(cid, 22, 'It is empty.')
end
else
doPlayerSendTextMessage(cid, 22, 'You have found a '..getItemNameById(valor.item)..'. It weighs '..getItemWeightById(valor.item, 1)..'.00 and it is too heavy.')
end
break
end
end
return true
end

OmegaO
20 de setembro de 2013 às 21:15

 

 

function onUse(cid, item, fromPos, item2, toPos)
local _ = {
[1] = {aid = 8000, item = 2427},
[2] = {aid = 8001, item = 2466},
[3] = {aid = 8002, item = 2171},
[4] = {aid = 8003, item = 2520},
}

-- Reservando os storages a partir de 202049 até o 202049 + número de baús nessa action
    for i = 1, #_ do
        _.storage = 202049 + i
    end

    for i, valor in ipairs(_) do
        if item.actionid == valor.aid then
            if getPlayerFreeCap(cid) >= getItemWeightById(valor.item, 1) then
                if getPlayerStorageValue(cid, valor.storage) == -1 then
                    if doPlayerAddItem(cid, valor.item, 1, false) then
                        doPlayerSendTextMessage(cid, 22, 'You have found a '..getItemNameById(valor.item)..'.')
                        setPlayerStorageValue(cid, valor.storage, 1)
                    else
                        doPlayerSendTextMessage(cid, 22, 'You have found a '..getItemNameById(valor.item)..', but you need a free slot.')
                    end
                else
                    doPlayerSendTextMessage(cid, 22, 'It is empty.')
                end
            else
                doPlayerSendTextMessage(cid, 22, 'You have found a '..getItemNameById(valor.item)..'. It weighs '..getItemWeightById(valor.item, 1)..'.00 and it is too heavy.')
            end
            break
        end
    end
    return true
end

 

 

luccagomesL
20 de setembro de 2013 às 21:52

Omega funcionou, mas deu problema nas storages, pq só da pra fazer a quest uma vez, dps da empty, tipo em todas as actions eu fiz a 8000, ta dando q eu já peguei todas a 8000,8001,8002,8003

OmegaO
20 de setembro de 2013 às 21:56

Erro meu, acho que consertei

OBS.: quando for usar um script, deixa algum comentário ou curte, sei lá. É bom saber que tem gente que usa o que você fez e que não tá só de enfeite...

 

 

function onUse(cid, item, fromPos, item2, toPos)
local _ = {
[1] = {aid = 8000, item = 2427},
[2] = {aid = 8001, item = 2466},
[3] = {aid = 8002, item = 2171},
[4] = {aid = 8003, item = 2520},
}

-- Reservando os storages a partir de 202049 até o 202049 + número de baús nessa action
    for i = 1, #_ do
        _[i].storage = 202049 + i
    end

    for i, valor in ipairs(_) do
        if item.actionid == valor.aid then
            if getPlayerFreeCap(cid) >= getItemWeightById(valor.item, 1) then
                if getPlayerStorageValue(cid, valor.storage) == -1 then
                    if doPlayerAddItem(cid, valor.item, 1, false) then
                        doPlayerSendTextMessage(cid, 22, 'You have found a '..getItemNameById(valor.item)..'.')
                        setPlayerStorageValue(cid, valor.storage, 1)
                    else
                        doPlayerSendTextMessage(cid, 22, 'You have found a '..getItemNameById(valor.item)..', but you need a free slot.')
                    end
                else
                    doPlayerSendTextMessage(cid, 22, 'It is empty.')
                end
            else
                doPlayerSendTextMessage(cid, 22, 'You have found a '..getItemNameById(valor.item)..'. It weighs '..getItemWeightById(valor.item, 1)..'.00 and it is too heavy.')
            end
            break
        end
    end
    return true
end

 

 

Editado Setembro 21 por omega blueheaven

luccagomesL
21 de setembro de 2013 às 03:59

Q isso man claro q vou usar, mt mais organizado, todos deviam usar, usa um topico só com ele, 2 reps pra vc =D

RoksasR
23 de setembro de 2013 às 07:56

Tópico movido para a seção de dúvidas e pedidos resolvidos.