Jump to content

Erro Inventory


Recommended Posts

boa noite, tenho um servidor de mta dayz, e como todos conhecem tem o famoso inventario, porém tem a funcao de pegar item do chao, e a funcao de dropar tudo de uma vez, e a funcao de dropar tudo de uma vez buga quando vou dropar em tendas, quando dropo no chão, vai normal, mas quando dropo tudo de uma vez em tenda, da esse erro abaixo e nao dropa

ERROR: [DayZ-MTA]\DayZ\Client\Inventario.lua:349 "for" limit must be a number

 

-----------S1L3NC3
inventoryItems = {
["Primary Weapon"] = {},
["Secondary Weapon"] = {},
["Specially Weapon"] = {},
["Ammo"] = {},

["Food"] = {
{"Canned Spaghetti (Fechado)",1},
{"Canned Spaghetti (Aberto)",1},
{"Canned Baked Beans (Fechado)",1},
{"Canned Baked Beans (Aberto)",1},
{"Canned Sardines (Fechado)",1},
{"Canned Sardines (Aberto)",1},
{"Can of Tactical Bacon (Fechado)",1},
{"Can of Tactical Bacon (Aberto)",1},

{"Water Bottle",1},
{"Burger",1},
{"Pizza",1},
{"Soda Bottle",1},
{"Milk",1},
{"Cooked Meat",1},
{"Raw Meat",1},
},

["Medic"] = {
{"Antibiotics",1,"Usar"},
{"Bandage",1,"Usar"},
{"Medic Kit",2,"Usar"},
{"Heat Pack",1,"Usar"},
{"Painkiller",1,"Usar"},
{"Blood Bag",1,"Usar"},
{"Morphine",1,"Usar"},
},

["VehicleParts"] = {
{"Engine",5},
{"Tire",2},
{"Tank Parts",3},
{"Scrap Metal",1},
{"Steel Sheet",1},
{"Empty Gas Canister",2},
{"Full Gas Canister",2},
},

["Items"] = {
{"Stinger",3,"Place Stinger"},
{"Wood Pile",2},
{"Roadflare",1,"Place"},
{"Wire Fence",1,"Colocar Wire Fence"},
{"Tent",3,"Pitch a Tent"},
{"Empty Water Bottle",1},
{"Empty Soda Cans",1},
},

["Roupas"] = {
},

["Mochilas"] = {
},

["Toolbelt"] = {
{"Night Vision Goggles",0},
{"Infrared Goggles",0},
{"Map",0},
{"Box of Matches",0,"Make a Fire"},
{"Watch",0},
{"GPS",0,"Set wave"},
{"Toolbox",0},
{"Radio Device",0},

{"Syringe",0},
{"Opener",0},
{"Hose",0},
{"Tire Repair Kit",0},
{"Compass",0},
}}
for i,weaponData in pairs(weaponTable)do
  if weaponData[5] == 1 then
	table.insert(inventoryItems["Primary Weapon"],{weaponData[1],3,weaponData[2],2,weaponData[11]})
  elseif weaponData[5] == 2 then
	if weaponData[2] == "others" then
	  table.insert(inventoryItems["Secondary Weapon"],{weaponData[1],2,weaponData[1],2,weaponData[11]})
	else
	  table.insert(inventoryItems["Secondary Weapon"],{weaponData[1],2,weaponData[2],2,weaponData[11]})
	end
    elseif weaponData[5] == 3 then
	table.insert(inventoryItems["Specially Weapon"],{weaponData[1],1,weaponData[1],1,weaponData[11]})
  end
  if weaponData[2] ~= "others" then
	add = true
	for i,weaponData2 in pairs(inventoryItems["Ammo"])do
	  if weaponData[2] == weaponData2[1] then
		add = false
		inventoryItems["Ammo"][i][5] = inventoryItems["Ammo"][i][5]..";\n"..weaponData[1]
	  end
	end
	if add then
	  table.insert(inventoryItems["Ammo"],{weaponData[2],weaponData[8],"",1,"Munição para:\n"..weaponData[1]})
	end
  end
end
for i,vestData in pairs(VestsTable)do
  table.insert(inventoryItems["Roupas"],{vestData[1],1,"Usar Colete",1,vestData[7]})
end
for i,helmetData in pairs(HelmetsTable)do
  table.insert(inventoryItems["Roupas"],{helmetData[1],1,"Usar Capacete",1,helmetData[7]})
end
for i,bpData in pairs(BackpacksTable)do
  table.insert(inventoryItems["Mochilas"],{bpData[1],1,"Vestir Mochila",1,"Mochila com "..bpData[2].." Slots"})
end

------------------------------------------------------------------------------
--INVENTORY
local headline = {}
local fontnamesv = guiCreateFont("font.ttf", 50)

pname = getPlayerName(getLocalPlayer()):gsub('#%x%x%x%x%x%x',''):gsub('#%x%x%x%x%x%x','')

inv_window = guiCreateWindow(0.15, 0.28, 0.72, 0.63,pname.."' Inventory", true)
guiWindowSetSizable(inv_window, false)
guiSetVisible(inv_window,false)

InvImage = guiCreateStaticImage(0.01,0.03,1.99,100,"images/inventory.png",true,inv_window)
guiSetAlpha(InvImage,1)
guiSetProperty(InvImage,"Disabled","true")

InventoryLabel = guiCreateLabel(0.58, 0.05, 0.39, 0.03, "Inventory", true, inv_window)
guiSetFont(InventoryLabel, "default-bold-small")
guiLabelSetHorizontalAlign(InventoryLabel, "center", false)
LootLabel = guiCreateLabel(0.03, 0.05, 0.39, 0.03, "Gear", true, inv_window)
guiSetFont(LootLabel, "default-bold-small")
guiLabelSetHorizontalAlign(LootLabel, "center", false)
loot_grid = guiCreateGridList(0.03, 0.10, 0.39, 0.83, true, inv_window)
guiGridListSetSortingEnabled(loot_grid,false)
loot_lootcolumn = guiGridListAddColumn(loot_grid,"Loot",0.7)
loot_amountcolumn = guiGridListAddColumn(loot_grid,"Amount",0.2)
inv_itemsgrid = guiCreateGridList(0.58, 0.11, 0.39, 0.83, true, inv_window)
guiGridListSetSortingEnabled(inv_itemsgrid,false)
inv_itemscolumn = guiGridListAddColumn(inv_itemsgrid,"Inventory",0.7)
inv_amountcolumn = guiGridListAddColumn(inv_itemsgrid,"Amount",0.2)
loot_takebutton = guiCreateButton(0.42, 0.19, 0.04, 0.63, "->", true, inv_window)
guiSetFont(loot_takebutton, "default-bold-small")
inv_dropbutton = guiCreateButton(0.54, 0.19, 0.04, 0.63, "<-", true, inv_window)
guiSetFont(inv_dropbutton, "default-bold-small")
inv_slotslabel = guiCreateLabel(0.62, 0.94, 0.29, 0.04, "Slots:", true, inv_window)
guiSetFont(inv_slotslabel, "default-bold-small")
guiLabelSetHorizontalAlign(inv_slotslabel, "center", false)
guiLabelSetVerticalAlign(inv_slotslabel, "center")
loot_amountlabel = guiCreateLabel(0.07, 0.94, 0.29, 0.04, "Empty", true, inv_window)
guiSetFont(loot_amountlabel, "default-bold-small")
guiLabelSetHorizontalAlign(loot_amountlabel, "center", false)
guiLabelSetVerticalAlign(loot_amountlabel, "center")
inv_takeammo = guiCreateButton(0.42, 0.10, 0.04, 0.09, "Take\nAmmo", true,inv_window)
guiSetAlpha(inv_takeammo, 0.63)
guiSetFont(inv_takeammo, "default-bold-small")
guiSetProperty(inv_takeammo, "NormalTextColour", "FF000000")
inv_takeall = guiCreateButton(0.42, 0.82, 0.04, 0.09, ">>", true,inv_window)
guiSetAlpha(inv_takeall, 0.63)
guiSetFont(inv_takeall, "default-bold-small")
guiSetProperty(inv_takeall, "NormalTextColour", "FF000000")
--[[inv_dropall = guiCreateButton(0.54, 0.82, 0.04, 0.09, "<<", true,inv_window)
guiSetAlpha(inv_dropall, 0.63)
guiSetFont(inv_dropall, "default-bold-small")
guiSetProperty(inv_dropall, "NormalTextColour", "FF000000")]]

HideGear = guiCreateCheckBox(0.03,0.05,0.11,0.04,"Hide Gear",true,true,inv_window)
guiSetFont(HideGear,"default-bold-small")


function showInventory(key,keyState)
  hideRightClickInventoryMenu()
  local col = getElementData(getLocalPlayer(),"currentCol")
  local gearName = getElementData(getLocalPlayer(),"lootname")
  refreshLoot(col,gearName)
  if getElementData(getLocalPlayer(),"logedin") and keyState == "down" then
	if guiGetVisible(inv_window) then
	  guiSetVisible(inv_window,false)
	  showCursor(false)
	else
	  guiSetVisible(inv_window,true)
	  showCursor(true)
	  playSound("sounds/Inventory.mp3")
	end
	guiSetVisible(HideGear,false)
	if isPlayerInLoot() then
	  if getElementData(col,"tent") then 
		guiSetVisible(HideGear,true)
		if getElementData(col,"visible") then 
		  guiCheckBoxSetSelected(HideGear,false)
		else
		  guiCheckBoxSetSelected(HideGear,true)
		end
	  end
	end
	refreshInventory()
	if guiGetVisible(inv_window)== true then
	  onClientOpenInventoryStopMenu()
	end
  end
