Ir para conteúdo
  • Cadastre-se

(Resolvido)Autoloot + Talk (Hard)


Ir para solução Resolvido por Dwarfer,

Posts Recomendados

Preciso de ajudar para modificar o mod de autoloot para que, o premium seja meu sistema de vip.

 

E o pedido de uma talk !loot list que pegue os dados do mod, e mostre em pop up, o nome do item, e seu valor.

 

items_price = {[2498] = 40000,[2523] = 150000, [2656] = 15000,[2195] = 40000,[2520] = 40000,[2492] = 60000, [2466] = 30000,[2646] = 100000,[2470] = 80000, [2522] = 100000, [2472] = 100000, [2514] = 80000, [2645] = 40000, [2528] = 8000}

 

Ficando da seguinte forma na talk (exemplo):

 

ROYAL HELMET - [40K ] ou 40000

DEMON SHIELD - [40K]

MASTERMIND SHIELD - [80K]

 

ou

 

ROYAL HELMET

40K ou 40000

 

DEMON SHIELD

40K

 

 

 

<?xml version="1.0" encoding="ISO-8859-1"?>
<mod name="Loot System" version="1.0" author="Vodkart And Mkalo" contact="none.com" enabled="yes">
<config name="Loot_func"><![CDATA[
info = {
	AutomaticDeposit = true,
	BlockMonsters = {},
	BlockItemsList = {2123,2515},
	Max_Slots = {free = 2, premium = 5},
	Storages = {27000,28008,28006,28007},
	items_price = {[2498] = 40000,[2523] = 150000, [2656] = 15000,[2195] = 40000,[2520] = 40000,[2492] = 60000, [2466] = 30000,[2646] = 100000,[2470] = 80000, [2522] = 100000, [2472] = 100000, [2514] = 80000, [2645] = 40000, [2528] = 8000}
}
function setPlayerStorageTable(cid, storage, tab)
	local tabstr = "&"
	for i,x in pairs(tab) do
		tabstr = tabstr .. i .. "," .. x .. ";"
	end
	setPlayerStorageValue(cid, storage, tabstr:sub(1, #tabstr-1))
end
function getPlayerStorageTable(cid, storage)
	local tabstr = getPlayerStorageValue(cid, storage)
	local tab = {}
	if type(tabstr) ~= "string" then
		return {}
	end
	if tabstr:sub(1,1) ~= "&" then
		return {}
	end
	local tabstr = tabstr:sub(2, #tabstr)
	local a = string.explode(tabstr, ";")
	for i,x in pairs(a) do
		local b = string.explode(x, ",")
		tab[tonumber(b[1]) or b[1]] = tonumber(b[2]) or b[2]
	end
	return tab
end
function isInTable(cid, item)
	for _,i in pairs(getPlayerStorageTable(cid, info.Storages[1]))do
		if tonumber(i) == tonumber(item) then
			return true
		end
	end
	return false
end
function addItemTable(cid, item)
	local x = {}
	for i = 1,#getPlayerStorageTable(cid, info.Storages[1]) do
		table.insert(x,getPlayerStorageTable(cid, info.Storages[1])[i])
	end
	if x ~= 0 then
		table.insert(x,tonumber(item))
		setPlayerStorageTable(cid, info.Storages[1], x)
	else
		setPlayerStorageTable(cid, info.Storages[1], {item})
	end
end
function removeItemTable(cid, item)
	local x = {}
	for i = 1,#getPlayerStorageTable(cid, info.Storages[1]) do
		table.insert(x,getPlayerStorageTable(cid, info.Storages[1])[i])
	end
	for i,v in ipairs(x) do
		if tonumber(v) == tonumber(item) then
			table.remove(x,i)
		end
	end
	return setPlayerStorageTable(cid, info.Storages[1], x)
end
function ShowItemsTabble(cid)
	local n,str = 0,"[+] Auto Loot Commands [+]\n\n!autoloot item name --> To add ou Remove item from list.\n!autoloot money --> To collect gold automatically.\n!autoloot clear --> To clear the list.\n!autoloot on/off --> To enable or disable the collecting of items in the system.\n\n[+] Auto Loot Info [+]\n\nSystem: "..(getPlayerStorageValue(cid, info.Storages[3]) <= 0 and "Activated" or "Disabled")..".\nGold Collecting: "..(getPlayerStorageValue(cid, info.Storages[2]) > 0 and "Activated" or "Disabled")..".\nAutomatic Item Selling: "..(getPlayerStorageValue(cid, info.Storages[4]) > 0 and "Activated" or "Disabled")..".\nBalance Total: ["..getPlayerBalance(cid).."] gp's.\nMaximum Slots: ["..#getPlayerStorageTable(cid, info.Storages[1]).."/"..(isPremium(cid) and info.Max_Slots.premium or info.Max_Slots.free).."]\n\n[+] Auto Loot Slots [+]\n\n"
	for i = 1,#getPlayerStorageTable(cid, info.Storages[1]) do
		n = n + 1
		str = str.."Slot "..n.." - "..getItemNameById(getPlayerStorageTable(cid, info.Storages[1])[i]).."\n"
	end
	return doPlayerPopupFYI(cid, str)
end
function getContainerItems(containeruid)
	local items = {}
	local containers = {}
	if type(getContainerSize(containeruid)) ~= "number" then
		return false
	end
	for slot = 0, getContainerSize(containeruid)-1 do
		local item = getContainerItem(containeruid, slot)
		if item.itemid == 0 then
			break
		end
		if isContainer(item.uid) then
			table.insert(containers, item.uid)
		end
		table.insert(items, item)
	end
	if #containers > 0 then
		for i,x in ipairs(getContainerItems(containers[1])) do
			table.insert(items, x)
		end
		table.remove(containers, 1)
	end
	return items
end
function getItemsInContainerById(container, itemid) -- Function By Kydrai
	local items = {}
	if isContainer(container) and getContainerSize(container) > 0 then
		for slot=0, (getContainerSize(container)-1) do
			local item = getContainerItem(container, slot)
			if isContainer(item.uid) then
				local itemsbag = getItemsInContainerById(item.uid, itemid)
				for i=0, #itemsbag do
					table.insert(items, itemsbag[i])
				end
			else
				if itemid == item.itemid then
					table.insert(items, item.uid)
				end
			end
		end
	end
	return items
end
function doPlayerAddItemStacking(cid, itemid, amount) -- revisado
	local item, _G = getItemsInContainerById(getPlayerSlotItem(cid, 3).uid, itemid), 0
	if #item > 0 then
		for _ ,x in pairs(item) do
			local ret = getThing(x)
			if ret.type < 100 then
				doTransformItem(ret.uid, itemid, ret.type+amount) 
				if ret.type+amount > 100 then
					doPlayerAddItem(cid, itemid, ret.type+amount-100)
				end
				break
			else
				_G = _G+1
			end
		end
		if _G == #item then
			doPlayerAddItem(cid, itemid, amount)
		end
	else
		return doPlayerAddItem(cid, itemid, amount)
	end
end
function AutomaticDeposit(cid,item,n)
	local deposit = item == tonumber(2160) and (n*10000) or tonumber(item) == 2152 and (n*100) or (n*1)
	return doPlayerDepositMoney(cid, deposit)
end
function AutomaticItensSelling(cid, x)
	return doPlayerAddMoney(cid, x) and doPlayerDepositMoney(cid, x)
end
function corpseRetireItems(cid, pos)
	local check = false
	for i = 0, 255 do
		pos.stackpos = i
		tile = getTileThingByPos(pos)
		if tile.uid > 0 and isCorpse(tile.uid) then
			check = true break
		end
	end
	if check == true then
		local items = getContainerItems(tile.uid)
		for i,x in pairs(items) do
			if isInArray(getPlayerStorageTable(cid, info.Storages[1]), tonumber(x.itemid)) or getPlayerStorageValue(cid, info.Storages[2]) > 0 and isInArray({2148,2152,2160},tonumber(x.itemid)) then
				if isItemStackable(x.itemid) then
					if getPlayerStorageValue(cid, info.Storages[4]) > 0 and info.items_price[tonumber(x.itemid)] then
						AutomaticItensSelling(cid, (info.items_price[tonumber(x.itemid)]*x.type))
					else
						doPlayerAddItemStacking(cid, x.itemid, x.type)
						if info.AutomaticDeposit == true and isInArray({2148,2152,2160}, tonumber(x.itemid)) then
							AutomaticDeposit(cid,x.itemid,x.type)
						end
					end
				else
					if getPlayerStorageValue(cid, info.Storages[4]) > 0 and info.items_price[tonumber(x.itemid)] then
						AutomaticItensSelling(cid, info.items_price[tonumber(x.itemid)])
					else
						doPlayerAddItem(cid, x.itemid)
					end
				end
				doRemoveItem(x.uid)
			end
		end
	end
end]]></config>
<event type="login" name="LootLogin" event="script"><![CDATA[
function onLogin(cid)
	registerCreatureEvent(cid, "LootEventKIll")
	if isPremium(cid) and getPlayerStorageValue(cid, 27001) <= 0 then
		setPlayerStorageValue(cid, 27001, 1)
	elseif getPlayerStorageValue(cid, 27001) > 0 and not isPremium(cid) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[Auto Loot] You premium is Over, Start a new list!")
		setPlayerStorageValue(cid, 27001, -1)
		setPlayerStorageValue(cid, info.Storages[1], -1)
	end
	return true
end]]></event>
<event type="kill" name="LootEventKIll" event="script"><![CDATA[
domodlib('Loot_func')
function onKill(cid, target, lastHit) 
	if isPlayer(cid) and getPlayerStorageValue(cid, info.Storages[3]) <= 0 and isMonster(target) and not isInArray(info.BlockMonsters, getCreatureName(target):lower()) then
		addEvent(corpseRetireItems, 0, cid ,getThingPos(target))
	end
	return true
end]]></event>
<talkaction words="!autoloot" event="buffer"><![CDATA[
domodlib('Loot_func')
local param, slots = param:lower(), isPremium(cid) and info.Max_Slots.premium or info.Max_Slots.free
if not param or param == "" then
	ShowItemsTabble(cid) return true
elseif tonumber(param) then
	doPlayerSendCancel(cid, "enter commands: !autoloot item name [+] !autoloot clean [+] !autoloot money [+] !autoloot on/off") return true
elseif isInArray({"clean","limpar", "clear"}, param) then
	setPlayerStorageValue(cid, info.Storages[1], -1)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"[Auto Loot] Your list has been cleaned.") return true
elseif isInArray({"start","stop","on","off"}, param) then
	setPlayerStorageValue(cid, info.Storages[3], getPlayerStorageValue(cid, info.Storages[3]) <= 0 and 1 or 0)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"[Auto Loot] "..(getPlayerStorageValue(cid, info.Storages[3]) > 0 and "Stopped" or "Started")..".") return true
elseif isInArray({"money","gold","gps","dinheiro"}, param) then
	setPlayerStorageValue(cid, info.Storages[2], getPlayerStorageValue(cid, info.Storages[2]) <= 0 and 1 or 0)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"[Auto Loot] Gold Colleting "..(getPlayerStorageValue(cid, info.Storages[2]) > 0 and "Activated" or "disabled")..".") return true
elseif isInArray({"selling","autosell","sell","vender"}, param) then
	setPlayerStorageValue(cid, info.Storages[4], getPlayerStorageValue(cid, info.Storages[4]) <= 0 and 1 or 0)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"[Auto Loot] Automatic Itens Selling "..(getPlayerStorageValue(cid, info.Storages[4]) > 0 and "Activated" or "disabled")..".") return true
end
local item = getItemIdByName(param, false)
if not item then
	doPlayerSendCancel(cid, "This item does not exist.") return true
end
local var = isInTable(cid, item)
if isInArray({2148,2152,2160},item) then 
	doPlayerSendCancel(cid, "Enter !autoloot money to add money in your list!") return true	
elseif isInArray(info.BlockItemsList, item) then
	doPlayerSendCancel(cid, "You can not add this item in the list!") return true
elseif not var and #getPlayerStorageTable(cid, info.Storages[1]) >= slots then
	doPlayerSendCancel(cid, "max "..slots.." from auto loot") return true
end
if not var then
	addItemTable(cid, item)
else
	removeItemTable(cid, item)
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,not var and "you added the item "..param.." in the list" or "you removed the item "..param.." from the list")
return true]]></talkaction>
</mod>

