Jump to content

Ajuda com Script


Recommended Posts

Boa noite, estou tentando fazer o seguinte, no servidor tem dois tipos de inventário (padrão e o modificado), vc aperta a Tecla 'J' e ele abre o inventário padrão, porém na hora que ele abre o inventário padrão, se vc apertar um botão ele troca para o inventário modificado, a porém eu queria deixar fixo, para quando apertar J, abrir somente o modificado, e não ter como mudar para o padrão, ou seja, quero que o inventário modificado seja o novo inventário padrão, (o inventário modificado vem de outro script, mas creio que nao preciso postar ele, porque a configuração de abrir está neste script abaixo), se alguém puder me ajudar e me dizer oque fazer, ou onde tenho que alterar algo, eu ficarei grato.

o (new_inv) é o inventário modificado. ele vem de outro script que seria uma resource.

a função no qual abre o inventário é a "function showInventory(key,keyState)"

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

["Food"] = {
{"Canned Spaghetti (Fechado)",1,"","Espaguete enlatado fechado, necessário o item *Opener* para abrir. \nClique 2x para abrir."},
{"Canned Spaghetti (Aberto)",1,"","Espaguete enlatado aberto.\nPara comer clique 2x"},
{"Canned Baked Beans (Fechado)",1,"","Feijão enlatado fechado, necessário o item *Opener* para abrir. \nClique 2x para abrir."},
{"Canned Baked Beans (Aberto)",1,"","Feijão enlatado aberto.\nPara comer clique 2x"},
{"Canned Sardines (Fechado)",1,"","Sardinha enlatada fechada, necessário o item *Opener* para abrir. \nClique 2x para abrir."},
{"Canned Sardines (Aberto)",1,"","Sardinha enlatada aberta.\nPara comer clique 2x"},
{"Can of Tactical Bacon (Fechado)",1,"","Bacon enlatado fechado, necessário o item *Opener* para abrir. \nClique 2x para abrir."},
{"Can of Tactical Bacon (Aberto)",1,"","Bacon enlatado aberto.\nPara comer clique 2x"},

{"Water Bottle",1,"","Garrafa de água.\nPara beber clique 2x"},
{"Burger",1,"","Burguer.\nPara comer clique 2x"},
{"Pizza",1,"","Pizza\nPara comer clique 2x"},
{"Soda Bottle",1,"","Soda Bottle.\nPara beber clique 2x"},
{"Milk",1,"","Milk.\nPara beber clique 2x"},
{"Cooked Meat",1,"","Carne Assada.\nPara comer clique 2x"},
{"Raw Meat",1,"","Carne Crua.\nPara assar é necessário o acender um Wood Pile\nPara Assar clique com o scroll do mouse no Wood Pile"},
},

["Medic"] = {
{"Antibiotics",1,"Usar","Antibiotcs"},
{"Bandage",1,"Usar","Bandage, usado para estancar curativos.\nPara usar clique 2x"},
{"Medic Kit",2,"Usar","Medic Kit, usado para aumentar o blood.\nPara usar clique 2x"},
{"Heat Pack",1,"Usar","Heat Pack.\nPara usar clique 2x"},
{"Painkiller",1,"Usar","Painkiller, usado para aliviar dores de cabeça.\nPara usar clique 2x"},
{"Blood Bag",1,"Usar","Blood Bag, bolsa de sangue, usado para aumentar o blood de outro player.\nPara usar se aproxime do player, e clique com o scrol do mouse em *Administer Blood Bag*"},
{"Morphine",1,"Usar","Morphine, usado para curar ossos quebrados.\nPara usar clique 2x"},
},

["VehicleParts"] = {
{"Engine",5,"","Motor, usado em veículos, necessário o item *Toolbox* para colocar no veículo.\nPara colocar no veículo aperta o Scrol do mouse em *Colocar Engine*"},
{"Tire",2,"","Pneu, usado em veículos, necessário o item *Toolbox* para colocar no veículo.\nPara colocar no veículo aperta o Scrol do mouse em *Colocar Tire*"},
{"Tank Parts",3,"","Tanque de Gasolina, usado em veículos, necessário o item *Toolbox* para colocar no veículo.\nPara colocar no veículo aperta o Scrol do mouse em *Colocar Tank Parts*"},
{"Scrap Metal",1,"","Ferramenta utilizada para reparar veículos, necessário o item *Toolbox* junto para poder reparar.\nPara colocar no veículo aperta o Scrol do mouse em *Reparar Veículo*"},
{"Steel Sheet",1,"","Armadura para veículos.\nPara colocar no veículo aperta o Scrol do mouse em *Colocar Steel Sheet*"},
{"Empty Gas Canister",2,"","Galão de Gasolina Vazio, para encher, vá até um posto de gasolina\nPara encher, aproxime-se da bomba de gasolina, e clique com o scroll do mouse."},
{"Full Gas Canister",2,"","Galão de Gasolina cheio\nPara abastecer o veículo, clique com o Scrol do mouse em *Colocar Gasolina*."},
},

["Items"] = {
{"Stinger",3,"Place Stinger","Tapete de pregos, usado para furar pneu de veículos.\nPara usar clique 2x."},
{"Wood Pile",2,"","Fogueira, necessários o item *Box Of Matches* para acender."},
{"Roadflare",1,"Place","Quando colocado, acende uma luz bem forte, para chamar atenção de outros players\nClique 2x para colocar."},
{"Wire Fence",1,"Colocar Wire Fence","Cerca de Arame (Para remover ela, necessário item *Toolbox*\nClique 2x para colocar."},
{"Tent",3,"Pitch a Tent","Tenda, usado para guardar itens.\nPara montar, clique 2x."},
{"Empty Water Bottle",1,"","Garrafa de água vazia\nPara encher, vá até o mar, e clique 2x."},
{"Empty Soda Cans",1,"","Lata de soda vazia."},
},

