Mandar Id Da Maquina
é o id dos items?
info
Grupo: Artesão
Registrado: 08/10/15
Posts: 103
Reputação: +34

Mandar Id Da Maquina
é o id dos items?
ID da MAQUINA - 1955
ID dos itens para eu TROCAR - 13976, 13948, 13969, 13990, 13941, 13983
ID dos ITENS para RECEBER Aleatorios - 13976, 13948, 13969, 13990, 13941, 13983
Mesmo ID, pois tipo, tenho que dar algum dos ITENS ali em cima, para receber um ITEM aleatorio nos ID de baixo !
se for fazer o SCRIPT, me passe também como modificar, adicionar mais e tals
info
Grupo: Artesão
Registrado: 08/10/15
Posts: 103
Reputação: +34

TESTA ASSIM = {
function onUse(cid, item, fromPosition, itemEx, toPosition)
local itemid = 13976 ---- ITEM QUER PRECISAR Para Usar Maquina
local items = {
{itemId = 13976, count = 1, chance = 84}, -- Itemid id do item Count Quantidade vai ganhar Chance Quer poder ganhar
{itemId = 13948, count = 1, chance = 32},
{itemId = 13969, count = 1, chance = 24},
{itemId = 13990, count = 1, chance = 10},
{itemId = 13941, count = 1, chance = 48},
}
for itemId, itemInfo in pairs (randomTable) do
local min, max = itemInfo.min, itemInfo.min + itemInfo.max
if randomNumber >= min and randomNumber <= max then
local newItem = doPlayerAddItem(cid, itemId, itemInfo.count, false)
if not newItem then return doPlayerSendCancel(cid, "Você não tem espaço livre para receber o item!") end
doRemoveItem(item.uid, 1)
local iInfo = getItemInfo(itemId)
break
end
end
if getPlayerItemCount(cid, itemid) >= 1 then
doPlayerSendCancel(cid, "Voce Precisar Do Item Para Usar Maquina!.")
return true
end
Editado Março 21 por luizmachado1
Mas explica, aonde eu coloco tals :x
info
Grupo: Artesão
Registrado: 08/10/15
Posts: 103
Reputação: +34

Olhar Agora ![]()
To falando tipo... me manda em qual pasta... Actions... etc
e me manda a tag por favor... REP+
info
Grupo: Artesão
Registrado: 08/10/15
Posts: 103
Reputação: +34

Tag = }
<action itemid="1955" event="script" value="Teste.lua"/>
info
Grupo: Artesão
Registrado: 08/10/15
Posts: 103
Reputação: +34

Testa Assim :
local items = {
{itemId = 13976, count = 1, chance = 84}, -- Itemid id do item Count Quantidade vai ganhar Chance Quer poder ganhar
{itemId = 13948, count = 1, chance = 32},
{itemId = 13969, count = 1, chance = 24},
{itemId = 13990, count = 1, chance = 10},
{itemId = 13941, count = 1, chance = 48},
}
local itemid = 13976 ---- ITEM QUER PRECISAR Para Usar Maquina
function onUse(cid, item, frompos, item2, topos)
if getPlayerItemCount(cid, itemid) >= 1 then
doPlayerSendCancel(cid, "Voce Precisar Do Item Para Usar Maquina!.")
return true
end
local totalChance, randomTable, randomNumber = 0, {}, 0
for _, itemInfo in pairs (items) do
randomTable[itemInfo.itemId] = {min = totalChance + 1, max = itemInfo.chance, count = itemInfo.count or 1}
totalChance = totalChance + itemInfo.chance
end
randomNumber = math.random(1, totalChance)
for itemId, itemInfo in pairs (randomTable) do
local min, max = itemInfo.min, itemInfo.min + itemInfo.max
if randomNumber >= min and randomNumber <= max then
local newItem = doPlayerAddItem(cid, itemId, itemInfo.count, false)
if not newItem then return doPlayerSendCancel(cid, "Você não tem espaço livre para receber o item!") end
doRemoveItem(item.uid, 1)
local iInfo = getItemInfo(itemId)
doPlayerSendTextMessage(cid, 27, "Você acabou de receber um item ("..iInfo.name..")!")
break
end
end
return true
end
Então, funcionou certinho. mas não precisou do ITEM tlg... não removeu o ITEM da minha bag... e a maquina sumiu quando eu usei
info
Grupo: Artesão
Registrado: 08/10/15
Posts: 103
Reputação: +34