Sistema VIP:

 

 

 

 

Link para o post
Compartilhar em outros sites
Spoiler

<?xml version="1.0" encoding="ISO-8859-1"?>
<mod name="Loot System" version="1.0" author="Vodkart And Mkalo" contact="none.com" enabled="yes">
<config name="Loot_func"><![CDATA[
info = {
	AutomaticDeposit = true,
	BlockMonsters = {},
	BlockItemsList = {2123,2515},
	Max_Slots = {free = 2, premium = 5},
	Storages = {27000,28008,28006,28007},
	items_price = {[2498] = 40000,[2523] = 150000, [2656] = 15000,[2195] = 40000,[2520] = 40000,[2492] = 60000, [2466] = 30000,[2646] = 100000,[2470] = 80000, [2522] = 100000, [2472] = 100000, [2514] = 80000, [2645] = 40000, [2528] = 8000}
}
function setPlayerStorageTable(cid, storage, tab)
	local tabstr = "&"
	for i,x in pairs(tab) do
		tabstr = tabstr .. i .. "," .. x .. ";"
	end
	setPlayerStorageValue(cid, storage, tabstr:sub(1, #tabstr-1))
end
function getPlayerStorageTable(cid, storage)
	local tabstr = getPlayerStorageValue(cid, storage)
	local tab = {}
	if type(tabstr) ~= "string" then
		return {}
	end
	if tabstr:sub(1,1) ~= "&" then
		return {}
	end
	local tabstr = tabstr:sub(2, #tabstr)
	local a = string.explode(tabstr, ";")
	for i,x in pairs(a) do
		local b = string.explode(x, ",")
		tab[tonumber(b[1]) or b[1]] = tonumber(b[2]) or b[2]
	end
	return tab
end
function isInTable(cid, item)
	for _,i in pairs(getPlayerStorageTable(cid, info.Storages[1]))do
		if tonumber(i) == tonumber(item) then
			return true
		end
	end
	return false
end
function addItemTable(cid, item)
	local x = {}
	for i = 1,#getPlayerStorageTable(cid, info.Storages[1]) do
		table.insert(x,getPlayerStorageTable(cid, info.Storages[1])[i])
	end
	if x ~= 0 then
		table.insert(x,tonumber(item))
		setPlayerStorageTable(cid, info.Storages[1], x)
	else
		setPlayerStorageTable(cid, info.Storages[1], {item})
	end
end
function removeItemTable(cid, item)
	local x = {}
	for i = 1,#getPlayerStorageTable(cid, info.Storages[1]) do
		table.insert(x,getPlayerStorageTable(cid, info.Storages[1])[i])
	end
	for i,v in ipairs(x) do
		if tonumber(v) == tonumber(item) then
			table.remove(x,i)
		end
	end
	return setPlayerStorageTable(cid, info.Storages[1], x)
end
function ShowItemsTabble(cid)
	local n,str = 0,"[+] Auto Loot Commands [+]\n\n!autoloot item name --> To add ou Remove item from list.\n!autoloot money --> To collect gold automatically.\n!autoloot clear --> To clear the list.\n!autoloot on/off --> To enable or disable the collecting of items in the system.\n\n[+] Auto Loot Info [+]\n\nSystem: "..(getPlayerStorageValue(cid, info.Storages[3]) <= 0 and "Activated" or "Disabled")..".\nGold Collecting: "..(getPlayerStorageValue(cid, info.Storages[2]) > 0 and "Activated" or "Disabled")..".\nAutomatic Item Selling: "..(getPlayerStorageValue(cid, info.Storages[4]) > 0 and "Activated" or "Disabled")..".\nBalance Total: ["..getPlayerBalance(cid).."] gp's.\nMaximum Slots: ["..#getPlayerStorageTable(cid, info.Storages[1]).."/"..(vip.hasVip(cid) and info.Max_Slots.premium or info.Max_Slots.free).."]\n\n[+] Auto Loot Slots [+]\n\n"
	for i = 1,#getPlayerStorageTable(cid, info.Storages[1]) do
		n = n + 1
		str = str.."Slot "..n.." - "..getItemNameById(getPlayerStorageTable(cid, info.Storages[1])[i]).."\n"
	end
	return doPlayerPopupFYI(cid, str)
end
function getContainerItems(containeruid)
	local items = {}
	local containers = {}
	if type(getContainerSize(containeruid)) ~= "number" then
		return false
	end
	for slot = 0, getContainerSize(containeruid)-1 do
		local item = getContainerItem(containeruid, slot)
		if item.itemid == 0 then
			break
		end
		if isContainer(item.uid) then
			table.insert(containers, item.uid)
		end
		table.insert(items, item)
	end
	if #containers > 0 then
		for i,x in ipairs(getContainerItems(containers[1])) do
			table.insert(items, x)
		end
		table.remove(containers, 1)
	end
	return items
end
function getItemsInContainerById(container, itemid) -- Function By Kydrai
	local items = {}
	if isContainer(container) and getContainerSize(container) > 0 then
		for slot=0, (getContainerSize(container)-1) do
			local item = getContainerItem(container, slot)
			if isContainer(item.uid) then
				local itemsbag = getItemsInContainerById(item.uid, itemid)
				for i=0, #itemsbag do
					table.insert(items, itemsbag[i])
				end
			else
				if itemid == item.itemid then
					table.insert(items, item.uid)
				end
			end
		end
	end
	return items
end
function doPlayerAddItemStacking(cid, itemid, amount) -- revisado
	local item, _G = getItemsInContainerById(getPlayerSlotItem(cid, 3).uid, itemid), 0
	if #item > 0 then
		for _ ,x in pairs(item) do
			local ret = getThing(x)
			if ret.type < 100 then
				doTransformItem(ret.uid, itemid, ret.type+amount) 
				if ret.type+amount > 100 then
					doPlayerAddItem(cid, itemid, ret.type+amount-100)
				end
				break
			else
				_G = _G+1
			end
		end
		if _G == #item then
			doPlayerAddItem(cid, itemid, amount)
		end
	else
		return doPlayerAddItem(cid, itemid, amount)
	end
end
function AutomaticDeposit(cid,item,n)
	local deposit = item == tonumber(2160) and (n*10000) or tonumber(item) == 2152 and (n*100) or (n*1)
	return doPlayerDepositMoney(cid, deposit)
end
function AutomaticItensSelling(cid, x)
	return doPlayerAddMoney(cid, x) and doPlayerDepositMoney(cid, x)
end
function corpseRetireItems(cid, pos)
	local check = false
	for i = 0, 255 do
		pos.stackpos = i
		tile = getTileThingByPos(pos)
		if tile.uid > 0 and isCorpse(tile.uid) then
			check = true break
		end
	end
	if check == true then
		local items = getContainerItems(tile.uid)
		for i,x in pairs(items) do
			if isInArray(getPlayerStorageTable(cid, info.Storages[1]), tonumber(x.itemid)) or getPlayerStorageValue(cid, info.Storages[2]) > 0 and isInArray({2148,2152,2160},tonumber(x.itemid)) then
				if isItemStackable(x.itemid) then
					if getPlayerStorageValue(cid, info.Storages[4]) > 0 and info.items_price[tonumber(x.itemid)] then
						AutomaticItensSelling(cid, (info.items_price[tonumber(x.itemid)]*x.type))
					else
						doPlayerAddItemStacking(cid, x.itemid, x.type)
						if info.AutomaticDeposit == true and isInArray({2148,2152,2160}, tonumber(x.itemid)) then
							AutomaticDeposit(cid,x.itemid,x.type)
						end
					end
				else
					if getPlayerStorageValue(cid, info.Storages[4]) > 0 and info.items_price[tonumber(x.itemid)] then
						AutomaticItensSelling(cid, info.items_price[tonumber(x.itemid)])
					else
						doPlayerAddItem(cid, x.itemid)
					end
				end
				doRemoveItem(x.uid)
			end
		end
	end
end]]></config>
<event type="login" name="LootLogin" event="script"><![CDATA[
function onLogin(cid)
	registerCreatureEvent(cid, "LootEventKIll")
	if vip.hasVip(cid) and getPlayerStorageValue(cid, 27001) <= 0 then
		setPlayerStorageValue(cid, 27001, 1)
	elseif getPlayerStorageValue(cid, 27001) > 0 and not vip.hasVip(cid) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[Auto Loot] You premium is Over, Start a new list!")
		setPlayerStorageValue(cid, 27001, -1)
		setPlayerStorageValue(cid, info.Storages[1], -1)
	end
	return true
end]]></event>
<event type="kill" name="LootEventKIll" event="script"><![CDATA[
domodlib('Loot_func')
function onKill(cid, target, lastHit) 
	if isPlayer(cid) and getPlayerStorageValue(cid, info.Storages[3]) <= 0 and isMonster(target) and not isInArray(info.BlockMonsters, getCreatureName(target):lower()) then
		addEvent(corpseRetireItems, 0, cid ,getThingPos(target))
	end
	return true
end]]></event>
<talkaction words="!autoloot" event="buffer"><![CDATA[
domodlib('Loot_func')
local param, slots = param:lower(), vip.hasVip(cid) and info.Max_Slots.premium or info.Max_Slots.free
if not param or param == "" then
	ShowItemsTabble(cid) return true
elseif tonumber(param) then
	doPlayerSendCancel(cid, "enter commands: !autoloot item name [+] !autoloot clean [+] !autoloot money [+] !autoloot on/off") return true
elseif isInArray({"clean","limpar", "clear"}, param) then
	setPlayerStorageValue(cid, info.Storages[1], -1)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"[Auto Loot] Your list has been cleaned.") return true
elseif isInArray({"start","stop","on","off"}, param) then
	setPlayerStorageValue(cid, info.Storages[3], getPlayerStorageValue(cid, info.Storages[3]) <= 0 and 1 or 0)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"[Auto Loot] "..(getPlayerStorageValue(cid, info.Storages[3]) > 0 and "Stopped" or "Started")..".") return true
elseif isInArray({"money","gold","gps","dinheiro"}, param) then
	setPlayerStorageValue(cid, info.Storages[2], getPlayerStorageValue(cid, info.Storages[2]) <= 0 and 1 or 0)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"[Auto Loot] Gold Colleting "..(getPlayerStorageValue(cid, info.Storages[2]) > 0 and "Activated" or "disabled")..".") return true
elseif isInArray({"selling","autosell","sell","vender"}, param) then
	setPlayerStorageValue(cid, info.Storages[4], getPlayerStorageValue(cid, info.Storages[4]) <= 0 and 1 or 0)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"[Auto Loot] Automatic Itens Selling "..(getPlayerStorageValue(cid, info.Storages[4]) > 0 and "Activated" or "disabled")..".") return true
end
local item = getItemIdByName(param, false)
if not item then
	doPlayerSendCancel(cid, "This item does not exist.") return true
end
local var = isInTable(cid, item)
if isInArray({2148,2152,2160},item) then 
	doPlayerSendCancel(cid, "Enter !autoloot money to add money in your list!") return true	
elseif isInArray(info.BlockItemsList, item) then
	doPlayerSendCancel(cid, "You can not add this item in the list!") return true
elseif not var and #getPlayerStorageTable(cid, info.Storages[1]) >= slots then
	doPlayerSendCancel(cid, "max "..slots.." from auto loot") return true
end
if not var then
	addItemTable(cid, item)
else
	removeItemTable(cid, item)
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,not var and "you added the item "..param.." in the list" or "you removed the item "..param.." from the list")
return true]]></talkaction>
</mod>

 

 