["Roupas"] = {
},

["Mochilas"] = {
},

["Toolbelt"] = {
{"Night Vision Goggles",0,"","Visão noturna, usado para enxergar melhor a noite.\nPara ativar aperte a tecla N"},
{"Infrared Goggles",0,"","Visão infra vermelho, usado para enxergar melhor os objetos e inimigos\nPara ativar aperte a tecla I"},
{"Map",0,"","Mapa\nPara usar aperte F11"},
{"Box of Matches",0,"Make a Fire","Esqueiro, usado para acender fogueira (necessário item *Wood Pile*\nPara acender se aproxime da fogueira e clique com o scrol do mouse.",},
{"Watch",0,"","Relógio"},
{"GPS",0,"Set Rate","Radar, usado para setar frequência e encontrar outros players"}, -- se for ativar frequencia do gps "Set Rate"
{"Toolbox",0,"","Caixa de Ferramentas, usado para colocar peças em veículos, remover wire fences e stingers"},
{"Radio Device",0,"","Usado em veículos para poder ouvir rádio"},

{"Syringe",0,"","Siringa"},
{"Opener",0,"","Usado para abrir comidas fechadas"},
{"Hose",0,"","Mangueira, usada para retirar gasolina de um veículo.\nPara retirar gasolina, ela precisa estar acima de 20 no veículo, clique com o scrol do mouse em *Retirar Gasolina*."},
{"Tire Repair Kit",0,"","Kit de Reparos de pneu"},
{"Compass",0,"","Kit de Reparos de pneu"},
}}

local sacks = {
   {"Smersh Backpack",10},
   {"Courier Bag",11},
   {"Child Briefcase",12},
   {"Improvised Backpack",14},
   {"Assault Pack (ACU)",16},
   {"Alice Pack",18},
   {"British Assault Pack",20},
   {"Taloon Backpack",22},
   {"Omega Backpack",24},
   {"Alfa Backpack",26},
   {"Hunting Backpack",28},
   {"Camping Backpack",30},
   {"Drybag Backpack",32},
   {"Mountain Backpack",36},
   {"Czech Backpack",40},
   {"Camping Tactical Backpack",42},
   {"Coyote Backpack",44},
   {"Coyote Backpack (Desert)",45},
   {"Coyote Backpack (Mossy)",46},
   {"Tactical Backpack",48},
   {"Eskimo Backpack",50},
   {"Tiger Backpack",55},
   {"Noel Backpack",68},
}	