end
bindKey("tab","down",showInventory)

addEventHandler("onClientGUIClick",HideGear,function()
  col = isPlayerInLoot()
  if col then 
	if guiCheckBoxGetSelected(HideGear) then
	  setElementData(col,"visible",false)
	else
	  setElementData(col,"visible",true)
    end
  end
end)

addEventHandler("onClientGUIClick",HideGear,function()
  col = isPlayerInLoot()
  if col then 
	if guiCheckBoxGetSelected(HideGear) then
	  setElementData(col,"visible",false)
	else
	  setElementData(col,"visible",true)
    end
  end
end)

function Debugg()
  setElementData(getLocalPlayer(),"loot",false)
end
addEventHandler("onClientPlayerVehicleEnter",getRootElement(),Debugg)

function hideInventoryManual()
  guiSetVisible(inv_window,false)
  showCursor(false)
  hideRightClickInventoryMenu()
end
addEvent("hideInventoryManual",true)
addEventHandler("hideInventoryManual",getLocalPlayer(),hideInventoryManual)

function refreshInventoryManual()
  refreshInventory()
end
addEvent("refreshInventoryManual",true)
addEventHandler("refreshInventoryManual",getLocalPlayer(),refreshInventoryManual)

function refreshLootManual(loot)
  refreshLoot(loot)
end
addEvent("refreshLootManual",true)
addEventHandler("refreshLootManual",getLocalPlayer(),refreshLootManual)

addEventHandler("onClientGUIClick",inv_takeammo,function()
	if isPlayerInLoot() and loot_lootcolumn then
		local countItem = guiGridListGetRowCount(loot_grid)
		for i = 0, countItem do
			local itemName = guiGridListGetItemText(loot_grid,i,1)
			for id, item in ipairs(inventoryItems["Ammo"]) do
				if itemName == item[1] and getElementData(isPlayerInLoot(),itemName) > 0 and not isToolbeltItem(itemName) then
					if getPlayerCurrentSlots() + getItemSlots(itemName) <= getPlayerMaxAviableSlots() then
						local numbers = getElementData(isPlayerInLoot(),itemName)
						for i = 1, numbers do
							if getPlayerCurrentSlots() + getItemSlots(itemName) <= getPlayerMaxAviableSlots() then
								triggerEvent("onPlayerMoveItemInInventory",getLocalPlayer(),itemName,isPlayerInLoot())
							else
								startRollMessage2("Inventory", "Inventario Cheio!", 255, 22, 0 )
								setTimer(refreshInventory,100,1)
								return
							end	
						end
						refreshButtonLoot()
					else
						startRollMessage2("Inventory", "Inventario Cheio!", 255, 22, 0 )
						setTimer(refreshInventory,100,1)
						return
					end
				end	
			end
		end	
	end
	refreshButtonLoot()
end,false)

addEventHandler("onClientGUIClick",inv_takeall,function()
	local itemName = guiGridListGetItemText(loot_grid,guiGridListGetSelectedItem(loot_grid),1)
	if isPlayerInLoot() then
		if getElementData(isPlayerInLoot(),itemName) and getElementData(isPlayerInLoot(),itemName) >= 1 and not isToolbeltItem(itemName) then
			if getPlayerCurrentSlots() + getItemSlots(itemName) <= getPlayerMaxAviableSlots() then
				local numbers = getElementData(isPlayerInLoot(),itemName)
				for i = 1, numbers do
					if getPlayerCurrentSlots() + getItemSlots(itemName) <= getPlayerMaxAviableSlots() then
						triggerEvent("onPlayerMoveItemInInventory",getLocalPlayer(),itemName,isPlayerInLoot())
					else
						startRollMessage2("Inventory", "Inventario Cheio!", 255, 22, 0 )
						return
					end
					refreshButtonLoot()
				end
			else
				startRollMessage2("Inventory", "Inventario Cheio!", 255, 22, 0 )
				return	
			end
		end
		refreshButtonLoot()
	end
end)

function refreshButtonLoot()
	if isPlayerInLoot() then
		local gearName = guiGetText(LootLabel)
		local col = getElementData(getLocalPlayer(),"currentCol")
		setTimer(refreshInventory,100,1)
		setTimer(refreshLoot,100,1,col,gearName)
	end
end

addEventHandler("onClientGUIClick",inv_dropall,function()
	if playerMovedInInventory then startRollMessage2("Inventory", "", 255, 22, 0 ) return end
	local itemName = guiGridListGetItemText(inv_itemsgrid,guiGridListGetSelectedItem(inv_itemsgrid),1)
	if getElementData(getLocalPlayer(),itemName) and getElementData(getLocalPlayer(),itemName) >= 1 then
		if isPlayerInLoot() then
			local isVehicle = getElementData(isPlayerInLoot(),"vehicle")
			local isTent = getElementData(isPlayerInLoot(),"tent")
			if isVehicle and not isTent then
				if isToolbeltItem(itemName) then
					local numbers = getElementData(isPlayerInLoot(),itemName)
					for i = 1, numbers do
						if getElementData(getLocalPlayer(),itemName) < 1 then return end
						if getLootCurrentSlots(getElementData(getLocalPlayer(),"currentCol")) + getItemSlots(itemName) > getLootMaxAviableSlots(isPlayerInLoot()) then
							startRollMessage2("Inventory", "Inventario Cheio!", 255, 22, 0 )
							return
						end	
						triggerEvent("onPlayerMoveItemOutOFInventory",getLocalPlayer(),itemName,isPlayerInLoot())
					end	
				elseif getLootCurrentSlots(getElementData(getLocalPlayer(),"currentCol")) + getItemSlots(itemName) <= getLootMaxAviableSlots(isPlayerInLoot()) then
					triggerEvent("onPlayerMoveItemOutOFInventory",getLocalPlayer(),itemName,isPlayerInLoot())
				end
			elseif isToolbeltItem(itemName) then
				local numbers = getElementData(isPlayerInLoot(),itemName)
				for i = 1, numbers do
					if getElementData(getLocalPlayer(),itemName) < 1 then return end
					if getLootCurrentSlots(getElementData(getLocalPlayer(),"currentCol")) + getItemSlots(itemName) > getLootMaxAviableSlots(isPlayerInLoot()) then
						startRollMessage2("Inventory", "Inventario Cheio!", 255, 22, 0 )
						return
					end
					triggerEvent("onPlayerMoveItemOutOFInventory",getLocalPlayer(),itemName,isPlayerInLoot())
				end	
			elseif getLootCurrentSlots(getElementData(getLocalPlayer(),"currentCol")) + getItemSlots(itemName) <= getLootMaxAviableSlots(isPlayerInLoot()) then
				local numbers = getElementData(isPlayerInLoot(),itemName)
				for i = 1, numbers do
					if getElementData(getLocalPlayer(),itemName) < 1 then return end
					if getLootCurrentSlots(getElementData(getLocalPlayer(),"currentCol")) + getItemSlots(itemName) > getLootMaxAviableSlots(isPlayerInLoot()) then
						startRollMessage2("Inventory", "Inventario Cheio!", 255, 22, 0 )
						return
					end
					triggerEvent("onPlayerMoveItemOutOFInventory",getLocalPlayer(),itemName,isPlayerInLoot())
				end	
			else
				startRollMessage2("Inventory", "Inventario Cheio!", 255, 22, 0 )
				return
			end	
		else
			local numbers = getElementData(getLocalPlayer(),itemName)
			for i = 1, numbers do
				if getElementData(getLocalPlayer(),itemName) < 1 then return end
				triggerEvent("onPlayerMoveItemOutOFInventory",getLocalPlayer(),itemName,isPlayerInLoot())
			end	
		end	
	end
	local gearName = guiGetText(LootLabel)
	local col = getElementData(getLocalPlayer(),"currentCol")
	setTimer(refreshInventory,100,1)
	if isPlayerInLoot() then
		setTimer(refreshLoot,100,1,col,gearName)
	end
end)

