tonynamoral 27 Postado Janeiro 21, 2013 Share Postado Janeiro 21, 2013 Olá galera eu quero por uma limitaçao nessa script -- TonyNamoral Scripts -- items = { [0] = {id = 2472, count = 1, chance = 2}, [1] = {id = 2466, count = 1, chance = 5}, [2] = {id = 8930, count = 1, chance = 10}, [3] = {id = 8858, count = 1, chance = 15}, [4] = {id = 2160, count = 10, chance = 30}, [5] = {id = 6569, count = 50, chance = 100} } function onUse(cid, item, fromPos, item2, toPos) if item2.itemid == 2472 then for i = 0, #items do if (items.chance > math.random(1, 100)) then doPlayerAddItem(cid, items.id, items.count) doPlayerSendTextMessage(cid,27,"You make a "..getItemNameById(items.id).."") doRemoveItem(item2.uid, 1) return true end end doPlayerSendTextMessage(cid,27,"You dont make nothing") doRemoveItem(item2.uid, 1) return false end end Bom eu so quero por assim , o player só pode usar o "use with" , no item2 , se o item2 tiver em uma certa posiçao. Link para o comentário https://xtibia.com/forum/topic/205105-como-eu-fa%C3%A7o-para-por-o-item-na-pos/ Compartilhar em outros sites More sharing options...
0 Oneshot 732 Postado Janeiro 21, 2013 Share Postado Janeiro 21, 2013 (editado) Fala, meu colega, utilize a seguinte construção condicional. local position = {x = 100, y = 100, z = 7} if getThingPosition(item2).x == position.x and getThingPosition(item2).y == position.y and getThingPosition(item2).z == position.z then -- INSERIR CÓDIGO MACARRÔNICO AQUI end Abraços. Editado Janeiro 21, 2013 por Oneshot Link para o comentário https://xtibia.com/forum/topic/205105-como-eu-fa%C3%A7o-para-por-o-item-na-pos/#findComment-1445498 Compartilhar em outros sites More sharing options...
0 tonynamoral 27 Postado Janeiro 21, 2013 Autor Share Postado Janeiro 21, 2013 (editado) Error : [21/01/2013 16:00:15] [Error - Action Interface] [21/01/2013 16:00:15] data/actions/scripts/box1.lua:onUse [21/01/2013 16:00:15] Description: [21/01/2013 16:00:15] (luaGetThingPosition) Thing not found [21/01/2013 16:00:15] [Error - Action Interface] [21/01/2013 16:00:15] data/actions/scripts/box1.lua:onUse [21/01/2013 16:00:15] Description: [21/01/2013 16:00:15] data/actions/scripts/box1.lua:13: attempt to index a boolean value [21/01/2013 16:00:15] stack traceback: [21/01/2013 16:00:15] data/actions/scripts/box1.lua:13: in function <data/actions/scripts/box1.lua:10> Script -- TonyNamoral Scripts -- items = { [0] = {id = 2472, count = 1, chance = 2}, [1] = {id = 2466, count = 1, chance = 5}, [2] = {id = 8930, count = 1, chance = 10}, [3] = {id = 8858, count = 1, chance = 15}, [4] = {id = 2160, count = 10, chance = 30}, [5] = {id = 6569, count = 50, chance = 100} } function onUse(cid, item, fromPos, item2, toPos) local position = {x = 1011, y = 991, z = 7} if getThingPosition(item2).x == position.x and getThingPosition(item2).y == position.y and getThingPosition(item2).z == position.z then if item2.itemid == 2472 then for i = 0, #items do if (items[i].chance > math.random(1, 100)) then doPlayerAddItem(cid, items[i].id, items[i].count) doPlayerSendTextMessage(cid,27,"You make a "..getItemNameById(items[i].id).."") doRemoveItem(item2.uid, 1) return true end end doPlayerSendTextMessage(cid,27,"You dont make nothing") doRemoveItem(item2.uid, 1) return false end end end Editado Janeiro 21, 2013 por tonynamoral Link para o comentário https://xtibia.com/forum/topic/205105-como-eu-fa%C3%A7o-para-por-o-item-na-pos/#findComment-1445506 Compartilhar em outros sites More sharing options...
0 Oneshot 732 Postado Janeiro 21, 2013 Share Postado Janeiro 21, 2013 Ah, eu sou muito burro, esqueci do parâmetro toPosition. Faz algo, tipo assim, olha: local items = { {itemid = 2472, amount = 1, chance = 2}, {itemid = 2466, amount = 1, chance = 5}, {itemid = 8930, count = 1, chance = 10}, {itemid = 8858, count = 1, chance = 15}, {itemid = 2160, count = 10, chance = 30}, {itemid = 6569, count = 50, chance = 100}, } local position = {x = 1011, y = 991, z = 7} function onUse(cid, item, fromPosition, itemEx, toPosition) local match if toPosition.x == position.x and toPosition.y == position.y and toPosition.z == position.z then if itemEx.itemid == 2472 then for tmp = 1, #items do if items[tmp].chance > math.random(1, 100) then match = doPlayerAddItem(cid, items[tmp].itemid, items[tmp].amount) doPlayerSendTextMessage(cid, 27, "You make a ".. getItemNameById(items[tmp].id) ..".") break end end end end if not match then doPlayerSendTextMessage(cid, 27, "You don't make nothing") end doRemoveItem(itemEx.uid) return true end Link para o comentário https://xtibia.com/forum/topic/205105-como-eu-fa%C3%A7o-para-por-o-item-na-pos/#findComment-1445541 Compartilhar em outros sites More sharing options...
0 tonynamoral 27 Postado Janeiro 21, 2013 Autor Share Postado Janeiro 21, 2013 (editado) Bom , agora so aparece que eu nao criei o item fica dando só essa msg -> doPlayerSendTextMessage(cid, 27, "You don't make nothing"), bom sera que tem como fazer se o player nao estiver com a madeira no lgar certo, aparece 1 msg que a madeira precisar estar em cima de 1 lugar e talz? Eu olhei o script , e axei algo esquisito local match if not match .... oq acontece? , o match nao é nada mesmo? Editado Janeiro 21, 2013 por tonynamoral Link para o comentário https://xtibia.com/forum/topic/205105-como-eu-fa%C3%A7o-para-por-o-item-na-pos/#findComment-1445665 Compartilhar em outros sites More sharing options...
0 Oneshot 732 Postado Janeiro 21, 2013 Share Postado Janeiro 21, 2013 Daqui a pouco, eu testo o script em algum servidor e te retorno um funcional. Sobre verificar se tal item está em cima de algo é só usar getTileItemById(position, itemid) Enfim, volto logo. Link para o comentário https://xtibia.com/forum/topic/205105-como-eu-fa%C3%A7o-para-por-o-item-na-pos/#findComment-1445672 Compartilhar em outros sites More sharing options...
0 tonynamoral 27 Postado Janeiro 21, 2013 Autor Share Postado Janeiro 21, 2013 Testei um aqui , só que deu error script -- TonyNamoral Scripts -- items = { [0] = {id = 2472, count = 1, chance = 2}, [1] = {id = 2466, count = 1, chance = 5}, [2] = {id = 8930, count = 1, chance = 10}, [3] = {id = 8858, count = 1, chance = 15}, [4] = {id = 2160, count = 10, chance = 30}, [5] = {id = 6569, count = 50, chance = 100} } function onUse(cid, item, fromPos, item2, toPos) local pos = {x = 1012, y = 992, y = 7, stackpos = 2} if item2.itemid == 2450 then if not getTileItemById(pos, 2450).uid <= 0 then doPlayerSendcancel(cid,"Voce precisa da table") return false end for i = 0, #items do if (items[i].chance > math.random(1, 100)) then doPlayerAddItem(cid, items[i].id, items[i].count) doPlayerSendTextMessage(cid,27,"You make a "..getItemNameById(items[i].id).."") doRemoveItem(item2.uid, 1) return true end end doPlayerSendTextMessage(cid,27,"You dont make nothing") doRemoveItem(item2.uid, 1) return false end end error : [21/01/2013 18:11:00] [Error - Action Interface] [21/01/2013 18:11:00] data/actions/scripts/box1.lua:onUse [21/01/2013 18:11:00] Description: [21/01/2013 18:11:00] data/actions/scripts/box1.lua:14: attempt to compare boolean with number [21/01/2013 18:11:00] stack traceback: [21/01/2013 18:11:00] data/actions/scripts/box1.lua:14: in function <data/actions/scripts/box1.lua:11> Link para o comentário https://xtibia.com/forum/topic/205105-como-eu-fa%C3%A7o-para-por-o-item-na-pos/#findComment-1445680 Compartilhar em outros sites More sharing options...
0 Skymagnum 234 Postado Janeiro 21, 2013 Share Postado Janeiro 21, 2013 (editado) Olha, eu fiz rapidinho porque vou sair: pastebin se não funcionar arrumo depois. @Esqueci do doRemoveItem, coloca lá, encima do return true. Editado Janeiro 21, 2013 por Skymagnum Link para o comentário https://xtibia.com/forum/topic/205105-como-eu-fa%C3%A7o-para-por-o-item-na-pos/#findComment-1445698 Compartilhar em outros sites More sharing options...
0 Oneshot 732 Postado Janeiro 21, 2013 Share Postado Janeiro 21, 2013 (editado) Pronto, totalmente funcional. local items = { {itemid = 2472, amount = 1, chance = 2}, {itemid = 2466, amount = 1, chance = 5}, {itemid = 8930, amount = 1, chance = 10}, {itemid = 8858, amount = 1, chance = 15}, {itemid = 2160, amount = 10, chance = 30}, {itemid = 6569, amount = 50, chance = 100}, } function onUse(cid, item, fromPosition, itemEx, toPosition) if toPosition.x == 0xFFFF or itemEx.itemid ~= 2472 then doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE) return true end if getTileItemById(toPosition, 2450).uid == 0 then doPlayerSendCancel(cid, "You need a table.") return true end local tmp = items[math.random(1, #items)] if tmp.chance > math.random(1, 100) then doPlayerAddItem(cid, tmp.itemid, tmp.amount) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You make a ".. getItemNameById(tmp.itemid) ..".") else doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You make nothing.") end doRemoveItem(itemEx.uid, 1) return true end Abração. Editado Janeiro 21, 2013 por Oneshot Link para o comentário https://xtibia.com/forum/topic/205105-como-eu-fa%C3%A7o-para-por-o-item-na-pos/#findComment-1445703 Compartilhar em outros sites More sharing options...
0 tonynamoral 27 Postado Janeiro 21, 2013 Autor Share Postado Janeiro 21, 2013 (editado) Obrigado OneShot , REP+ Abraçao (: Editado Janeiro 21, 2013 por tonynamoral Link para o comentário https://xtibia.com/forum/topic/205105-como-eu-fa%C3%A7o-para-por-o-item-na-pos/#findComment-1445766 Compartilhar em outros sites More sharing options...
0 AlexandreKG 134 Postado Janeiro 21, 2013 Share Postado Janeiro 21, 2013 Resolvido? Link para o comentário https://xtibia.com/forum/topic/205105-como-eu-fa%C3%A7o-para-por-o-item-na-pos/#findComment-1445770 Compartilhar em outros sites More sharing options...
0 Oneshot 732 Postado Janeiro 21, 2013 Share Postado Janeiro 21, 2013 Tópico movido para a seção de dúvidas e pedidos resolvidos. Link para o comentário https://xtibia.com/forum/topic/205105-como-eu-fa%C3%A7o-para-por-o-item-na-pos/#findComment-1445779 Compartilhar em outros sites More sharing options...
Pergunta
tonynamoral 27
Olá galera eu quero por uma limitaçao nessa script
-- TonyNamoral Scripts --
items = {
[0] = {id = 2472, count = 1, chance = 2},
[1] = {id = 2466, count = 1, chance = 5},
[2] = {id = 8930, count = 1, chance = 10},
[3] = {id = 8858, count = 1, chance = 15},
[4] = {id = 2160, count = 10, chance = 30},
[5] = {id = 6569, count = 50, chance = 100}
}
function onUse(cid, item, fromPos, item2, toPos)
if item2.itemid == 2472 then
for i = 0, #items do
if (items.chance > math.random(1, 100)) then
doPlayerAddItem(cid, items.id, items.count)
doPlayerSendTextMessage(cid,27,"You make a "..getItemNameById(items.id).."")
doRemoveItem(item2.uid, 1)
return true
end
end
doPlayerSendTextMessage(cid,27,"You dont make nothing")
doRemoveItem(item2.uid, 1)
return false
end
end
Bom eu so quero por assim , o player só pode usar o "use with" , no item2 , se o item2 tiver em uma certa posiçao.
Link para o comentário
https://xtibia.com/forum/topic/205105-como-eu-fa%C3%A7o-para-por-o-item-na-pos/Compartilhar em outros sites
11 respostass a esta questão
Posts Recomendados