addEventHandler("onClientResourceStart",resourceRoot,function()
for i,weaponData in pairs(weaponTable)do
  if weaponData[5] == 1 then
	table.insert(inventoryItems["Primary Weapon"],{weaponData[1],3,weaponData[2],weaponData[11]})
  elseif weaponData[5] == 2 then
	if weaponData[2] == "others" then
	  table.insert(inventoryItems["Secondary Weapon"],{weaponData[1],2,weaponData[1],weaponData[11]})
	else
	  table.insert(inventoryItems["Secondary Weapon"],{weaponData[1],2,weaponData[2],weaponData[11]})
	end
  elseif weaponData[5] == 3 then
	table.insert(inventoryItems["Specially Weapon"],{weaponData[1],1,weaponData[1],weaponData[11]})
  elseif weaponData[5] == 4 then
	table.insert(inventoryItems["Pistols"],{weaponData[1],2,weaponData[2],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][4] = inventoryItems["Ammo"][i][4]..";\n"..weaponData[1]
	  end
	end
	if add then
	  table.insert(inventoryItems["Ammo"],{weaponData[2],weaponData[8],"","Ammo for:\n"..weaponData[1]})
	end
  end
end
end)

for i,vestData in pairs(VestsTable)do
  table.insert(inventoryItems["Items"],{vestData[1],1,"Use Vest",vestData[7]})
end
for i,helmetData in pairs(HelmetsTable)do
  table.insert(inventoryItems["Items"],{helmetData[1],1,"Use Helmet",helmetData[7]})
end
for i,bpData in pairs(BackpacksTable)do
  table.insert(inventoryItems["Items"],{bpData[1],1,"Wear Backpack","Backpack with "..bpData[2].." Slots"})
end -- убрать
------------------------------------------------------------------------------
--INVENTORY
local headline = {}

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.17, 0.04, 0.69, "->", true, inv_window)
guiSetFont(loot_takebutton, "default-bold-small")
inv_dropbutton = guiCreateButton(0.53, 0.17, 0.04, 0.69, "<-", 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")

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

SetGPSRateWindow = guiCreateWindow(0.42,0.45,0.08,0.13,"Set GPS Rate",true)
guiWindowSetSizable(SetGPSRateWindow,false)
guiSetVisible(SetGPSRateWindow,false)
GPSRate = guiCreateEdit(0.10,0.25,0.81,0.25,"",true,SetGPSRateWindow)
SetGPSRate = guiCreateButton(0.10,0.61,0.81,0.29,"Set",true,SetGPSRateWindow)
guiSetFont(SetGPSRate,"default-bold-small")
guiSetProperty(SetGPSRateWindow,"AlwaysOnTop","True")

x,y = guiGetScreenSize()
x2,y2 = guiGetSize(inv_window,false)
x3,y3 = guiGetSize(SetGPSRateWindow,false)
guiSetPosition(inv_window,x/2-x2/2,y/2-y2/2,false)
guiSetPosition(SetGPSRateWindow,x/2-x3/2,y/2-y3/2,false)

addEventHandler("onClientGUIClick",getResourceRootElement(getThisResource()),function()
  if source == SetGPSRate then
	rate = guiGetText(GPSRate)
	if rate ~= "" and tonumber(rate) then
	  guiSetVisible(SetGPSRateWindow,false)
	  setElementData(getLocalPlayer(),"GPSChannel",rate)
	else
	  outputChatBox("Type a number!")
	end
  end
end)
local sW, sH = guiGetScreenSize()
local topChangeButtonsParent = guiCreateLabel(100,100,100,30,"",false)
local middleOnButton = guiCreateRadioButton ( 0,0,100, 15, "",false, topChangeButtonsParent)
guiCreateRadioButton ( 0,15,100, 15, "",false, topChangeButtonsParent)
guiRadioButtonSetSelected ( middleOnButton, true )

local bottomChangeButtonsParent = guiCreateLabel(100,100,100,30,"",false)
local inventoryOnButton = guiCreateRadioButton ( 0,0,100, 15, "",false, bottomChangeButtonsParent)
local inventoryOffButton = guiCreateRadioButton ( 0,15,100, 15, "",false, bottomChangeButtonsParent)
guiRadioButtonSetSelected ( inventoryOnButton, true )

function changeMiddleVisible()
	exports.new_inv:setMiddleVisible(guiRadioButtonGetSelected(middleOnButton))
	local x, top, bottom = exports.new_inv:getRadioButtonsCoords()
	guiSetPosition(topChangeButtonsParent,x,top,false)
	guiSetPosition(bottomChangeButtonsParent,x,bottom,false)
end

addEventHandler("onClientGUIClick",topChangeButtonsParent, changeMiddleVisible )

guiSetVisible(topChangeButtonsParent,false)

function changeInventoryVisible()
	setElementData(localPlayer,"dayz:new_inv",guiRadioButtonGetSelected(inventoryOnButton))
	if not guiRadioButtonGetSelected(inventoryOnButton) then
		exports.new_inv:hideNewInventory()
	else
		guiSetVisible(inv_window,false)
		hideRightClickInventoryMenu ()
	end
	showInventory(nil,"down")
	guiSetVisible(bottomChangeButtonsParent,true)
end

addEventHandler("onClientGUIClick",bottomChangeButtonsParent, changeInventoryVisible )

guiSetVisible(bottomChangeButtonsParent,false)



function showInventory(key,keyState)
  if getElementData(getLocalPlayer(),"cantOpenInv") then return end
  hideRightClickInventoryMenu()
  guiSetVisible(InfoWindow,false)
  local col = getElementData(getLocalPlayer(),"currentCol")
  local gearName = getElementData(getLocalPlayer(),"lootname")
  refreshLoot(col,gearName)
  if getElementData(getLocalPlayer(),"logedin") and keyState == "down" then
	local x, top, bottom = exports.new_inv:getRadioButtonsCoords()
	if getElementData ( localPlayer, "dayz:new_inv") then -- ESSE NEW_INV É O INVENTÁRIO MODIFICADO, O QUAL QUERO DEIXAR COMO PADRÃO
		guiRadioButtonSetSelected ( inventoryOnButton, true )
		guiSetVisible(topChangeButtonsParent,not guiGetVisible(topChangeButtonsParent))
		guiSetPosition(topChangeButtonsParent,x,top,false)
		guiSetPosition(bottomChangeButtonsParent,x,bottom,false)
		guiSetVisible(bottomChangeButtonsParent,not guiGetVisible(bottomChangeButtonsParent))
		local show = exports.new_inv:showNewInventory()
		if show then
			onClientOpenInventoryStopMenu ()
		end
		showCursor(show)
		return
	else
		guiRadioButtonSetSelected ( inventoryOffButton, true )
		guiSetVisible(topChangeButtonsParent,false)
	end
	if guiGetVisible(inv_window) then --- AQUI É O INVENTÁRIO PADRÃO
		guiSetVisible(inv_window,false)
		guiSetVisible(SetGPSRateWindow,false)
		--guiSetVisible(SetGPSRateWindow,false)
		showCursor(false)
		guiSetVisible(bottomChangeButtonsParent,false)
	else
		guiSetVisible(inv_window,true)
		showCursor(true)
		guiSetPosition(bottomChangeButtonsParent,0.14*sW+0.72*sW,0.18*sH+0.63*sH-30,false)
		guiSetVisible(bottomChangeButtonsParent,true)
	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("j","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)

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

function showInventoryManual()
	if getElementData(localPlayer,"dayz:new_inv") then
		exports.new_inv:showNewInventory()
		return
	end
  guiSetVisible(inv_window,not guiGetVisible(inv_window))
  showCursor(not isCursorShowing())
  refreshInventory()
  if guiGetVisible(inventoryWindows)== true then
	onClientOpenInventoryStopMenu()
  end
end

function hideInventoryManual()
	guiSetVisible(inv_window,false)
	guiSetVisible(topChangeButtonsParent,false)
	guiSetVisible(bottomChangeButtonsParent,false)
	showCursor(false)
	if getElementData ( localPlayer, "dayz:new_inv") then
		return
	end
	hideRightClickInventoryMenu()
end
addEvent("hideInventoryManual",true)
addEventHandler("hideInventoryManual",getLocalPlayer(),hideInventoryManual)

function refreshInventoryManual()
	if getElementData ( localPlayer, "dayz:new_inv") then
		return
	end
	refreshInventory()
end
addEvent("refreshInventoryManual",true)
addEventHandler("refreshInventoryManual",getLocalPlayer(),refreshInventoryManual)

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

function getMyInventory()
	local myInventory = {}
	for id, item in ipairs(inventoryItems["Primary Weapon"]) do
		local quant = getElementData(getLocalPlayer(),item[1])
		if quant and quant >= 1 then
			table.insert(myInventory,{item[1],quant})
		end
	end
	for id, item in ipairs(inventoryItems["Secondary Weapon"]) do
		local quant = getElementData(getLocalPlayer(),item[1])
		if quant and quant >= 1 then
			table.insert(myInventory,{item[1],quant})
		end
	end
	for id, item in ipairs(inventoryItems["Pistols"]) do
		local quant = getElementData(getLocalPlayer(),item[1])
		if quant and quant >= 1 then
			table.insert(myInventory,{item[1],quant})
		end
	end
	for id, item in ipairs(inventoryItems["Specially Weapon"]) do
		local quant = getElementData(getLocalPlayer(),item[1])
		if quant and quant >= 1 then
			table.insert(myInventory,{item[1],quant})
		end
	end
	for id, item in ipairs(inventoryItems["Ammo"]) do
		local quant = getElementData(getLocalPlayer(),item[1])
		if quant and quant >= 1 then
			table.insert(myInventory,{item[1],quant})
		end
	end
	for id, item in ipairs(inventoryItems["Food"]) do
		local quant = getElementData(getLocalPlayer(),item[1])
		if quant and quant >= 1 then
			table.insert(myInventory,{item[1],quant})
		end
	end
	for id, item in ipairs(inventoryItems["Medic"]) do
		local quant = getElementData(getLocalPlayer(),item[1])
		if quant and quant >= 1 then
			table.insert(myInventory,{item[1],quant})
		end
	end
	for id, item in ipairs(inventoryItems["VehicleParts"]) do
		local quant = getElementData(getLocalPlayer(),item[1])
		if quant and quant >= 1 then
			table.insert(myInventory,{item[1],quant})
		end
    end
	for id, item in ipairs(inventoryItems["Items"]) do
		local quant = getElementData(getLocalPlayer(),item[1])
		if quant and quant >= 1 then
			table.insert(myInventory,{item[1],quant})
		end
    end
	for id, item in ipairs(inventoryItems["Toolbelt"]) do
		local quant = getElementData(getLocalPlayer(),item[1])
		if quant and quant >= 1 then
			table.insert(myInventory,{item[1],quant})
		end
	end
	return myInventory
end

function getLootInventory()
	local lootInventory = {}
	if not isElement (isPlayerInLoot()) then
		return false
	end
	for id, item in ipairs(inventoryItems["Primary Weapon"]) do
		local quant = getElementData(isPlayerInLoot(),item[1])
		if quant and quant >= 1 then
			table.insert(lootInventory,{item[1],quant})
		end
	end
	for id, item in ipairs(inventoryItems["Secondary Weapon"]) do
		local quant = getElementData(isPlayerInLoot(),item[1])
		if quant and quant >= 1 then
			table.insert(lootInventory,{item[1],quant})
		end
	end
	for id, item in ipairs(inventoryItems["Pistols"]) do
		local quant = getElementData(isPlayerInLoot(),item[1])
		if quant and quant >= 1 then
			table.insert(lootInventory,{item[1],quant})
		end
	end
	for id, item in ipairs(inventoryItems["Specially Weapon"]) do
		local quant = getElementData(isPlayerInLoot(),item[1])
		if quant and quant >= 1 then
			table.insert(lootInventory,{item[1],quant})
		end
	end
	for id, item in ipairs(inventoryItems["Ammo"]) do
		local quant = getElementData(isPlayerInLoot(),item[1])
		if quant and quant >= 1 then
			table.insert(lootInventory,{item[1],quant})
		end
	end
	for id, item in ipairs(inventoryItems["Food"]) do
		local quant = getElementData(isPlayerInLoot(),item[1])
		if quant and quant >= 1 then
			table.insert(lootInventory,{item[1],quant})
		end
	end
	for id, item in ipairs(inventoryItems["Medic"]) do
		local quant = getElementData(isPlayerInLoot(),item[1])
		if quant and quant >= 1 then
			table.insert(lootInventory,{item[1],quant})
		end
	end
	for id, item in ipairs(inventoryItems["VehicleParts"]) do
		local quant = getElementData(isPlayerInLoot(),item[1])
		if quant and quant >= 1 then
			table.insert(lootInventory,{item[1],quant})
		end
	end
	for id, item in ipairs(inventoryItems["Items"]) do
		local quant = getElementData(isPlayerInLoot(),item[1])
		if quant and quant >= 1 then
			table.insert(lootInventory,{item[1],quant})
		end
    end
	for id, item in ipairs(inventoryItems["Toolbelt"]) do
		local quant = getElementData(isPlayerInLoot(),item[1])
		if quant and quant >= 1 then
			table.insert(lootInventory,{item[1],quant})
		end
	end
	return lootInventory
end

function getMySlots()
  vestSlots = getActiveVestSlots(getLocalPlayer())
  if vestSlots then
	return {getPlayerCurrentSlots()+vestSlots,getPlayerMaxAviableSlots()+vestSlots}
  else
	return {getPlayerCurrentSlots(),getPlayerMaxAviableSlots()}
  end
end

function getLootSlots()
	if not isElement (isPlayerInLoot()) then
		return {0,0}
	else
		return {getLootCurrentSlots(isPlayerInLoot()),getLootMaxAviableSlots(isPlayerInLoot())}
	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,"- Primary Weapon",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,"- Secondary Weapon",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,"- Pistols",true,false)
	for id,item in ipairs(inventoryItems["Pistols"])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_4") and item[1] == getElementData(getLocalPlayer(),"currentweapon_4") 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,"- Specially Weapon",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,"- Ammo",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,"- Foods / Drinks",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,"- Medic",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,"- Vehicle Parts",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,"- Misc",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)
		if getActiveVest(getLocalPlayer()) == item[1] then
		  guiGridListSetItemColor(inv_itemsgrid,row,inv_itemscolumn,0,255,0)
		  guiGridListSetItemColor(inv_itemsgrid,row,inv_amountcolumn,0,255,0)
		end
		if getActiveHelmet(getLocalPlayer()) == item[1] then
		  guiGridListSetItemColor(inv_itemsgrid,row,inv_itemscolumn,0,255,0)
		  guiGridListSetItemColor(inv_itemsgrid,row,inv_amountcolumn,0,255,0)
		end
		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,"- Toolbelt",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
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,"- Primary Weapon",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,"- Secondary Weapon",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,"- Pistols",true,false)
	for id,item in ipairs(inventoryItems["Pistols"])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,"- Specially Weapon",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,"- Ammo",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,"- Foods / Drinks",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,"- Medic",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,"- Vehicle Parts",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,"- Misc",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,"- Toolbelt",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[4]
	  end
	end
  end
  return false