function refreshInventory()
  if(inv_itemscolumn) then
	row1,column1 = guiGridListGetSelectedItem(inv_itemsgrid)
	guiGridListClear(inv_itemsgrid)
	local row = guiGridListAddRow(inv_itemsgrid)
	guiGridListSetItemText(inv_itemsgrid,row,inv_itemscolumn,"- Armas Primárias",true,false)
	for id,item in ipairs(inventoryItems["Primary Weapon"])do
	  if getElementData(getLocalPlayer(),item[1]) and getElementData(getLocalPlayer(),item[1])>= 1 then
		local row = guiGridListAddRow(inv_itemsgrid)
		guiGridListSetItemText(inv_itemsgrid,row,inv_itemscolumn,item[1],false,false)
		guiGridListSetItemText(inv_itemsgrid,row,inv_amountcolumn,getElementData(getLocalPlayer(),item[1]),false,false)
	  if getElementData(getLocalPlayer(),"currentweapon_1") and item[1] == getElementData(getLocalPlayer(),"currentweapon_1") then
		    guiGridListSetItemColor ( inv_itemsgrid, row, inv_itemscolumn,255, 0, 0)
		    guiGridListSetItemColor ( inv_itemsgrid, row, inv_amountcolumn,255, 0, 0)
		    end
	    end
	end
	local row = guiGridListAddRow(inv_itemsgrid)
	guiGridListSetItemText(inv_itemsgrid,row,inv_itemscolumn,"- Armas Secundárias",true,false)
	for id,item in ipairs(inventoryItems["Secondary Weapon"])do
	  if getElementData(getLocalPlayer(),item[1]) and getElementData(getLocalPlayer(),item[1])>= 1 then
		local row = guiGridListAddRow(inv_itemsgrid)
		guiGridListSetItemText(inv_itemsgrid,row,inv_itemscolumn,item[1],false,false)
		guiGridListSetItemText(inv_itemsgrid,row,inv_amountcolumn,getElementData(getLocalPlayer(),item[1]),false,false)
	  if getElementData(getLocalPlayer(),"currentweapon_2") and item[1] == getElementData(getLocalPlayer(),"currentweapon_2") then
		    guiGridListSetItemColor ( inv_itemsgrid, row, inv_itemscolumn,255, 0, 0)
		    guiGridListSetItemColor ( inv_itemsgrid, row, inv_amountcolumn,255, 0, 0)
		    end
	    end
	end
	local row = guiGridListAddRow(inv_itemsgrid)
	guiGridListSetItemText(inv_itemsgrid,row,inv_itemscolumn,"- Armas Especiais",true,false)
	for id,item in ipairs(inventoryItems["Specially Weapon"])do
	  if getElementData(getLocalPlayer(),item[1]) and getElementData(getLocalPlayer(),item[1])>= 1 then
		local row = guiGridListAddRow(inv_itemsgrid)
		guiGridListSetItemText(inv_itemsgrid,row,inv_itemscolumn,item[1],false,false)
		guiGridListSetItemText(inv_itemsgrid,row,inv_amountcolumn,getElementData(getLocalPlayer(),item[1]),false,false)
	 if getElementData(getLocalPlayer(),"currentweapon_3") and item[1] == getElementData(getLocalPlayer(),"currentweapon_3") then
		    guiGridListSetItemColor ( inv_itemsgrid, row, inv_itemscolumn,255, 0, 0)
		    guiGridListSetItemColor ( inv_itemsgrid, row, inv_amountcolumn,255, 0, 0)
		    end
	    end
	end
	local row = guiGridListAddRow(inv_itemsgrid)
	guiGridListSetItemText(inv_itemsgrid,row,inv_itemscolumn,"- Munição",true,false)
	for id,item in ipairs(inventoryItems["Ammo"])do
	  if getElementData(getLocalPlayer(),item[1]) and getElementData(getLocalPlayer(),item[1])>= 1 then
		local row = guiGridListAddRow(inv_itemsgrid)
		guiGridListSetItemText(inv_itemsgrid,row,inv_itemscolumn,item[1],false,false)
		guiGridListSetItemText(inv_itemsgrid,row,inv_amountcolumn,getElementData(getLocalPlayer(),item[1]),false,false)
	  end
	end
	local row = guiGridListAddRow(inv_itemsgrid)
	guiGridListSetItemText(inv_itemsgrid,row,inv_itemscolumn,"- Comida e Bebida",true,false)
	for id,item in ipairs(inventoryItems["Food"])do
	  if getElementData(getLocalPlayer(),item[1]) and getElementData(getLocalPlayer(),item[1])>= 1 then
		local row = guiGridListAddRow(inv_itemsgrid)
		guiGridListSetItemText(inv_itemsgrid,row,inv_itemscolumn,item[1],false,false)
		guiGridListSetItemText(inv_itemsgrid,row,inv_amountcolumn,getElementData(getLocalPlayer(),item[1]),false,false)
	  end
	end
	local row = guiGridListAddRow(inv_itemsgrid)
	guiGridListSetItemText(inv_itemsgrid,row,inv_itemscolumn,"- Suprimentos Médicos",true,false)
	for id,item in ipairs(inventoryItems["Medic"])do
	  if getElementData(getLocalPlayer(),item[1]) and getElementData(getLocalPlayer(),item[1])>= 1 then
		local row = guiGridListAddRow(inv_itemsgrid)
		guiGridListSetItemText(inv_itemsgrid,row,inv_itemscolumn,item[1],false,false)
		guiGridListSetItemText(inv_itemsgrid,row,inv_amountcolumn,getElementData(getLocalPlayer(),item[1]),false,false)
	  end
	end
	local row = guiGridListAddRow(inv_itemsgrid)
	guiGridListSetItemText(inv_itemsgrid,row,inv_itemscolumn,"- Peças de Veículos",true,false)
	for id,item in ipairs(inventoryItems["VehicleParts"])do
	  if getElementData(getLocalPlayer(),item[1]) and getElementData(getLocalPlayer(),item[1])>= 1 then
		local row = guiGridListAddRow(inv_itemsgrid)
		guiGridListSetItemText(inv_itemsgrid,row,inv_itemscolumn,item[1],false,false)
		guiGridListSetItemText(inv_itemsgrid,row,inv_amountcolumn,getElementData(getLocalPlayer(),item[1]),false,false)
	  end
	end
	local row = guiGridListAddRow(inv_itemsgrid)
	guiGridListSetItemText(inv_itemsgrid,row,inv_itemscolumn,"- Itens",true,false)
	for id,item in ipairs(inventoryItems["Items"])do
	  if getElementData(getLocalPlayer(),item[1]) and getElementData(getLocalPlayer(),item[1])>= 1 then
		local row = guiGridListAddRow(inv_itemsgrid)
		guiGridListSetItemText(inv_itemsgrid,row,inv_itemscolumn,item[1],false,false)
		guiGridListSetItemText(inv_itemsgrid,row,inv_amountcolumn,getElementData(getLocalPlayer(),item[1]),false,false)
		 end
	  end
	end
	----- Mochilas e Capacete
	local row = guiGridListAddRow(inv_itemsgrid)
	guiGridListSetItemText(inv_itemsgrid,row,inv_itemscolumn,"- Roupas",true,false)
	for id,item in ipairs(inventoryItems["Roupas"])do
	  if getElementData(getLocalPlayer(),item[1]) and getElementData(getLocalPlayer(),item[1])>= 1 then
		local row = guiGridListAddRow(inv_itemsgrid)
		guiGridListSetItemText(inv_itemsgrid,row,inv_itemscolumn,item[1],false,false)
		guiGridListSetItemText(inv_itemsgrid,row,inv_amountcolumn,getElementData(getLocalPlayer(),item[1]),false,false)
		if getActiveVest(getLocalPlayer()) == item[1] then
		  guiGridListSetItemColor(inv_itemsgrid,row,inv_itemscolumn,255, 0, 0)
		  guiGridListSetItemColor(inv_itemsgrid,row,inv_amountcolumn,255, 0, 0)
		end
		if getActiveHelmet(getLocalPlayer()) == item[1] then
		  guiGridListSetItemColor(inv_itemsgrid,row,inv_itemscolumn,255, 0, 0)
		  guiGridListSetItemColor(inv_itemsgrid,row,inv_amountcolumn,255, 0, 0)
		end
	  end
	end
		local row = guiGridListAddRow(inv_itemsgrid)
	guiGridListSetItemText(inv_itemsgrid,row,inv_itemscolumn,"- Mochilas",true,false)
	for id,item in ipairs(inventoryItems["Mochilas"])do
	  if getElementData(getLocalPlayer(),item[1]) and getElementData(getLocalPlayer(),item[1])>= 1 then
		local row = guiGridListAddRow(inv_itemsgrid)
		guiGridListSetItemText(inv_itemsgrid,row,inv_itemscolumn,item[1],false,false)
		guiGridListSetItemText(inv_itemsgrid,row,inv_amountcolumn,getElementData(getLocalPlayer(),item[1]),false,false)
		for i=1,#BackpacksTable do
		  if item[1] == BackpacksTable[i][1] then
			if BackpacksTable[i][2] == getElementData(getLocalPlayer(),"MAX_Slots") then
			  guiGridListSetItemColor(inv_itemsgrid,row,inv_itemscolumn,255, 0, 0)
			  guiGridListSetItemColor(inv_itemsgrid,row,inv_amountcolumn,255, 0, 0)
			end
		  end
		end
	  end
	end
	local row = guiGridListAddRow(inv_itemsgrid)
	guiGridListSetItemText(inv_itemsgrid,row,inv_itemscolumn,"- Ferramentas",true,false)
	for id,item in ipairs(inventoryItems["Toolbelt"])do
	  if getElementData(getLocalPlayer(),item[1]) and getElementData(getLocalPlayer(),item[1])>= 1 then
		local row = guiGridListAddRow(inv_itemsgrid)
		guiGridListSetItemText(inv_itemsgrid,row,inv_itemscolumn,item[1],false,false)
		guiGridListSetItemText(inv_itemsgrid,row,inv_amountcolumn,getElementData(getLocalPlayer(),item[1]),false,false)
	  end
	end
	if row1 and column1 then
	  guiGridListSetSelectedItem(inv_itemsgrid,row1,column1)
	end
	vestSlots = getActiveVestSlots(getLocalPlayer())
	if vestSlots then
	  guiSetText(inv_slotslabel,"Slots: "..getPlayerCurrentSlots()+vestSlots.."/"..getPlayerMaxAviableSlots().." + "..vestSlots)
	else
	  guiSetText(inv_slotslabel,"Slots: "..getPlayerCurrentSlots().."/"..getPlayerMaxAviableSlots())
	end
  end