Ok vou Acheita 1 minuto!
Testa Assim = {
local items = {
{itemId = 13976, count = 1, chance = 84}, -- Itemid id do item Count Quantidade vai ganhar Chance Quer poder ganhar
{itemId = 13948, count = 1, chance = 32},
{itemId = 13969, count = 1, chance = 24},
{itemId = 13990, count = 1, chance = 10},
{itemId = 13941, count = 1, chance = 48},
}
local itemid = 13976 ---- ITEM QUER PRECISAR Para Usar Maquina
function onUse(cid, item, frompos, item2, topos)
if getPlayerItemCount(cid, itemid) >= 1 then
doPlayerSendCancel(cid, "Voce Precisar Do Item Para Usar Maquina!.")
return true
end
local totalChance, randomTable, randomNumber = 0, {}, 0
for _, itemInfo in pairs (items) do
randomTable[itemInfo.itemId] = {min = totalChance + 1, max = itemInfo.chance, count = itemInfo.count or 1}
totalChance = totalChance + itemInfo.chance
end
randomNumber = math.random(1, totalChance)
for itemId, itemInfo in pairs (randomTable) do
local min, max = itemInfo.min, itemInfo.min + itemInfo.max
if randomNumber >= min and randomNumber <= max then
local newItem = doPlayerAddItem(cid, itemId, itemInfo.count, false)
if not newItem then return doPlayerSendCancel(cid, "Você não tem espaço livre para receber o item!") end
doRemoveItem(cid, 13976, 1)
local iInfo = getItemInfo(itemId)
doPlayerSendTextMessage(cid, 27, "Você acabou de receber um item ("..iInfo.name..")!")
break
end
end
return true
end
Editado Março 21 por luizmachado1
Beleza <3
Tipo, se eu to com o item necessario na BAG, a maquina fala ''Você precisa do item pra usar'' ai se eu removo o item necessario de minha bag, a maquina funciona..
info
Grupo: Artesão
Registrado: 08/10/15
Posts: 103
Reputação: +34

local items = {
{itemId = 13976, count = 1, chance = 84}, -- Itemid id do item Count Quantidade vai ganhar Chance Quer poder ganhar
{itemId = 13948, count = 1, chance = 32},
{itemId = 13969, count = 1, chance = 24},
{itemId = 13990, count = 1, chance = 10},
{itemId = 13941, count = 1, chance = 48},
}
local id_remove = 13976 --- id quer vai remove do player
function onUse(cid, item, frompos, item2, topos)
if item.itemid == 13976 then
elseif item.itemid == 13976 then
doPlayerSendTextMessage(cid, 22, "Você precisa de item para usar")
return true
end
local totalChance, randomTable, randomNumber = 0, {}, 0
for _, itemInfo in pairs (items) do
randomTable[itemInfo.itemId] = {min = totalChance + 1, max = itemInfo.chance, count = itemInfo.count or 1}
totalChance = totalChance + itemInfo.chance
end
randomNumber = math.random(1, totalChance)
for itemId, itemInfo in pairs (randomTable) do
local min, max = itemInfo.min, itemInfo.min + itemInfo.max
if randomNumber >= min and randomNumber <= max then
local newItem = doPlayerAddItem(cid, itemId, itemInfo.count, false)
if not newItem then return doPlayerSendCancel(cid, "Você não tem espaço livre para receber o item!") end
doPlayerRemoveItem(id_remove, 1)
local iInfo = getItemInfo(itemId)
doPlayerSendTextMessage(cid, 27, "Você acabou de receber um item ("..iInfo.name..")!")
break
end
end
return true
end
Editado Março 22 por luizmachado1
info
Grupo: Campones
Registrado: 12/08/15
Posts: 84
Reputação: +7
Pedido : O pedido é o seguinte... queria um SCRIPT que eu colocaria em uma MAQUINA, ai nessa maquina ela trocaria itens de minha BAG por ITENS Aleatorios !