end

function playerMoveItemOutOfInventory(itemName)
  if getElementData(localPlayer,"dayz:new_inv") or source == inv_dropbutton then
	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 startRollMessage2("Inventory","Abusing exploits will result in a ban!",255,22,0)return end
	
	if not getElementData(localPlayer,"dayz:new_inv") then
		itemName = guiGridListGetItemText(inv_itemsgrid,guiGridListGetSelectedItem(inv_itemsgrid),1)
	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
		  if 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","Inventory is full!",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","Inventory is full!",255,22,0)
		  return
		end 
	  else
		triggerEvent("onPlayerMoveItemOutOFInventory",getLocalPlayer(),itemName,isPlayerInLoot())
		playerMovedInInventory = true
		setTimer(function()
		  playerMovedInInventory = false
		end,700,1)
	  end 
	end
	if getElementData(localPlayer,"dayz:new_inv") then
		setTimer(triggerEvent,200,2,"refreshInventoryManual",localPlayer)
		return
	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
end
addEventHandler("onClientGUIClick",inv_dropbutton,playerMoveItemOutOfInventory)

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 not getElementData(loot,"itemloot") and getElementType(getElementData(loot,"parent")) == "vehicle" then
  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
  end
  if itemPlus > getElementData(getLocalPlayer(),itemName) then
	itemPlus = getElementData(getLocalPlayer(),itemName)
  end
  if loot then
	if getElementType(loot)== "player" then
	  triggerServerEvent("giveItemToAnotherPlayer",getLocalPlayer(),itemName,itemPlus)
	else
	  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	
	end
  else
	triggerServerEvent("playerDropAItem",getLocalPlayer(),itemName,itemPlus)
	setElementData(getLocalPlayer(),itemName,getElementData(getLocalPlayer(),itemName)- itemPlus)
	return
  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 playerMoveItemInInventory(itemName)
  if getElementData(localPlayer,"dayz:new_inv") or source == loot_takebutton then
	if getElementData(getLocalPlayer(),"CantUseInv") then
	  stateCounter = getElementData(getLocalPlayer(),"PingCounter")
	  if not stateCounter then stateCounter = 0 end
	  setElementData(getLocalPlayer(),"PingCounter",stateCounter + 1)
	end
	if not getElementData(localPlayer,"dayz:new_inv") then
		itemName = guiGridListGetItemText(loot_grid,guiGridListGetSelectedItem(loot_grid),1)
	end
	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)
			  return
			end 
		  else
			startRollMessage2("Inventory","Inventory is full!",255,22,0)
			return
		  end
		else
		  playerMovedInInventory = true
		  setTimer(function()
			playerMovedInInventory = false
		  end,700,1)
		  triggerEvent("onPlayerMoveItemInInventory",getLocalPlayer(),itemName,isPlayerInLoot())
		end
	  end
		if getElementData(localPlayer,"dayz:new_inv") then
			setTimer(triggerEvent,200,2,"refreshInventoryManual",localPlayer)
			return
		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