function refreshLoot(loot,gearName)
   if loot == false then
	guiGridListClear(loot_grid)
	guiSetText(loot_amountlabel,"Empty")
	guiSetText(LootLabel,"Gear")
	return
  end
  if(loot_lootcolumn) then
	row2,column2 = guiGridListGetSelectedItem(loot_grid)
	guiGridListClear(loot_grid)
	if gearName then
	  guiSetText(LootLabel,gearName)
	end
	local row = guiGridListAddRow(loot_grid)
	guiGridListSetItemText(loot_grid,row,loot_lootcolumn,"- Armas Primárias",true,false)
	for id,item in ipairs(inventoryItems["Primary Weapon"])do
	  if getElementData(loot,item[1]) and getElementData(loot,item[1])>= 1 then
		local row = guiGridListAddRow(loot_grid)
		guiGridListSetItemText(loot_grid,row,loot_lootcolumn,item[1],false,false)
		guiGridListSetItemText(loot_grid,row,loot_amountcolumn,getElementData(loot,item[1]),false,false)
	  end
	end
	local row = guiGridListAddRow(loot_grid)
	guiGridListSetItemText(loot_grid,row,loot_lootcolumn,"- Armas Secundárias",true,false)
	for id,item in ipairs(inventoryItems["Secondary Weapon"])do
	  if getElementData(loot,item[1]) and getElementData(loot,item[1])>= 1 then
		local row = guiGridListAddRow(loot_grid)
		guiGridListSetItemText(loot_grid,row,loot_lootcolumn,item[1],false,false)
		guiGridListSetItemText(loot_grid,row,loot_amountcolumn,getElementData(loot,item[1]),false,false)
	  end
	end
	local row = guiGridListAddRow(loot_grid)
	guiGridListSetItemText(loot_grid,row,loot_lootcolumn,"- Armas Especiais",true,false)
	for id,item in ipairs(inventoryItems["Specially Weapon"])do
	  if getElementData(loot,item[1]) and getElementData(loot,item[1])>= 1 then
		local row = guiGridListAddRow(loot_grid)
		guiGridListSetItemText(loot_grid,row,loot_lootcolumn,item[1],false,false)
		guiGridListSetItemText(loot_grid,row,loot_amountcolumn,getElementData(loot,item[1]),false,false)
	  end
	end
	local row = guiGridListAddRow(loot_grid)
	guiGridListSetItemText(loot_grid,row,loot_lootcolumn,"- Munição",true,false)
	for id,item in ipairs(inventoryItems["Ammo"])do
	  if getElementData(loot,item[1]) and getElementData(loot,item[1])>= 1 then
		local row = guiGridListAddRow(loot_grid)
		guiGridListSetItemText(loot_grid,row,loot_lootcolumn,item[1],false,false)
		guiGridListSetItemText(loot_grid,row,loot_amountcolumn,getElementData(loot,item[1]),false,false)
	  end
	end
	local row = guiGridListAddRow(loot_grid)
	guiGridListSetItemText(loot_grid,row,loot_lootcolumn,"- Comida e Bebida",true,false)
	for id,item in ipairs(inventoryItems["Food"])do
	  if getElementData(loot,item[1]) and getElementData(loot,item[1])>= 1 then
		local row = guiGridListAddRow(loot_grid)
		guiGridListSetItemText(loot_grid,row,loot_lootcolumn,item[1],false,false)
		guiGridListSetItemText(loot_grid,row,loot_amountcolumn,getElementData(loot,item[1]),false,false)
	  end
	end
	local row = guiGridListAddRow(loot_grid)
	guiGridListSetItemText(loot_grid,row,loot_lootcolumn,"- Suprimentos Médicos",true,false)
	for id,item in ipairs(inventoryItems["Medic"])do
	  if getElementData(loot,item[1]) and getElementData(loot,item[1])>= 1 then
		local row = guiGridListAddRow(loot_grid)
		guiGridListSetItemText(loot_grid,row,loot_lootcolumn,item[1],false,false)
		guiGridListSetItemText(loot_grid,row,loot_amountcolumn,getElementData(loot,item[1]),false,false)
	  end
	end
	local row = guiGridListAddRow(loot_grid)
	guiGridListSetItemText(loot_grid,row,loot_lootcolumn,"- Peças de Veículos",true,false)
	for id,item in ipairs(inventoryItems["VehicleParts"])do
	  if getElementData(loot,item[1]) and getElementData(loot,item[1])>= 1 then
		local row = guiGridListAddRow(loot_grid)
		guiGridListSetItemText(loot_grid,row,loot_lootcolumn,item[1],false,false)
		guiGridListSetItemText(loot_grid,row,loot_amountcolumn,getElementData(loot,item[1]),false,false)
	  end
	end
	local row = guiGridListAddRow(loot_grid)
	guiGridListSetItemText(loot_grid,row,loot_lootcolumn,"- Itens",true,false)
	for id,item in ipairs(inventoryItems["Items"])do
	  if getElementData(loot,item[1]) and getElementData(loot,item[1])>= 1 then
		local row = guiGridListAddRow(loot_grid)
		guiGridListSetItemText(loot_grid,row,loot_lootcolumn,item[1],false,false)
		guiGridListSetItemText(loot_grid,row,loot_amountcolumn,getElementData(loot,item[1]),false,false)
	  end
	end
		local row = guiGridListAddRow(loot_grid)
	guiGridListSetItemText(loot_grid,row,loot_lootcolumn,"- Roupas",true,false)
	for id,item in ipairs(inventoryItems["Roupas"])do
	  if getElementData(loot,item[1]) and getElementData(loot,item[1])>= 1 then
		local row = guiGridListAddRow(loot_grid)
		guiGridListSetItemText(loot_grid,row,loot_lootcolumn,item[1],false,false)
		guiGridListSetItemText(loot_grid,row,loot_amountcolumn,getElementData(loot,item[1]),false,false)
	  end
	end
		local row = guiGridListAddRow(loot_grid)
	guiGridListSetItemText(loot_grid,row,loot_lootcolumn,"- Mochilas",true,false)
	for id,item in ipairs(inventoryItems["Mochilas"])do
	  if getElementData(loot,item[1]) and getElementData(loot,item[1])>= 1 then
		local row = guiGridListAddRow(loot_grid)
		guiGridListSetItemText(loot_grid,row,loot_lootcolumn,item[1],false,false)
		guiGridListSetItemText(loot_grid,row,loot_amountcolumn,getElementData(loot,item[1]),false,false)
	  end
	end
	local row = guiGridListAddRow(loot_grid)
	guiGridListSetItemText(loot_grid,row,loot_lootcolumn,"- Ferramentas",true,false)
	for id,item in ipairs(inventoryItems["Toolbelt"])do
	  if getElementData(loot,item[1]) and getElementData(loot,item[1])>= 1 then
		local row = guiGridListAddRow(loot_grid)
		guiGridListSetItemText(loot_grid,row,loot_lootcolumn,item[1],false,false)
		guiGridListSetItemText(loot_grid,row,loot_amountcolumn,getElementData(loot,item[1]),false,false)
	  end
	end
	if row2 and column2 then
	  guiGridListSetSelectedItem(loot_grid,row2,column2)
	end
	guiSetText(loot_amountlabel,"Slots: "..getLootCurrentSlots(loot).."/"..(getLootMaxAviableSlots(loot)or 0))
  end
end

function getPlayerMaxAviableSlots()
  return getElementData(getLocalPlayer(),"MAX_Slots")
end

function getLootMaxAviableSlots(loot)
  return getElementData(loot,"MAX_Slots")
end

function getPlayerCurrentSlots()
  local current_SLOTS = 0
  for _,category in pairs(inventoryItems)do
	for id,item in pairs(category)do
	  if getElementData(getLocalPlayer(),item[1]) and getElementData(getLocalPlayer(),item[1])>= 1 then
		current_SLOTS = current_SLOTS + item[2]*getElementData(getLocalPlayer(),item[1])
	  end
	end
  end
  if getActiveVest(getLocalPlayer()) then
	current_SLOTS = current_SLOTS - getActiveVestSlots(getLocalPlayer())
  end
  if isWeaponEquiped(1) then
	current_SLOTS = current_SLOTS - 3
  end
  if isWeaponEquiped(2) then
	current_SLOTS = current_SLOTS - 2
  end
  if isWeaponEquiped(3) then
	current_SLOTS = current_SLOTS - 1
  end
  if isWeaponEquiped(4) then
	current_SLOTS = current_SLOTS - 2
  end
  return math.floor(current_SLOTS)
end

function getLootCurrentSlots(loot)
  local current_SLOTS = 0
  for _,category in pairs(inventoryItems)do
	for id,item in pairs(category)do
	  if getElementData(loot,item[1]) and getElementData(loot,item[1])>= 1 then
		current_SLOTS = current_SLOTS + item[2]*getElementData(loot,item[1])
	  end
	end
  end
  return math.floor(current_SLOTS)
end

function getItemSlots(ItemName)
  for _,category in pairs(inventoryItems)do
	for id,item in pairs(category)do
	  if ItemName == item[1] then 
		return item[2]
	  end
	end
  end
  return false
end

function isToolbeltItem(ItemName)
  for id,item in ipairs(inventoryItems["Toolbelt"])do
	if ItemName == item[1] then 
	  return true
	end
  end 
  return false
end

function getItemInfo(ItemName)
  for _,category in pairs(inventoryItems)do
	for id,item in pairs(category)do
	  if ItemName == item[1] then 
		return item[5]
	  end
	end
  end
  return false