Em talkactions/scripts crie um arquivo:

 

Spoiler

domodlib('Loot_func') 
function onSay(cid, words, param, channel)
    local list = ""
    for id, price in pairs(info.items_price) do
        list = list .. getItemNameById(id) .. " - [" .. (price/1000) .."] K\n"
    end
    doPlayerPopupFYI(cid, list)
    return true
end   

 

 

Em talkactions.xml:  <talkaction words="!lootlist" event="script" value="NOMEDOSEUARQUIVO.lua"/>

 

 

 

Contato:

 

Link para o post
Compartilhar em outros sites
1 hora atrás, Dwarfer disse:
  Ocultar conteúdo


<?xml version="1.0" encoding="ISO-8859-1"?>
<mod name="Loot System" version="1.0" author="Vodkart And Mkalo" contact="none.com" enabled="yes">
<config name="Loot_func"><![CDATA[
info = {
	AutomaticDeposit = true,
	BlockMonsters = {},
	BlockItemsList = {2123,2515},
	Max_Slots = {free = 2, premium = 5},
	Storages = {27000,28008,28006,28007},
	items_price = {[2498] = 40000,[2523] = 150000, [2656] = 15000,[2195] = 40000,[2520] = 40000,[2492] = 60000, [2466] = 30000,[2646] = 100000,[2470] = 80000, [2522] = 100000, [2472] = 100000, [2514] = 80000, [2645] = 40000, [2528] = 8000}
}
function setPlayerStorageTable(cid, storage, tab)
	local tabstr = "&"
	for i,x in pairs(tab) do
		tabstr = tabstr .. i .. "," .. x .. ";"
	end
	setPlayerStorageValue(cid, storage, tabstr:sub(1, #tabstr-1))
end
function getPlayerStorageTable(cid, storage)
	local tabstr = getPlayerStorageValue(cid, storage)
	local tab = {}
	if type(tabstr) ~= "string" then
		return {}
	end
	if tabstr:sub(1,1) ~= "&" then
		return {}
	end
	local tabstr = tabstr:sub(2, #tabstr)
	local a = string.explode(tabstr, ";")
	for i,x in pairs(a) do
		local b = string.explode(x, ",")
		tab[tonumber(b[1]) or b[1]] = tonumber(b[2]) or b[2]
	end
	return tab
end
function isInTable(cid, item)
	for _,i in pairs(getPlayerStorageTable(cid, info.Storages[1]))do
		if tonumber(i) == tonumber(item) then
			return true
		end
	end
	return false
end
function addItemTable(cid, item)
	local x = {}
	for i = 1,#getPlayerStorageTable(cid, info.Storages[1]) do
		table.insert(x,getPlayerStorageTable(cid, info.Storages[1])[i])
	end
	if x ~= 0 then
		table.insert(x,tonumber(item))
		setPlayerStorageTable(cid, info.Storages[1], x)
	else
		setPlayerStorageTable(cid, info.Storages[1], {item})
	end
end
function removeItemTable(cid, item)
	local x = {}
	for i = 1,#getPlayerStorageTable(cid, info.Storages[1]) do
		table.insert(x,getPlayerStorageTable(cid, info.Storages[1])[i])
	end
	for i,v in ipairs(x) do
		if tonumber(v) == tonumber(item) then
			table.remove(x,i)
		end
	end
	return setPlayerStorageTable(cid, info.Storages[1], x)
end
function ShowItemsTabble(cid)
	local n,str = 0,"[+] Auto Loot Commands [+]\n\n!autoloot item name --> To add ou Remove item from list.\n!autoloot money --> To collect gold automatically.\n!autoloot clear --> To clear the list.\n!autoloot on/off --> To enable or disable the collecting of items in the system.\n\n[+] Auto Loot Info [+]\n\nSystem: "..(getPlayerStorageValue(cid, info.Storages[3]) <= 0 and "Activated" or "Disabled")..".\nGold Collecting: "..(getPlayerStorageValue(cid, info.Storages[2]) > 0 and "Activated" or "Disabled")..".\nAutomatic Item Selling: "..(getPlayerStorageValue(cid, info.Storages[4]) > 0 and "Activated" or "Disabled")..".\nBalance Total: ["..getPlayerBalance(cid).."] gp's.\nMaximum Slots: ["..#getPlayerStorageTable(cid, info.Storages[1]).."/"..(vip.hasVip(cid) and info.Max_Slots.premium or info.Max_Slots.free).."]\n\n[+] Auto Loot Slots [+]\n\n"
	for i = 1,#getPlayerStorageTable(cid, info.Storages[1]) do
		n = n + 1
		str = str.."Slot "..n.." - "..getItemNameById(getPlayerStorageTable(cid, info.Storages[1])[i]).."\n"
	end
	return doPlayerPopupFYI(cid, str)
end
function getContainerItems(containeruid)
	local items = {}
	local containers = {}
	if type(getContainerSize(containeruid)) ~= "number" then
		return false
	end
	for slot = 0, getContainerSize(containeruid)-1 do
		local item = getContainerItem(containeruid, slot)
		if item.itemid == 0 then
			break
		end
		if isContainer(item.uid) then
			table.insert(containers, item.uid)
		end
		table.insert(items, item)
	end
	if #containers > 0 then
		for i,x in ipairs(getContainerItems(containers[1])) do
			table.insert(items, x)
		end
		table.remove(containers, 1)
	end
	return items
end
function getItemsInContainerById(container, itemid) -- Function By Kydrai
	local items = {}
	if isContainer(container) and getContainerSize(container) > 0 then
		for slot=0, (getContainerSize(container)-1) do
			local item = getContainerItem(container, slot)
			if isContainer(item.uid) then
				local itemsbag = getItemsInContainerById(item.uid, itemid)
				for i=0, #itemsbag do
					table.insert(items, itemsbag[i])
				end
			else
				if itemid == item.itemid then
					table.insert(items, item.uid)
				end
			end
		end
	end
	return items
end
function doPlayerAddItemStacking(cid, itemid, amount) -- revisado
	local item, _G = getItemsInContainerById(getPlayerSlotItem(cid, 3).uid, itemid), 0
	if #item > 0 then
		for _ ,x in pairs(item) do
			local ret = getThing(x)
			if ret.type < 100 then
				doTransformItem(ret.uid, itemid, ret.type+amount) 
				if ret.type+amount > 100 then
					doPlayerAddItem(cid, itemid, ret.type+amount-100)
				end
				break
			else
				_G = _G+1
			end
		end
		if _G == #item then
			doPlayerAddItem(cid, itemid, amount)
		end
	else
		return doPlayerAddItem(cid, itemid, amount)
	end
end
function AutomaticDeposit(cid,item,n)
	local deposit = item == tonumber(2160) and (n*10000) or tonumber(item) == 2152 and (n*100) or (n*1)
	return doPlayerDepositMoney(cid, deposit)
end
function AutomaticItensSelling(cid, x)
	return doPlayerAddMoney(cid, x) and doPlayerDepositMoney(cid, x)
end
function corpseRetireItems(cid, pos)
	local check = false
	for i = 0, 255 do
		pos.stackpos = i
		tile = getTileThingByPos(pos)
		if tile.uid > 0 and isCorpse(tile.uid) then
			check = true break
		end
	end
	if check == true then
		local items = getContainerItems(tile.uid)
		for i,x in pairs(items) do
			if isInArray(getPlayerStorageTable(cid, info.Storages[1]), tonumber(x.itemid)) or getPlayerStorageValue(cid, info.Storages[2]) > 0 and isInArray({2148,2152,2160},tonumber(x.itemid)) then
				if isItemStackable(x.itemid) then
					if getPlayerStorageValue(cid, info.Storages[4]) > 0 and info.items_price[tonumber(x.itemid)] then
						AutomaticItensSelling(cid, (info.items_price[tonumber(x.itemid)]*x.type))
					else
						doPlayerAddItemStacking(cid, x.itemid, x.type)
						if info.AutomaticDeposit == true and isInArray({2148,2152,2160}, tonumber(x.itemid)) then
							AutomaticDeposit(cid,x.itemid,x.type)
						end
					end
				else
					if getPlayerStorageValue(cid, info.Storages[4]) > 0 and info.items_price[tonumber(x.itemid)] then
						AutomaticItensSelling(cid, info.items_price[tonumber(x.itemid)])
					else
						doPlayerAddItem(cid, x.itemid)
					end
				end
				doRemoveItem(x.uid)
			end
		end
	end
end]]></config>
<event type="login" name="LootLogin" event="script"><![CDATA[
function onLogin(cid)
	registerCreatureEvent(cid, "LootEventKIll")
	if vip.hasVip(cid) and getPlayerStorageValue(cid, 27001) <= 0 then
		setPlayerStorageValue(cid, 27001, 1)
	elseif getPlayerStorageValue(cid, 27001) > 0 and not vip.hasVip(cid) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[Auto Loot] You premium is Over, Start a new list!")
		setPlayerStorageValue(cid, 27001, -1)
		setPlayerStorageValue(cid, info.Storages[1], -1)
	end
	return true
end]]></event>
<event type="kill" name="LootEventKIll" event="script"><![CDATA[
domodlib('Loot_func')
function onKill(cid, target, lastHit) 
	if isPlayer(cid) and getPlayerStorageValue(cid, info.Storages[3]) <= 0 and isMonster(target) and not isInArray(info.BlockMonsters, getCreatureName(target):lower()) then
		addEvent(corpseRetireItems, 0, cid ,getThingPos(target))
	end
	return true
end]]></event>
<talkaction words="!autoloot" event="buffer"><![CDATA[
domodlib('Loot_func')
local param, slots = param:lower(), vip.hasVip(cid) and info.Max_Slots.premium or info.Max_Slots.free
if not param or param == "" then
	ShowItemsTabble(cid) return true
elseif tonumber(param) then
	doPlayerSendCancel(cid, "enter commands: !autoloot item name [+] !autoloot clean [+] !autoloot money [+] !autoloot on/off") return true
elseif isInArray({"clean","limpar", "clear"}, param) then
	setPlayerStorageValue(cid, info.Storages[1], -1)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"[Auto Loot] Your list has been cleaned.") return true
elseif isInArray({"start","stop","on","off"}, param) then
	setPlayerStorageValue(cid, info.Storages[3], getPlayerStorageValue(cid, info.Storages[3]) <= 0 and 1 or 0)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"[Auto Loot] "..(getPlayerStorageValue(cid, info.Storages[3]) > 0 and "Stopped" or "Started")..".") return true
elseif isInArray({"money","gold","gps","dinheiro"}, param) then
	setPlayerStorageValue(cid, info.Storages[2], getPlayerStorageValue(cid, info.Storages[2]) <= 0 and 1 or 0)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"[Auto Loot] Gold Colleting "..(getPlayerStorageValue(cid, info.Storages[2]) > 0 and "Activated" or "disabled")..".") return true
elseif isInArray({"selling","autosell","sell","vender"}, param) then
	setPlayerStorageValue(cid, info.Storages[4], getPlayerStorageValue(cid, info.Storages[4]) <= 0 and 1 or 0)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"[Auto Loot] Automatic Itens Selling "..(getPlayerStorageValue(cid, info.Storages[4]) > 0 and "Activated" or "disabled")..".") return true
end
local item = getItemIdByName(param, false)
if not item then
	doPlayerSendCancel(cid, "This item does not exist.") return true
end
local var = isInTable(cid, item)
if isInArray({2148,2152,2160},item) then 
	doPlayerSendCancel(cid, "Enter !autoloot money to add money in your list!") return true	
elseif isInArray(info.BlockItemsList, item) then
	doPlayerSendCancel(cid, "You can not add this item in the list!") return true
elseif not var and #getPlayerStorageTable(cid, info.Storages[1]) >= slots then
	doPlayerSendCancel(cid, "max "..slots.." from auto loot") return true
end
if not var then
	addItemTable(cid, item)
else
	removeItemTable(cid, item)
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,not var and "you added the item "..param.." in the list" or "you removed the item "..param.." from the list")
return true]]></talkaction>
</mod>

 

 