end
addEventHandler("onClientGUIClick",loot_takebutton,playerMoveItemInInventory)


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
	if getElementType(loot)== "player" then
	  triggerServerEvent("takeItemToAnotherPlayer",getLocalPlayer(),itemName,itemPlus)
	else
	  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
	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(itemName)
	if not getElementData(localPlayer,"dayz:new_inv") then	
		itemName = guiGridListGetItemText(inv_itemsgrid,guiGridListGetSelectedItem(inv_itemsgrid),1)
	end
  local itemName,itemInfo = getInventoryInfosForRightClickMenu(itemName)

  if isCursorShowing() and ( guiGetVisible(inv_window) or getElementData(localPlayer,"dayz:new_inv") ) 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 == "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 == "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 = "Remove Backpack"
	end
	if itemName == getActiveVest(getLocalPlayer()) then
	  itemInfo = "Remove Vest"
	end
	if itemName == getActiveHelmet(getLocalPlayer()) then
	  itemInfo = "Remove Helmet"
	end -- убрать
	if itemInfo ~= "" then
	  playerUseItem(itemName,itemInfo)
	end
  end
end
addEventHandler("onClientGUIDoubleClick",inv_itemsgrid,onPlayerPressRightKeyInInventory,false)

function onPlayerPressRightKeyInInventory2()
  local itemName = guiGridListGetItemText(inv_itemsgrid,guiGridListGetSelectedItem(inv_itemsgrid),1)
  local itemName,itemInfo = getInventoryInfosForRightClickMenu(itemName)
  if guiGetVisible(inv_window) and itemName then
	showRightClickInventoryMenu2(itemName)
  end