end

function onPlayerMoveItemOutOfInventory ()
if playerMovedInInventory then startRollMessage2("Inventory", "Abusing exploits will result in a ban!", 255, 22, 0 ) return end -- [ID:0000005 - Several grammar + spelling mistakes and typos] //L
local itemName = guiGridListGetItemText(inv_itemsgrid,guiGridListGetSelectedItem(inv_itemsgrid),1)
    if getElementData(getLocalPlayer(),itemName) and getElementData(getLocalPlayer(),itemName) >= 1 then
        if isPlayerInLoot() then
            local isVehicle = getElementData(isPlayerInLoot(),"vehicle")
            local isTent = getElementData(isPlayerInLoot(),"tent")
            if isVehicle and not isTent then
                local veh = getElementData(isPlayerInLoot(),"parent")
                local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
                if itemName == "BUGADO" and (getElementData(isPlayerInLoot(),"Tire_inVehicle") or 0) < tires  or 
                   itemName == "BUGADO" and (getElementData(isPlayerInLoot(),"Engine_inVehicle") or 0)  < engine or 
                   itemName == "BUGADO" and (getElementData(isPlayerInLoot(),"Parts_inVehicle") or 0)  < parts then
                if itemName == "BUGADO" then
                   itemName = "BUGADO"
                end
                    triggerEvent("onPlayerMoveItemOutOFInventory",getLocalPlayer(),itemName.."_inVehicle",isPlayerInLoot())
                    playerMovedInInventory = true
                    setTimer(function()
                        playerMovedInInventory = false
                    end,700,1)
                elseif isToolbeltItem(itemName) then
                    triggerEvent("onPlayerMoveItemOutOFInventory",getLocalPlayer(),itemName,isPlayerInLoot())
                    playerMovedInInventory = true
                    setTimer(function()
                        playerMovedInInventory = false
                    end,700,1)
                elseif getLootCurrentSlots(getElementData(getLocalPlayer(),"currentCol")) + getItemSlots(itemName) <= getLootMaxAviableSlots(isPlayerInLoot()) then
                    triggerEvent("onPlayerMoveItemOutOFInventory",getLocalPlayer(),itemName,isPlayerInLoot())
                    playerMovedInInventory = true
                    setTimer(function()
                        playerMovedInInventory = false
                    end,700,1)
                else
                    startRollMessage2("Inventory", "Inventário Cheio!", 255, 22, 0 ) -- [ID:0000005 - Several grammar + spelling mistakes and typos] //L
                    return
                end
            elseif isToolbeltItem(itemName) then
                    triggerEvent("onPlayerMoveItemOutOFInventory",getLocalPlayer(),itemName,isPlayerInLoot())   
                    playerMovedInInventory = true
                    setTimer(function()
                        playerMovedInInventory = false
                    end,700,1)
            elseif getLootCurrentSlots(getElementData(getLocalPlayer(),"currentCol")) + getItemSlots(itemName) <= getLootMaxAviableSlots(isPlayerInLoot()) then
                triggerEvent("onPlayerMoveItemOutOFInventory",getLocalPlayer(),itemName,isPlayerInLoot())
                playerMovedInInventory = true
                    setTimer(function()
                    playerMovedInInventory = false
                end,700,1)
            else
                startRollMessage2("Inventory", "Inventário Cheio!", 255, 22, 0 ) -- [ID:0000005 - Several grammar + spelling mistakes and typos] //L
                return
            end 
        else
            triggerEvent("onPlayerMoveItemOutOFInventory",getLocalPlayer(),itemName,isPlayerInLoot())
            playerMovedInInventory = true
            setTimer(function()
                playerMovedInInventory = false
            end,700,1)
        end 
    end
    local gearName = guiGetText(LootLabel)
    local col = getElementData(getLocalPlayer(),"currentCol")
    setTimer(refreshInventory,200,2)
    if isPlayerInLoot() then
        setTimer(refreshLoot,200,2,col,gearName)
    end
end
addEventHandler ( "onClientGUIClick", inv_dropbutton, onPlayerMoveItemOutOfInventory )

function onPlayerMoveItemOutOFInventory(itemName,loot)
  keyState = getKeyState("lalt")
  itemPlus = getAmmoPlus(itemName)
  for i,weaponData in pairs(weaponTable)do
	if weaponData[1] == itemName then
	  triggerServerEvent("removeBackWeaponOnDrop",getLocalPlayer())
	end
  end
  if loot and not getElementData(loot,"itemloot") and getElementType(getElementData(loot,"parent"))== "vehicle" and itemName == "BUGADO" then
	engine,tires,parts,rotor,glass,slots,fuel,fuelpm = getVehicleAddonInfos(getElementModel(getElementData(loot,"parent")))
	if getElementData(loot,"fuel")+ 20 < fuel then
	  addingfuel = 20
	elseif getElementData(loot,"fuel")+ 20 > fuel + 15 then
	  triggerEvent("displayClientInfo",getLocalPlayer(),"Vehicle","O tanque de combustivel está 100% cheio",255,22,0)
	  return
	else
	  addingfuel = fuel - getElementData(loot,"fuel")
	end
	setElementData(loot,"fuel",getElementData(loot,"fuel")+ addingfuel)
	setElementData(getLocalPlayer(),itemName,getElementData(getLocalPlayer(),itemName)- itemPlus)
	setElementData(getLocalPlayer(),"BUGADO",(getElementData(getLocalPlayer(),"BUGADO")or 0)+ itemPlus)
	triggerEvent("displayClientInfo",getLocalPlayer(),"Vehicle","Você abasteceu alguns litros de combustivel no veículo!",22,255,0)
	x,y,z = getElementPosition(getLocalPlayer())
	setSoundMaxDistance(playSound3D("sounds/Refuel.mp3",x,y,z),15)
	return
  end
  if getActiveVest(getLocalPlayer()) == itemName and getElementData(getLocalPlayer(),itemName) == 1 then
	startRollMessage2("Inventory","You can't drop your current vest!",255,22,0)
	return
  end
  if getActiveHelmet(getLocalPlayer()) == itemName and getElementData(getLocalPlayer(),itemName) == 1 then
	startRollMessage2("Inventory","You can't drop your current helmet!",255,22,0)
	return
  end
  if (getElementData(getLocalPlayer(),"wearingBackpack") == itemName) and (getElementData(getLocalPlayer(),getElementData(getLocalPlayer(),"wearingBackpack")) == 1) then
	startRollMessage2("Inventory","You can't drop your current backpack!",255,22,0)
	return true
  end
  if itemPlus > (getElementData(getLocalPlayer(),itemName) or 0) then
	itemPlus = getElementData(getLocalPlayer(),itemName) or 1
  end
  if loot then
	avaliableSlotss = getLootMaxAviableSlots(loot) - getLootCurrentSlots(loot)
	if keyState then
	  movingg = math.floor(avaliableSlotss/getItemSlots(itemName))
	  if movingg > getElementData(getLocalPlayer(),itemName) then
		movingg = getElementData(getLocalPlayer(),itemName)
	  end
	  setElementData(loot,itemName,(getElementData(loot,itemName)or 0)+ movingg)
	else
	  setElementData(loot,itemName,(getElementData(loot,itemName)or 0)+ itemPlus)
	end
	local players = getElementsWithinColShape(loot,"player")
	if #players > 1 then
	  triggerServerEvent("onPlayerChangeLoot",getRootElement(),loot)
	end
  else
	triggerServerEvent("playerDropAItem",getLocalPlayer(),itemName,itemPlus)
	setElementData(getLocalPlayer(),itemName,getElementData(getLocalPlayer(),itemName)- itemPlus)
	return
  end
  if itemName == "Tire_inVehicle" then
	itemName = "BUGADO"
  end
  if itemName == "Engine_inVehicle" then
	itemName = "BUGADO"
  end
  if itemName == "Parts_inVehicle" then
	itemName = "BUGADO"
  end
  if keyState then
	setElementData(getLocalPlayer(),itemName,getElementData(getLocalPlayer(),itemName)- movingg)
  else
	setElementData(getLocalPlayer(),itemName,getElementData(getLocalPlayer(),itemName)- itemPlus)
  end
  if loot and getElementData(loot,"itemloot") then
	triggerServerEvent("refre:~emLoot",getRootElement(),loot,getElementData(loot,"parent"))
  end
end
addEvent("onPlayerMoveItemOutOFInventory",true)
addEventHandler("onPlayerMoveItemOutOFInventory",getRootElement(),onPlayerMoveItemOutOFInventory)

function onPlayerMoveItemInInventory ()
local itemName = guiGridListGetItemText(loot_grid,guiGridListGetSelectedItem(loot_grid),1)
if isPlayerInLoot() then
    if getElementData(isPlayerInLoot(),itemName) and getElementData(isPlayerInLoot(),itemName) >= 1 then
        if not isToolbeltItem(itemName) then
            if getPlayerCurrentSlots() + getItemSlots(itemName) <= getPlayerMaxAviableSlots() then
                if not playerMovedInInventory then
                    triggerEvent("onPlayerMoveItemInInventory",getLocalPlayer(),itemName,isPlayerInLoot())
                    playerMovedInInventory = true
                    setTimer(function()
                        playerMovedInInventory = false
                    end,700,1)
                else
                    startRollMessage2("Inventory", "Abusing exploits will result in a ban!", 255, 22, 0 ) -- [ID:0000005 - Several grammar + spelling mistakes and typos] //L
                    return
                end 
            else
                startRollMessage2("Inventory", "Inventory is full!", 255, 22, 0 ) -- [ID:0000005 - Several grammar + spelling mistakes and typos] //L
                return
            end
        else
            playerMovedInInventory = true
            setTimer(function()
                playerMovedInInventory = false
            end,700,1)
            triggerEvent("onPlayerMoveItemInInventory",getLocalPlayer(),itemName,isPlayerInLoot())
        end
    end
    if isPlayerInLoot() then
        local gearName = guiGetText(LootLabel)
        local col = getElementData(getLocalPlayer(),"currentCol")
        setTimer(refreshInventory,200,2)
        setTimer(refreshLoot,200,2,col,gearName)
    end