Em talkactions/scripts crie um arquivo:

 

  Ocultar conteúdo


domodlib('Loot_func') 
function onSay(cid, words, param, channel)
    local list = ""
    for id, price in pairs(info.items_price) do
        list = list .. getItemNameById(id) .. " - [" .. (price/1000) .."] K\n"
    end
    doPlayerPopupFYI(cid, list)
    return true
end   

 

 

Em talkactions.xml:  <talkaction words="!lootlist" event="script" value="NOMEDOSEUARQUIVO.lua"/>

 

 

 

 

Erro

 

 

Sem título.png

Link para o post
Compartilhar em outros sites

1 - O mod já está adicionado?

2 - A tabela no MOD está igual a que você colocou aí? Ou seja, o nome é "info"? 

 

Se não, obviamente não vai funcionar.

Editado por Dwarfer (veja o histórico de edições)

Contato:

 

Link para o post
Compartilhar em outros sites
37 minutos atrás, Dwarfer disse:

1 - O mod já está adicionado?

2 - A tabela no MOD está igual a que você colocou aí? Ou seja, o nome é "info"? 

 

Se não, obviamente não vai funcionar.

 

 

Sim, fiz tudo isso, não deu aqui, se quiser testa ai e me fala

Link para o post
Compartilhar em outros sites
12 minutos atrás, Dwarfer disse:

 