end
bindKey("mouse2","down",onPlayerPressRightKeyInInventory2)

function getInventoryInfosForRightClickMenu(itemName)
  for i,itemInfo in ipairs(inventoryItems["Primary Weapon"])do
	if itemName == itemInfo[1] then
	  return itemName,"Equip Primary Weapon"
	end
  end
  for i,itemInfo in ipairs(inventoryItems["Secondary Weapon"])do
	if itemName == itemInfo[1] then
	  return itemName,"Equip Secondary Weapon"
	end
  end
  for i,itemInfo in ipairs(inventoryItems["Pistols"])do
	if itemName == itemInfo[1] then
	  return itemName,"Equip Pistol"
	end
  end
  for i,itemInfo in ipairs(inventoryItems["Specially Weapon"])do
	if itemName == itemInfo[1] then
	  return itemName,"Equip Specially Weapon"
	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 = "Drink"
	  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 = "Open"
	  else
		info = "Eat"
	  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["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 showRightClickInventoryMenu(itemName,itemInfo)
  if itemInfo then
	local screenx,screeny,worldx,worldy,worldz = getCursorPosition()
	guiSetVisible(rightclickWindow,true)
	guiSetText(headline["rightclickmenu"],itemInfo)
	local whith = guiLabelGetTextExtent(headline["rightclickmenu"])
	guiSetPosition(rightclickWindow,screenx,screeny,true)
	local x,y = guiGetSize(rightclickWindow,false)
	guiSetSize(rightclickWindow,whith,y,false)
	guiBringToFront(rightclickWindow)
	setElementData(rightclickWindow,"iteminfo",{itemName,itemInfo})
  end
end

function hideRightClickInventoryMenu()
  guiSetVisible(rightclickWindow,false)
  guiSetVisible(rightclickWindow2,false)
end

function hideRightClickInventoryMenu2(button)
  if button == "left" then
	hideRightClickInventoryMenu()
  end
end
addEventHandler("onClientGUIClick",inv_window,hideRightClickInventoryMenu2,false)
addEventHandler("onClientGUIClick",loot_grid,hideRightClickInventoryMenu2,false)
addEventHandler("onClientGUIClick",inv_itemsgrid,hideRightClickInventoryMenu2,false)

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)
------------------------------ RightClickMenu 1 ------------------------------


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

InfoWindow = guiCreateWindow(382, 323, 268, 155, "Item Info: ", false)
guiWindowSetSizable(InfoWindow, false)
guiSetVisible(InfoWindow,false)
InfoWindowInfo = guiCreateMemo(10, 25, 248, 84, "", false, InfoWindow)
guiMemoSetReadOnly(InfoWindowInfo, true)
InfoWindowButton = guiCreateButton(10, 119, 248, 26, "Close", false, InfoWindow)
guiSetFont(InfoWindowButton, "default-bold-small")
guiSetProperty(InfoWindow,"AlwaysOnTop","True")

function CloseInfoWindow()
  guiSetVisible(InfoWindow,false)
end
addEventHandler("onClientGUIClick",InfoWindowButton,CloseInfoWindow,false)

function showRightClickInventoryMenu2(itemName)
  if itemName then
	local screenx,screeny,worldx,worldy,worldz = getCursorPosition()
	guiSetVisible(rightclickWindow2,true)
	guiSetText(headline["rightclickmenu2"],"Info")
	local whith = guiLabelGetTextExtent(headline["rightclickmenu2"])
	if guiGetVisible(rightclickWindow) then
	  guiSetPosition(rightclickWindow2,screenx,screeny + 0.023,true)
	else
	  guiSetPosition(rightclickWindow2,screenx,screeny,true)
	end
	local x,y = guiGetSize(rightclickWindow2,false)
	guiSetSize(rightclickWindow2,whith,y,false)
	guiBringToFront(rightclickWindow2)
	setElementData(rightclickWindow2,"iteminfo",{itemName,itemInfo})
  end
end

function onPlayerClickOnRightClickMenu2(button,state)
  if button == "left" then
	local itemName,itemInfo = getElementData(rightclickWindow2,"iteminfo")[1],getElementData(rightclickWindow2,"iteminfo")[2]
	hideRightClickInventoryMenu()
	guiSetText(InfoWindow,"Item Info: "..itemName)
	guiSetText(InfoWindowInfo,getItemInfo(itemName))
	guiSetVisible(InfoWindow,true)

	x,y = guiGetScreenSize()
	x2,y2 = guiGetSize(InfoWindow,false)
	guiSetPosition(InfoWindow,x/2 - x2/2,y/2 - y2/2,false)
  end
end
addEventHandler("onClientGUIClick",headline["rightclickmenu2"],onPlayerClickOnRightClickMenu2,false)
------------------------------ RightClickMenu 2 ------------------------------