end 
end
addEventHandler ( "onClientGUIClick", loot_takebutton, onPlayerMoveItemInInventory )


function onPlayerMoveItemInInventory(itemName,loot)
  itemPlus = getAmmoPlus(itemName)
  if loot then
	if itemPlus > (getElementData(loot,itemName)or 0) then
	  itemPlus = getElementData(loot,itemName) or 1
	end
	local avaliableSlotss = getPlayerMaxAviableSlots() - getPlayerCurrentSlots()
	if keyState then
	  movingg = math.floor(avaliableSlotss/getItemSlots(itemName))
	  if movingg > getElementData(loot,itemName) then
		movingg = getElementData(loot,itemName)
	  end
	  setElementData(getLocalPlayer(),itemName,(getElementData(getLocalPlayer(),itemName)or 0)+ movingg)
	else
	  setElementData(getLocalPlayer(),itemName,(getElementData(getLocalPlayer(),itemName)or 0)+ itemPlus)
	end
	if itemPlus > 0 then
	  if keyState then
		setElementData(loot,itemName,(getElementData(loot,itemName)or 0)- movingg)
	  else
		setElementData(loot,itemName,getElementData(loot,itemName)- itemPlus)
	  end
	end
	local players = getElementsWithinColShape(loot,"player")
	if #players > 1 then
	  triggerServerEvent("onPlayerChangeLoot",getRootElement(),loot)
	end
	if getElementData(loot,"itemloot") then
	  triggerServerEvent("refre:~emLoot",getRootElement(),loot,getElementData(loot,"parent"))
	end
  end
end
addEvent("onPlayerMoveItemInInventory",true)
addEventHandler("onPlayerMoveItemInInventory",getRootElement(),onPlayerMoveItemInInventory)

function onClientOpenInventoryStopMenu()
  triggerEvent("disableMenu",getLocalPlayer())
end

function isPlayerInLoot()
  if getElementData(getLocalPlayer(),"loot") then
	return getElementData(getLocalPlayer(),"currentCol")
  end
  return false
end


------------------------------------------------------------------------------
--right-click menu
function onPlayerPressRightKeyInInventory()
  local itemName = guiGridListGetItemText ( inv_itemsgrid, guiGridListGetSelectedItem ( inv_itemsgrid ), 1 )	
	local itemName,itemInfo = getInventoryInfosForRightClickMenu(itemName)	

  if isCursorShowing() and guiGetVisible(inv_window) and itemInfo then
	if itemName == "Box of Matches" then
	  if getElementData(getLocalPlayer(),"Wood Pile")== 0 then 
		return
	  end
	end
	if itemName == "Bandage" then
	  if getElementData(getLocalPlayer(),"bleeding")== 0 then
		return
	  end
	end
	if itemName == "Antibiotics" and not getElementData(getLocalPlayer(),"infection") then
	  return
	end
	if itemName == "Medic Kit" then
	  if getElementData(getLocalPlayer(),"blood")> 10500 then
		return
	  end
	end

	if itemName == "Heat Pack" then
	  if getElementData(getLocalPlayer(),"temperature")> 35 then
		return
	  end
	end
	if itemName == "Painkiller" then
	  if not getElementData(getLocalPlayer(),"pain") then
		return
	  end
	end
	if itemName == "Stinger" or itemName == "Trap" then
	  if getPedOccupiedVehicle(getLocalPlayer()) then
		return
	  end
	end
	if itemName == "Canned Spaghetti (Fechado)" or itemName == "Canned Baked Beans (Fechado)" or itemName == "Can of Tactical Bacon (Fechado)" or itemName == "Canned Sardines (Fechado)" then
	  if getElementData(getLocalPlayer(),"Opener") == 0 then
		return
	  end
	end
	if itemName == "Morphine" then
	  if not getElementData(getLocalPlayer(),"brokenbone") then
		return
	  end
	end
	if itemName == "Blood Bag" then
	  return
	end
	if itemName == getElementData(getLocalPlayer(),"wearingBackpack") then
	  itemInfo = "Remover Mochila"
	end
	if itemName == getActiveVest(getLocalPlayer()) then
	  itemInfo = "Remover Colete"
	end
	if itemName == getActiveHelmet(getLocalPlayer()) then
	  itemInfo = "Remover Capacete"
	end
	playerUseItem(itemName,itemInfo)
  end
end
--bindKey("mouse2","down",onPlayerPressRightKeyInInventory)
addEventHandler("onClientGUIDoubleClick",inv_itemsgrid,onPlayerPressRightKeyInInventory,false)

function getInventoryInfosForRightClickMenu(itemName)
  for i,itemInfo in ipairs(inventoryItems["Primary Weapon"])do
	if itemName == itemInfo[1] then
	  return itemName,"Equipar Arma Primária"
	end
  end
  for i,itemInfo in ipairs(inventoryItems["Secondary Weapon"])do
	if itemName == itemInfo[1] then
	  return itemName,"Equipar Arma Secundária"
	end
  end
  for i,itemInfo in ipairs(inventoryItems["Specially Weapon"])do
	if itemName == itemInfo[1] then
	  return itemName,"Equipar Arma Especial"
	end
  end
  for i,itemInfo in ipairs(inventoryItems["Ammo"])do
	if itemName == itemInfo[1] then
	  return itemName,false
	end
  end
  for i,itemInfo in ipairs(inventoryItems["Food"])do
	if itemName == itemInfo[1] then
	  if itemInfo[1] == "Water Bottle" or itemInfo[1] == "Milk" or itemInfo[1] == "Soda Bottle" then
		info = "Beber"
	  elseif itemInfo[1] == "Canned Baked Beans (Fechado)" or itemInfo[1] == "Canned Spaghetti (Fechado)" or itemInfo[1] == "Canned Sardines (Fechado)" or itemInfo[1] == "Can of Tactical Bacon (Fechado)" then
		info = "Abrir"
	  else
		info = "Comer"
	  end
	  return itemName,info
	end
  end
  for i,itemInfo in ipairs(inventoryItems["Items"])do
	if itemName == itemInfo[1] then
	  return itemName,itemInfo[3] or false
	end
  end
   for i,itemInfo in ipairs(inventoryItems["Roupas"])do
	if itemName == itemInfo[1] then
	  return itemName,itemInfo[3] or false
	end
  end
   for i,itemInfo in ipairs(inventoryItems["Mochilas"])do
	if itemName == itemInfo[1] then
	  return itemName,itemInfo[3] or false
	end
  end
  for i,itemInfo in ipairs(inventoryItems["Medic"])do
	if itemName == itemInfo[1] then
	  return itemName,itemInfo[3] or false
	end
  end
  for i,itemInfo in ipairs(inventoryItems["VehicleParts"])do
	if itemName == itemInfo[1] then
	  return itemName,itemInfo[3] or false
	end
  end
  for i,itemInfo in ipairs(inventoryItems["Toolbelt"])do
	if itemName == itemInfo[1] then
	  return itemName,itemInfo[3] or false
	end
  end
end

------------------------------ RightClickMenu 1 ------------------------------
rightclickWindow = guiCreateStaticImage(0,0,0.05,0.0215,"images/scrollmenu_1.png",true)
headline["rightclickmenu"] = guiCreateLabel(0,0,1,1,"",true,rightclickWindow)
guiLabelSetHorizontalAlign (headline["rightclickmenu"],"center")
guiLabelSetVerticalAlign (headline["rightclickmenu"],"center")
guiSetFont (headline["rightclickmenu"], "default-bold-small" )
guiSetVisible(rightclickWindow,false)

function hideRightClickInventoryMenu()
  guiSetVisible(rightclickWindow,false)
end
------------------------------ RightClickMenu 1 ------------------------------

function onPlayerClickOnRightClickMenu (button,state)
    if button == "left" then
        local itemName,itemInfo = getElementData(rightclickWindow,"iteminfo")[1],getElementData(rightclickWindow,"iteminfo")[2]
		hideRightClickInventoryMenu ()
		playerUseItem(itemName,itemInfo)
    end
end
addEventHandler("onClientGUIClick",headline["rightclickmenu"],onPlayerClickOnRightClickMenu,false)

function playerUseItem(itemName,itemInfo)
  if itemInfo == "Beber" then
	refreshInventory()
    triggerEvent("hideInventoryManual",localPlayer)
	x,y,z = getElementPosition(getLocalPlayer())
	setSoundMaxDistance(playSound3D("sounds/Drink.mp3",x,y,z),15)
	triggerServerEvent("onPlayerRequestChangingStats",getLocalPlayer(),itemName,itemInfo,"thirst")
  elseif itemInfo == "Comer" then
	refreshInventory()
    triggerEvent("hideInventoryManual",localPlayer)
	x,y,z = getElementPosition(getLocalPlayer())
	setSoundMaxDistance(playSound3D("sounds/Eat.mp3",x,y,z),15)
	triggerServerEvent("onPlayerRequestChangingStats",getLocalPlayer(),itemName,itemInfo,"food")
  elseif itemInfo == "Abrir" then
	hideInventoryManual()
	setPedAnimation(getLocalPlayer(),"BOMBER","BOM_Plant",-1,false,false,false,false)
	triggerServerEvent("onPlayerOpenFood",getLocalPlayer(),itemName)
  elseif itemInfo == "Usar skin" then
	refreshInventory()
    triggerEvent("hideInventoryManual",localPlayer)
	triggerServerEvent("onPlayerChangeSkin",getLocalPlayer(),itemName)
  elseif itemName == "Empty Water Bottle" then
	refreshInventory()
    triggerEvent("hideInventoryManual",localPlayer)
	triggerServerEvent("onPlayerRefillWaterBottle",getLocalPlayer(),itemName)
  elseif itemInfo == "Set Rate" then
	guiSetVisible(SetGPSRateWindow,true)
  elseif itemName == "Tent" then
   refreshInventory()
    triggerEvent("hideInventoryManual",localPlayer)
	triggerServerEvent("onPlayerPitchATent",getLocalPlayer(),itemName)
  elseif itemInfo == "Colocar Wire Fence" then
	refreshInventory()
    triggerEvent("hideInventoryManual",localPlayer)
	triggerServerEvent("onPlayerBuildAWireFence",getLocalPlayer(),itemName)
  elseif itemName == "Roadflare" then
	refreshInventory()
    triggerEvent("hideInventoryManual",localPlayer)
	triggerServerEvent("onPlayerPlaceRoadflare",getLocalPlayer(),itemName)
  elseif itemInfo == "Make a Fire" then
	refreshInventory()
    triggerEvent("hideInventoryManual",localPlayer)
	triggerServerEvent("onPlayerMakeAFire",getLocalPlayer(),itemName)
  elseif itemName == "Morphine" then
	refreshInventory()
    triggerEvent("hideInventoryManual",localPlayer)
	x,y,z = getElementPosition(getLocalPlayer())
	setSoundMaxDistance(playSound3D("sounds/Morphine.mp3",x,y,z),15)
	triggerServerEvent("onPlayerUseMedicObject",getLocalPlayer(),itemName)
  elseif itemName == "Medic Kit" then
	refreshInventory()
    triggerEvent("hideInventoryManual",localPlayer)
	x,y,z = getElementPosition(getLocalPlayer())
	setSoundMaxDistance(playSound3D("sounds/MedicKit.mp3",x,y,z),15)
	triggerServerEvent("onPlayerUseMedicObject",getLocalPlayer(),itemName)
  elseif itemName == "Painkiller" then
	refreshInventory()
    triggerEvent("hideInventoryManual",localPlayer)
	x,y,z = getElementPosition(getLocalPlayer())
	setSoundMaxDistance(playSound3D("sounds/Painkiller.mp3",x,y,z),15)
	triggerServerEvent("onPlayerUseMedicObject",getLocalPlayer(),itemName)
  elseif itemName == "Bandage" then
	refreshInventory()
    triggerEvent("hideInventoryManual",localPlayer)
	x,y,z = getElementPosition(getLocalPlayer())
	setSoundMaxDistance(playSound3D("sounds/Bandage.mp3",x,y,z),15)
	triggerServerEvent("onPlayerUseMedicObject",getLocalPlayer(),itemName)
  elseif itemInfo == "Usar" then
	refreshInventory()
    triggerEvent("hideInventoryManual",localPlayer)
	triggerServerEvent("onPlayerUseMedicObject",getLocalPlayer(),itemName)
  elseif itemInfo == "Equipar Arma Primária" then 
	refreshInventory()
    triggerEvent("hideInventoryManual",localPlayer)
  	playSound("sounds/equip1.mp3")
	triggerServerEvent("onPlayerRearmWeapon",getLocalPlayer(),itemName,1)
  elseif itemInfo == "Equipar Arma Secundária" then
	refreshInventory()
    triggerEvent("hideInventoryManual",localPlayer)
  	playSound("sounds/equip2.mp3")
	triggerServerEvent("onPlayerRearmWeapon",getLocalPlayer(),itemName,2)
  elseif itemInfo == "Equipar Arma Especial" then
	refreshInventory()
    triggerEvent("hideInventoryManual",localPlayer)
  	playSound("sounds/equip3.mp3")
	triggerServerEvent("onPlayerRearmWeapon",getLocalPlayer(),itemName,3)
  elseif itemInfo == "Equipar Pistola" then
	refreshInventory()
    triggerEvent("hideInventoryManual",localPlayer)
  	playSound("sounds/equip2.mp3")
	triggerServerEvent("onPlayerRearmWeapon",getLocalPlayer(),itemName,4)
	elseif itemInfo == "Set Rate" then
	    hideInventoryManual()
        guiSetVisible(GUIEditor.window[1],not guiGetVisible(GUIEditor.window[1]))
		showCursor(not isCursorShowing())
  elseif itemInfo == "Place Stinger" then
	setElementData(localPlayer,"Stinger",getElementData(localPlayer,"Stinger")-1)
	local x, y, z = getElementPosition(localPlayer)
	local rx, ry, rz = getElementRotation(localPlayer)
	x = x - math.sin(math.rad(rz))*2
	y = y + math.cos(math.rad(rz))*2
	rz = rz + 90
	local groundZ = getGroundPosition(x,y,z)
	if(groundZ ~= z) then z = groundZ+0.2 end
	setPedAnimation(getLocalPlayer(),"BOMBER","BOM_Plant",-1,false,false,false,false)
	triggerServerEvent("CreateStinger",localPlayer,x,y,z,rz)

  elseif itemInfo == "Usar Colete" then
	--if getActiveVest(getLocalPlayer()) and getElementData(getLocalPlayer(),"vestLife") == getVestLife(getActiveVest(getLocalPlayer())) then
	  --setElementData(getLocalPlayer(),getActiveVest(getLocalPlayer()),getElementData(getLocalPlayer(),getActiveVest(getLocalPlayer()))+1)
	--end
	for _,vest in pairs(VestsTable)do
	  setElementData(localPlayer,vest[2],false)
	end
	for _,vest in pairs(VestsTable)do
	  if vest[1] == itemName then
		var = vest[2]
		setElementData(getLocalPlayer(),"vestLife",vest[4])
		break
	  end
	end
	setElementData(localPlayer,var,true)
	refreshInventory()
    triggerEvent("hideInventoryManual",localPlayer)

  elseif itemInfo == "Usar Capacete" then
	--if getActiveHelmet(getLocalPlayer()) and getElementData(getLocalPlayer(),"helmetLife") == getHelmetLife(getActiveHelmet(getLocalPlayer())) then
	  --setElementData(getLocalPlayer(),getActiveHelmet(getLocalPlayer()),getElementData(getLocalPlayer(),getActiveHelmet(getLocalPlayer()))+1)
	--end
	for _,helmet in pairs(HelmetsTable)do
	  setElementData(localPlayer,helmet[2],false)
	end
	for _,helmet in pairs(HelmetsTable)do
	  if helmet[1] == itemName then
		var = helmet[2]
		setElementData(getLocalPlayer(),"helmetLife",helmet[4])
		break
	  end
	end
	setElementData(localPlayer,var,true)
	refreshInventory()
    triggerEvent("hideInventoryManual",localPlayer)

  elseif itemInfo == "Vestir Mochila" then
	for _,backpack in pairs(BackpacksTable)do
	  if itemName == backpack[1] then
		if getElementData(getLocalPlayer(),"MAX_Slots")== backpack[2] then
		  triggerEvent("displayClientInfo",getLocalPlayer(),"inventory","Você já usando esta mochila!",255,22,0)
		elseif getPlayerCurrentSlots() > backpack[2] then
		  triggerEvent("displayClientInfo",getLocalPlayer(),"inventory","Seus itens precisam estar abaixo de "..backpack[2].."!",255,22,0)
		else
		  setElementData(getLocalPlayer(),"MAX_Slots",backpack[2])
		  setElementData(getLocalPlayer(),"wearingBackpack",backpack[1])
		  refreshInventory()
		  triggerEvent("hideInventoryManual",localPlayer)
		end
	  end
	end
  elseif itemInfo == "Remover Mochila" then
	if getPlayerCurrentSlots() <= 8 then
	  setElementData(getLocalPlayer(),"MAX_Slots",8)
	  setElementData(getLocalPlayer(),"wearingBackpack",false)
	  refreshInventory()
      triggerEvent("hideInventoryManual",localPlayer)
	else
	  triggerEvent("displayClientInfo",getLocalPlayer(),"inventory","Seus itens precisam estar abaixo de 8!",255,22,0)
	end
  elseif itemInfo == "Remover Colete" then
	vestSlots = getActiveVestSlots(getLocalPlayer())
	if getElementData(getLocalPlayer(),"MAX_Slots")-vestSlots < getPlayerCurrentSlots() then
	  triggerEvent("displayClientInfo",getLocalPlayer(),"inventory","Seus itens precisam estar abaixo de "..getElementData(getLocalPlayer(),"MAX_Slots").."!",255,22,0)
	  return
	end
	setElementData(getLocalPlayer(),getActiveVestVar(getLocalPlayer()),false)
		  refreshInventory()
	  triggerEvent("hideInventoryManual",localPlayer)
  elseif itemInfo == "Remover Capacete" then
	setElementData(getLocalPlayer(),getActiveHelmetVar(getLocalPlayer()),false)
	refreshInventory()
    triggerEvent("hideInventoryManual",localPlayer)
  end
  refreshInventory()