lZNDMHE.png

 

 

Fiz conforme orientado,  isso funciona em qualquer TFS? Não citei, mas sendo ou não, TFS 0.4.

E a tabela esta como no mod, enfim, é serio, não fiz nada errado aqui,

 

 

 

 

 

Link para o post
Compartilhar em outros sites
15 minutos atrás, Dwarfer disse:

Funciona em tfs 0.4. Copia o script do seu arquivo e manda aqui.

 

Ué, ta igual o que você postou

 

domodlib('Loot_func') 
function onSay(cid, words, param, channel)
    local list = ""
    for id, price in pairs(info.items_price) do
        list = list .. getItemNameById(id) .. " - [" .. (price/1000) .."] K\n"
    end
    doPlayerPopupFYI(cid, list)
    return true
end   

 

A não ser que era para acrescentar algo nele, e eu não sabia kkk

Link para o post
Compartilhar em outros sites
  • Solução

Não tinha que adicionar nada se já estivesse tudo configurado corretamente. Enfim, utilize assim:

 

Spoiler

local items_price = {[2498] = 40000,[2523] = 150000, [2656] = 15000,[2195] = 40000,[2520] = 40000,[2492] = 60000, [2466] = 30000,[2646] = 100000,[2470] = 80000, [2522] = 100000, [2472] = 100000, [2514] = 80000, [2645] = 40000, [2528] = 8000}