function playerUseItem(itemName,itemInfo)
  if itemInfo == "Drink" then
  	refreshInventory()
    triggerEvent("hideInventoryManual",localPlayer)
	playSound("sounds/Actions/Drink.ogg")
	triggerServerEvent("onPlayerRequestChangingStats",getLocalPlayer(),itemName,itemInfo,"thirst")
	refreshNewInventory()
  elseif itemInfo == "Eat" then
  	refreshInventory()
    triggerEvent("hideInventoryManual",localPlayer)
	playSound("sounds/Actions/Eat.ogg")
	triggerServerEvent("onPlayerRequestChangingStats",getLocalPlayer(),itemName,itemInfo,"food")
	refreshNewInventory()
  elseif itemInfo == "Open" then
  	refreshInventory()
    triggerEvent("hideInventoryManual",localPlayer)
	setPedAnimation(getLocalPlayer(),"BOMBER","BOM_Plant",-1,false,false,false,false)
	triggerServerEvent("onPlayerOpenFood",getLocalPlayer(),itemName)
	refreshNewInventory()
  elseif itemInfo == "Use Skin" then
  	refreshInventory()
    triggerEvent("hideInventoryManual",localPlayer)
	playSound("sounds/Actions/Skin.ogg")
	triggerServerEvent("onPlayerChangeSkin",getLocalPlayer(),itemName)
	refreshNewInventory()
  elseif itemName == "Empty Water Bottle" then
  	refreshInventory()
    triggerEvent("hideInventoryManual",localPlayer)
	triggerServerEvent("onPlayerRefillWaterBottle",getLocalPlayer(),itemName)
	refreshNewInventory()
  elseif itemInfo == "Set Rate" then
	guiSetVisible(SetGPSRateWindow,true)
  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 itemName == "Tent" then
  	refreshInventory()
    triggerEvent("hideInventoryManual",localPlayer)
	playSound("sounds/Actions/MontarTenda.ogg")
	triggerServerEvent("onPlayerPitchATent",getLocalPlayer(),itemName)
	refreshNewInventory()
  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)
	refreshNewInventory()
  elseif itemInfo == "Make a Fire" then
  	refreshInventory()
    triggerEvent("hideInventoryManual",localPlayer)
	triggerServerEvent("onPlayerMakeAFire",getLocalPlayer(),itemName)
	refreshNewInventory()
	elseif itemInfo == "Usar" then
        triggerServerEvent("onPlayerUseMedicObject",getLocalPlayer(),itemName)
		refreshInventory()
		refreshNewInventory()
	elseif itemName == "Bandage" then
        triggerServerEvent("onPlayerUseMedicObject",getLocalPlayer(),itemName)  
		refreshInventory()
		refreshNewInventory()
  elseif itemInfo == "Use Googles" then
  	refreshInventory()
    triggerEvent("hideInventoryManual",localPlayer)
	triggerServerEvent("onPlayerChangeView",getLocalPlayer(),itemName)
  elseif itemInfo == "Equip Primary Weapon" then 
  	refreshInventory()
    triggerEvent("hideInventoryManual",localPlayer)
  	playSound("sounds/Equip/equip1.wav")
	triggerServerEvent("onPlayerRearmWeapon",getLocalPlayer(),itemName,1)
  elseif itemInfo == "Equip Secondary Weapon" then
  	refreshInventory()
    triggerEvent("hideInventoryManual",localPlayer)
  	playSound("sounds/Equip/equip2.wav")
	triggerServerEvent("onPlayerRearmWeapon",getLocalPlayer(),itemName,2)
  elseif itemInfo == "Equip Specially Weapon" then
  	refreshInventory()
    triggerEvent("hideInventoryManual",localPlayer)
  	playSound("sounds/Equip/equip3.wav")
	triggerServerEvent("onPlayerRearmWeapon",getLocalPlayer(),itemName,3)
  elseif itemInfo == "Equip Pistol" then
  	refreshInventory()
    triggerEvent("hideInventoryManual",localPlayer)
  	playSound("sounds/Equip/equip3.wav")
	triggerServerEvent("onPlayerRearmWeapon",getLocalPlayer(),itemName,4)
  elseif itemInfo == "Use Vest" 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)
	  triggerEvent("refreshInventoryManual",localPlayer)

  elseif itemInfo == "Use Helmet" 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)
	  triggerEvent("refreshInventoryManual",localPlayer)

  elseif itemInfo == "Wear Backpack" 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","Your current itens needs to be under "..backpack[2].."!",255,22,0)
		else
		  setElementData(getLocalPlayer(),"MAX_Slots",backpack[2])
		  setElementData(getLocalPlayer(),"wearingBackpack",backpack[1])
		  triggerEvent("refreshInventoryManual",localPlayer)
		end
	  end
	end
  elseif itemInfo == "Remove Backpack" then
	if getPlayerCurrentSlots() <= 8 then
	  setElementData(getLocalPlayer(),"MAX_Slots",8)
	  setElementData(getLocalPlayer(),"wearingBackpack",false)
	  triggerEvent("refreshInventoryManual",localPlayer)
	else
	  triggerEvent("displayClientInfo",getLocalPlayer(),"inventory","Your current itens needs to be under 8!",255,22,0)
	end
  elseif itemInfo == "Remove Vest" then
	vestSlots = getActiveVestSlots(getLocalPlayer())
	if getElementData(getLocalPlayer(),"MAX_Slots")-vestSlots < getPlayerCurrentSlots() then
	  triggerEvent("displayClientInfo",getLocalPlayer(),"inventory","Your current itens needs to be under "..getElementData(getLocalPlayer(),"MAX_Slots").."!",255,22,0)
	  return
	end
	setElementData(getLocalPlayer(),getActiveVestVar(getLocalPlayer()),false)
	  triggerEvent("refreshInventoryManual",localPlayer)
  elseif itemInfo == "Remove Helmet" then
	setElementData(getLocalPlayer(),getActiveHelmetVar(getLocalPlayer()),false)
	  triggerEvent("refreshInventoryManual",localPlayer)
  end
  refreshInventory()