end
addEvent("playerUseItem",true)
addEventHandler("playerUseItem",getLocalPlayer(),playerUseItem)


function weaponSwitch(ID)
  for _,item in pairs(weaponTable)do
	if getElementData(getLocalPlayer(),"currentweapon_1") == item[1] and ID == item[3] and item[5] == 1 then
	  if getElementData(getLocalPlayer(),item[2])> 0 then
		setElementData(getLocalPlayer(),item[2],getElementData(getLocalPlayer(),item[2])- 1)
		return
	  end
	end
	if getElementData(getLocalPlayer(),"currentweapon_2") == item[1] and ID == item[3] and item[5] == 2 then
	  if getElementData(getLocalPlayer(),item[2])> 0 then
		setElementData(getLocalPlayer(),item[2],getElementData(getLocalPlayer(),item[2])- 1)
	  end
	end
	if getElementData(getLocalPlayer(),"currentweapon_3") == item[1] and ID == item[3] and item[5] == 3 then
	  if getElementData(getLocalPlayer(),item[1])> 0 then
		setElementData(getLocalPlayer(),item[1],getElementData(getLocalPlayer(),item[1])- 1)
	  end
	end
	if getElementData(getLocalPlayer(),"currentweapon_4") == item[1] and ID == item[3] and item[5] == 4 then
	  if getElementData(getLocalPlayer(),item[2])> 0 then
		setElementData(getLocalPlayer(),item[2],getElementData(getLocalPlayer(),item[2])- 1)
	  end
	end
  end
end
addEventHandler("onClientPlayerWeaponFire",getLocalPlayer(),weaponSwitch)


------------------------------------------------------------ NEW INVENTORY ------------------------------------------------------------
function onPlayerMoveItemOutOfInventoryNew(itemName)
	if getElementData(getLocalPlayer(),"CantUseInv") then
	  stateCounter = getElementData(getLocalPlayer(),"PingCounter")
	  if not stateCounter then stateCounter = 0 end
	  setElementData(getLocalPlayer(),"PingCounter",stateCounter + 1)
	end
	if playerMovedInInventory then
	  return
	end
	if getElementData(getLocalPlayer(),itemName) and getElementData(getLocalPlayer(),itemName)>= 1 then
	  if isPlayerInLoot() then
		local isVehicle = getElementData(isPlayerInLoot(),"vehicle")
		local isTent = getElementData(isPlayerInLoot(),"tent")
		if isVehicle and not isTent then
		  local veh = getElementData(isPlayerInLoot(),"parent")
		  engine,tires,parts,rotor,glass,slots,fuel,fuelpm = getVehicleAddonInfos(getElementModel(veh))
		  if itemName == "BUGADO" and(getElementData(isPlayerInLoot(),"Tire_inVehicle")or 0)< tires  or itemName == "BUGADO" and(getElementData(isPlayerInLoot(),"Engine_inVehicle")or 0) < engine or itemName == "BUGADO" and(getElementData(isPlayerInLoot(),"Rotor_inVehicle")or 0) < rotor or itemName == "BUGADO" and(getElementData(isPlayerInLoot(),"Glass_inVehicle")or 0) < glass or itemName == "BUGADO" and(getElementData(isPlayerInLoot(),"Parts_inVehicle")or 0) < parts then
			if itemName == "BUGADO" then
			  itemName = "Parts"
			end
			if itemName == "BUGADO" then
			  itemName = "Rotor"
			end
			if itemName == "BUGADO" then
			  itemName = "Glass"
			end
			triggerEvent("onPlayerMoveItemOutOFInventory",getLocalPlayer(),itemName.."_inVehicle",isPlayerInLoot())
			playerMovedInInventory = true
			setTimer(function()
			  playerMovedInInventory = false
			end,700,1)
		  elseif isToolbeltItem(itemName) then
			triggerEvent("onPlayerMoveItemOutOFInventory",getLocalPlayer(),itemName,isPlayerInLoot())
			playerMovedInInventory = true
			setTimer(function()
			  playerMovedInInventory = false
			end,700,1)
		  elseif getLootCurrentSlots(getElementData(getLocalPlayer(),"currentCol"))+ getItemSlots(itemName)<= getLootMaxAviableSlots(isPlayerInLoot()) then
			triggerEvent("onPlayerMoveItemOutOFInventory",getLocalPlayer(),itemName,isPlayerInLoot())
			playerMovedInInventory = true
			setTimer(function()
			  playerMovedInInventory = false
			end,700,1)
		  else
			startRollMessage2("Inventory","Inventário cheio!",255,22,0)
			return
		  end
		elseif isToolbeltItem(itemName) then
		  triggerEvent("onPlayerMoveItemOutOFInventory",getLocalPlayer(),itemName,isPlayerInLoot())  
		  playerMovedInInventory = true
		  setTimer(function()
			  playerMovedInInventory = false
		  end,700,1)
		elseif getLootCurrentSlots(getElementData(getLocalPlayer(),"currentCol"))+ getItemSlots(itemName)<= getLootMaxAviableSlots(isPlayerInLoot()) then
		  triggerEvent("onPlayerMoveItemOutOFInventory",getLocalPlayer(),itemName,isPlayerInLoot())
		  playerMovedInInventory = true
		  setTimer(function()
			  playerMovedInInventory = false
		  end,700,1)
		else
		  startRollMessage2("Inventory","Inventário cheio!",255,22,0)
		  return
		end 
	  else
		triggerEvent("onPlayerMoveItemOutOFInventory",getLocalPlayer(),itemName,isPlayerInLoot())
		playerMovedInInventory = true
		setTimer(function()
		  playerMovedInInventory = false
		end,700,1)
	  end 
	end
end
addEvent("onPlayerMoveItemOutOfInventoryNew",true)
addEventHandler("onPlayerMoveItemOutOfInventoryNew",getLocalPlayer(),onPlayerMoveItemOutOfInventoryNew)

function onPlayerMoveItemInInventoryNew(itemName)
	if getElementData(getLocalPlayer(),"CantUseInv") then
	  stateCounter = getElementData(getLocalPlayer(),"PingCounter")
	  if not stateCounter then stateCounter = 0 end
	  setElementData(getLocalPlayer(),"PingCounter",stateCounter + 1)
	end
	if isPlayerInLoot() then
	  if getElementData(isPlayerInLoot(),itemName) and (getElementData(isPlayerInLoot(),itemName)or 0)>= 1 then
		if not isToolbeltItem(itemName) then
		  if getPlayerCurrentSlots()+ getItemSlots(itemName)<= getPlayerMaxAviableSlots() then
			if not playerMovedInInventory then
			  triggerEvent("onPlayerMoveItemInInventory",getLocalPlayer(),itemName,isPlayerInLoot())
			  playerMovedInInventory = true
			  setTimer(function()
				playerMovedInInventory = false
			  end,700,1)
			else
			  return
			end 
		  else
			startRollMessage2("Inventory","Inventário cheio!",255,22,0)
			return
		  end
		else
		  playerMovedInInventory = true
		  setTimer(function()
			playerMovedInInventory = false
		  end,700,1)
		  triggerEvent("onPlayerMoveItemInInventory",getLocalPlayer(),itemName,isPlayerInLoot())
		end
	  end
	  if isPlayerInLoot() then
		local gearName = guiGetText(LootLabel)
		local col = getElementData(getLocalPlayer(),"currentCol")
		setTimer(refreshInventory,200,2)
		setTimer(refreshLoot,200,2,col,gearName)
	  end
	end 
end
addEvent("onPlayerMoveItemInInventoryNew",true)
addEventHandler("onPlayerMoveItemInInventoryNew",getLocalPlayer(),onPlayerMoveItemInInventoryNew)

function getPedClothesID(thePed, clothingSlot)
	if not isElement(thePed) or type(clothingSlot) ~= "number" then
		error("Invalid arguments to setPedClothes()!", 2)
	end
	local texture, model = getPedClothes(thePed, clothingSlot)
	if not texture then
		return false
	else
		local _, id = getTypeIndexFromClothes(texture, model)
		return id
	end
end

 

Link to comment
  • Other Languages Moderators
local numbers = getElementData(isPlayerInLoot(),itemName) -- Se não existir a data, então numbers = false
for i = 1, numbers do -- Se numbers for false, dará erro aqui.

Ali nas linhas 348 e 349.

Edited by Lord Henry
  • Like 1
Link to comment
15 hours ago, Lord Henry said:

local numbers = getElementData(isPlayerInLoot(),itemName) -- Se não existir a data, então numbers = falsefor i = 1, numbers do -- Se numbers for false, dará erro aqui.

Ali nas linhas 348 e 349.

sim mas eu teria que adicionar um true na linha 348 ou 349? ou trocar o numbers por um numero, eu n entendi

Link to comment
  • Moderators
On 25/11/2018 at 02:10, Lukkas2201 said:

mas ja tem um numero ali, vc diz que o proprio "number" teria que ser um numero? ou eu teria que adicionar um true nele?

"number" ali é só a variável, o que ocorre é que tem um erro no getElementData que precisa ser corrigido. A propósito isPlayerInLoot() provavelmente retorna uma boolean, e getElementData deve receber um elemento no primeiro argumento.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...