function onSay(cid, words, param, channel)
    local list = ""
    for id, price in pairs(items_price) do
        list = list .. getItemNameById(id) .. " - [" .. (price/1000) .."] K\n"
    end
    doPlayerPopupFYI(cid, list)
    return true
end   

 

 

Nesse caso, as alterações que fizer na tabela do mod tem que fazer na tabela items_price deste arquivo também.

Contato:

 

Link para o post
Compartilhar em outros sites
5 minutos atrás, Dwarfer disse:

Não tinha que adicionar nada se já estivesse tudo configurado corretamente. Enfim, utilize assim:

 

  Ocultar conteúdo


local items_price = {[2498] = 40000,[2523] = 150000, [2656] = 15000,[2195] = 40000,[2520] = 40000,[2492] = 60000, [2466] = 30000,[2646] = 100000,[2470] = 80000, [2522] = 100000, [2472] = 100000, [2514] = 80000, [2645] = 40000, [2528] = 8000}

function onSay(cid, words, param, channel)
    local list = ""
    for id, price in pairs(items_price) do
        list = list .. getItemNameById(id) .. " - [" .. (price/1000) .."] K\n"
    end
    doPlayerPopupFYI(cid, list)
    return true
end   

 

 

Nesse caso, as alterações que fizer na tabela do mod tem que fazer na tabela items_price deste arquivo também.

 

Desse jeito funciona, obrigado!

Não tem problema, preguiça é o de menos!

Valeu!

Link para o post
Compartilhar em outros sites

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo