FA
pedido

Use e Troque

Por fawkz12, 21 de mar. de 2016 em Scripts

20
2.6k
fawkz12F
21 de março de 2016 às 22:52

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 !

21 de março de 2016 às 23:07

Mandar Id Da Maquina

 

é o id dos items?

fawkz12F
21 de março de 2016 às 23:10

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

21 de março de 2016 às 23:31


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

fawkz12F
21 de março de 2016 às 23:36

Mas explica, aonde eu coloco tals :x

21 de março de 2016 às 23:39

Olhar Agora :)

fawkz12F
21 de março de 2016 às 23:41

To falando tipo... me manda em qual pasta... Actions... etc

e me manda a tag por favor... REP+

21 de março de 2016 às 23:44

Tag = }

 

<action itemid="1955" event="script" value="Teste.lua"/>

fawkz12F
21 de março de 2016 às 23:49
[Error - LuaScriptInterface::loadFile] data/actions/scripts/maquinaheld.lua:28: 'end' expected (to close 'function' at line 1) near '<eof>'

[21/03/2016 23:48:30] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/maquinaheld.lua)

[21/03/2016 23:48:30] data/actions/scripts/maquinaheld.lua:28: 'end' expected (to close 'function' at line 1) near '<eof>'

21 de março de 2016 às 23:51


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

 

fawkz12F
21 de março de 2016 às 23:56

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

21 de março de 2016 às 23:58

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

fawkz12F
22 de março de 2016 às 00:05

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

22 de março de 2016 às 00:05


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

fawkz12F
22 de março de 2016 às 00:12

Não sei muito bem de scriipt, mas não seria necessario aquele bagulho de ''removeitem : Id do item''