end

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)


function makeRadioStayOff()
  setRadioChannel(0)
end
addEventHandler("onClientPlayerVehicleEnter",getRootElement(),makeRadioStayOff)
addEventHandler("onClientPlayerRadioSwitch",getRootElement(),makeRadioStayOff)

function getPlayerSackName()
	local slots = getElementData(localPlayer,"MAX_Slots")
	if slots then
		for i, v in ipairs ( sacks ) do
			if v[2] == slots then
				return v[1]
			end
		end
	end
	return false
end
outputDebugString("inventory loaded")

 ficarei grato.

 

 

Edited by Lukkas2201
Link to comment
12 hours ago, OverKILL said:

Basta retirar a checkbox que alterna entre os inventários e desativar o padrão.

Sim eu faço isso, até então funciona de boa, mas quando eu reconecto n oservidor, ai aperto J pra abrir o inventário, não aparece nada.

e tipo, eu inicio normal o servidor, ai eu marco a checkbox do inventario modificado, ai eu removo todas as checkbox, e reinicio o servidor, ai funciona, mas só funciona porque a checkbox que está selecionada era ad o inventário modiificado, se eu tivesse deixado selecionada a check box padrão, não iria funcionar, que é o caso quando eu reconecto, quando eu reconecto no servidor, a checkbox volta pra padrão ai quando aperto J não abre o inventário.

Link to comment

Não sei porquê tanta ignorância com a minha pessoa, entendo que nos meus tópicos antigos, eu era sim meio doido da cabeça, postava umas coisas nada a ver, postava tópico atras do outro, mas eu parei com isso, e o pior é que quando eu posto, eu pergunto oque tenho que fazer, e não peço o script pronto, ao contrário de vários tópicos que vejo, de gente que pede e vão lá e fazem o script prontinho pro cara, mas quando é comigo, o povo "ignora" meu tópico, difícil pedir ajuda assim, está até parecendo que vcs só ajudam quem vocês querem ajudar, eu apenas peço para me ajudar a identificar o erro, ou a possível solução, mas nem isso fazem, complicado desse jeito.

Link to comment
  • Other Languages Moderators

Tá.

Vamos ver se eu entendi:
Você tem 2 scripts de inventário (em resources separados), um modificado e um padrão. No entanto eles estão gerando conflito e você quer fazer o inventário padrão não ser mais ativado junto com o modificado, é isso?

Link to comment
3 hours ago, Lukkas2201 said:

Não sei porquê tanta ignorância com a minha pessoa, entendo que nos meus tópicos antigos, eu era sim meio doido da cabeça, postava umas coisas nada a ver, postava tópico atras do outro, mas eu parei com isso, e o pior é que quando eu posto, eu pergunto oque tenho que fazer, e não peço o script pronto, ao contrário de vários tópicos que vejo, de gente que pede e vão lá e fazem o script prontinho pro cara, mas quando é comigo, o povo "ignora" meu tópico, difícil pedir ajuda assim, está até parecendo que vcs só ajudam quem vocês querem ajudar, eu apenas peço para me ajudar a identificar o erro, ou a possível solução, mas nem isso fazem, complicado desse jeito.

Não se trata disso jovem, as vezes a galera não entende muito bem o que você esta pedindo, então é difícil ajudar.

  • Like 1
Link to comment
3 hours ago, Lukkas2201 said:

Não sei porquê tanta ignorância com a minha pessoa, entendo que nos meus tópicos antigos, eu era sim meio doido da cabeça, postava umas coisas nada a ver, postava tópico atras do outro, mas eu parei com isso, e o pior é que quando eu posto, eu pergunto oque tenho que fazer, e não peço o script pronto, ao contrário de vários tópicos que vejo, de gente que pede e vão lá e fazem o script prontinho pro cara, mas quando é comigo, o povo "ignora" meu tópico, difícil pedir ajuda assim, está até parecendo que vcs só ajudam quem vocês querem ajudar, eu apenas peço para me ajudar a identificar o erro, ou a possível solução, mas nem isso fazem, complicado desse jeito.

Cara não é questão de ser ignorante, só que ás vezes é dificil entender o seu tópico postado, sendo assim o ignoram. Pois não sabem como ajuda-ló. 

Link to comment
1 hour ago, Lord Henry said:

Tá.

Vamos ver se eu entendi:
Você tem 2 scripts de inventário (em resources separados), um modificado e um padrão. No entanto eles estão gerando conflito e você quer fazer o inventário padrão não ser mais ativado junto com o modificado, é isso?

não, tem 2 inventarios, os dois funcionam normalmente, vc abre o padrao, e com ele aberto vc consegue alternar pro modificado e vice versa, porem queria deixar somente o modificado, pra quando abrir o inventario, ao invez de abrir o padrao , so abrir o modificado.

Link to comment
  • Moderators

Se você usasse o Ctrl+f veria que a bind fica na linha 309. Edit: Na verdade você já deve saber disso, já que falou da função showInventory no post principal. Mas o que você quer na verdade? Você quer deixar os 2 inventários rodando no server? Se não quiser é simples, tire esse inventário padrão, mas tenha em mente que ele pode ter funções sendo utilizadas em outros scripts do gamemode. Se for só a bind, tá na linha 309 como eu já disse.

Edited by DNL291
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...