Jump to content

Help for script error please


Recommended Posts

Hi, I have error in my script and i try found it but i dont understand..

 

Quote

checkZombies = function()
	for i,ped in ipairs(getElementsByType("ped",root,true)) do
		if getElementData(ped, "zombie") then
			local x,y,z = getElementPosition ( localPlayer )
			local zx,zy,zz = getElementPosition (ped)
                        setPedFootBloodEnabled(ped, true)
			local zfrontx, zfronty, zfrontz = getPositionInfrontOfElement(ped, 3)
			
			local vect1X, vect1Y =  zx-x, zy-z
			local vect2X, vect2Y = zfrontx-zx, zfronty - zy
			
			local scal = vect2X*vect1X+vect2Y*vect1Y
			
			local distance = getDistanceBetweenPoints3D ( x,y,z, zx,zy,zz )
			local sound = getElementData(getLocalPlayer(), "volume") / 5
			local visibly = getElementData(getLocalPlayer(), "visibly") / 5
			local ready = true
			if ( distance > sound*1.2 + visibly*1.2 and scal <= 0 ) or ( distance > sound*1.4 + visibly*1.4 ) then -- Расстояние за которую он вас увидит и услышит (средне)
				ready = false
			end
			if ready then
				triggerServerEvent ( "chasedStartAttackC", getLocalPlayer(), ped )
			end
		end
	end
end
setTimer(checkZombies, 2000, 0)
setElementData ( localPlayer, "spawnedzombies", 0 )


checkAnimal = function()
	for i,ped in ipairs(getElementsByType("ped",root,true)) do
		if getElementData(ped, "animal") then
			local x,y,z = getElementPosition ( localPlayer )
			local zx,zy,zz = getElementPosition (ped)
			local zfrontx, zfronty, zfrontz = getPositionInfrontOfElement(ped, 3)
			
			local vect1X, vect1Y =  zx-x, zy-z
			local vect2X, vect2Y = zfrontx-zx, zfronty - zy
			
			local scal = vect2X*vect1X+vect2Y*vect1Y
			
			local distance = getDistanceBetweenPoints3D ( x,y,z, zx,zy,zz )
			local sound = getElementData(getLocalPlayer(), "volume") / 3
			local visibly = getElementData(getLocalPlayer(), "visibly") / 3
			local ready = true
			if ( distance > sound*3 + visibly*3 and scal <= 0 ) or ( distance > sound*3 + visibly*3 ) then -- Расстояние за которую он вас увидит и услышит (ДАЛЕКО)
				ready = false 
			end
			if ready then
				triggerServerEvent ( "animalStopFollow", getLocalPlayer(), ped )
			end
		end
	end
end
setTimer(checkAnimal, 2000, 0)
setElementData ( localPlayer, "spawnedzombies", 0 )

checkKiller = function()
	for i,ped in ipairs(getElementsByType("ped",root,true)) do
		if getElementData(ped, "killer") then
			local x,y,z = getElementPosition ( localPlayer )
			local zx,zy,zz = getElementPosition (ped)
			local zfrontx, zfronty, zfrontz = getPositionInfrontOfElement(ped, 3)
			
			local vect1X, vect1Y =  zx-x, zy-z
			local vect2X, vect2Y = zfrontx-zx, zfronty - zy
			
			local scal = vect2X*vect1X+vect2Y*vect1Y
			
			local distance = getDistanceBetweenPoints3D ( x,y,z, zx,zy,zz )
			local sound = getElementData(getLocalPlayer(), "volume") / 5
			local visibly = getElementData(getLocalPlayer(), "visibly") / 5
			local ready = true
			if ( distance > sound*3 + visibly*3 and scal <= 0 ) or ( distance > sound*3 + visibly*3 ) then -- Расстояние за которую он вас увидит и услышит (ДАЛЕКО)
				ready = false 
			end
			if ready then
				triggerServerEvent ( "chasedStartAttackC", getLocalPlayer(), ped )
			end
		end
	end
end
setTimer(checkKiller, 2000, 0)
setElementData ( localPlayer, "spawnedzombies", 0 )

checkboss4aki = function()
	for i,ped in ipairs(getElementsByType("ped",root,true)) do
		if getElementData(ped, "boss4aki") then
			local x,y,z = getElementPosition ( localPlayer )
			local zx,zy,zz = getElementPosition (ped)
			local zfrontx, zfronty, zfrontz = getPositionInfrontOfElement(ped, 3)
			
			local vect1X, vect1Y =  zx-x, zy-z
			local vect2X, vect2Y = zfrontx-zx, zfronty - zy
			
			local scal = vect2X*vect1X+vect2Y*vect1Y
			
			local distance = getDistanceBetweenPoints3D ( x,y,z, zx,zy,zz )
			local sound = getElementData(getLocalPlayer(), "volume") / 5
			local visibly = getElementData(getLocalPlayer(), "visibly") / 5
			local ready = true
			if ( distance > sound*3 + visibly*3 and scal <= 0 ) or ( distance > sound*3 + visibly*3 ) then -- Расстояние за которую он вас увидит и услышит (ДАЛЕКО)
				ready = false 
			end
			if ready then
				triggerServerEvent ( "chasedStartAttackC", getLocalPlayer(), ped )
			end
		end
	end
end
setTimer(checkboss4aki, 2000, 0)
setElementData ( localPlayer, "spawnedzombies", 0 )

checksnegovik = function()
	for i,ped in ipairs(getElementsByType("ped",root,true)) do
		if getElementData(ped, "snegovik") then
			local x,y,z = getElementPosition ( localPlayer )
			local zx,zy,zz = getElementPosition (ped)
			local zfrontx, zfronty, zfrontz = getPositionInfrontOfElement(ped, 3)
			
			local vect1X, vect1Y =  zx-x, zy-z
			local vect2X, vect2Y = zfrontx-zx, zfronty - zy
			
			local scal = vect2X*vect1X+vect2Y*vect1Y
			
			local distance = getDistanceBetweenPoints3D ( x,y,z, zx,zy,zz )
			local sound = getElementData(getLocalPlayer(), "volume") / 5
			local visibly = getElementData(getLocalPlayer(), "visibly") / 5
			local ready = true
			if ( distance > sound*3 + visibly*5 and scal <= 0 ) or ( distance > sound*3 + visibly*3 ) then -- Расстояние за которую он вас увидит и услышит (ДАЛЕКО)
				ready = false 
			end
			if ready then
				triggerServerEvent ( "chasedStartAttackC", getLocalPlayer(), ped )
			end
		end
	end
end
setTimer(checksnegovik, 2000, 0)
setElementData ( localPlayer, "spawnedzombies", 0 )

checksanta = function()
	for i,ped in ipairs(getElementsByType("ped",root,true)) do
		if getElementData(ped, "santa") then
			local x,y,z = getElementPosition ( localPlayer )
			local zx,zy,zz = getElementPosition (ped)
			local zfrontx, zfronty, zfrontz = getPositionInfrontOfElement(ped, 3)
			
			local vect1X, vect1Y =  zx-x, zy-z
			local vect2X, vect2Y = zfrontx-zx, zfronty - zy
			
			local scal = vect2X*vect1X+vect2Y*vect1Y
			
			local distance = getDistanceBetweenPoints3D ( x,y,z, zx,zy,zz )
			local sound = getElementData(getLocalPlayer(), "volume") / 5
			local visibly = getElementData(getLocalPlayer(), "visibly") / 5
			local ready = true
			if ( distance > sound*3 + visibly*5 and scal <= 0 ) or ( distance > sound*3 + visibly*3 ) then -- Расстояние за которую он вас увидит и услышит (ДАЛЕКО)
				ready = false 
			end
			if ready then
				triggerServerEvent ( "chasedStartAttackC", getLocalPlayer(), ped )
			end
		end
	end
end
setTimer(checksanta, 2000, 0)
setElementData ( localPlayer, "spawnedzombies", 0 )

checkBots = function()
	for i,ped in ipairs(getElementsByType("ped",root,true)) do
		if getElementData(ped, "bots") then
			local x,y,z = getElementPosition ( localPlayer )
			local zx,zy,zz = getElementPosition (ped)
			local zfrontx, zfronty, zfrontz = getPositionInfrontOfElement(ped, 3)
			
			local vect1X, vect1Y =  zx-x, zy-z
			local vect2X, vect2Y = zfrontx-zx, zfronty - zy
			
			local scal = vect2X*vect1X+vect2Y*vect1Y
			
			local distance = getDistanceBetweenPoints3D ( x,y,z, zx,zy,zz )
			local sound = getElementData(getLocalPlayer(), "volume") / 3
			local visibly = getElementData(getLocalPlayer(), "visibly") / 3
			local ready = true
			if ( distance > sound*3 + visibly*5 and scal <= 0 ) or ( distance > sound*3 + visibly*3 ) then -- Расстояние за которую он вас увидит и услышит (ДАЛЕКО)
				ready = false 
			end
			if ready then
				triggerServerEvent ( "botsStartAttack", getLocalPlayer(), ped )
			end
		end
	end
end
setTimer(checkBots, 2000, 0)
setElementData ( localPlayer, "spawnedzombies", 0 )

checkbossBenz = function()
	for i,ped in ipairs(getElementsByType("ped",root,true)) do
		if getElementData(ped, "bossBenz") then
			local x,y,z = getElementPosition ( localPlayer )
			local zx,zy,zz = getElementPosition (ped)
			local zfrontx, zfronty, zfrontz = getPositionInfrontOfElement(ped, 3)
			
			local vect1X, vect1Y =  zx-x, zy-z
			local vect2X, vect2Y = zfrontx-zx, zfronty - zy
			
			local scal = vect2X*vect1X+vect2Y*vect1Y
			
			local distance = getDistanceBetweenPoints3D ( x,y,z, zx,zy,zz )
			local sound = getElementData(getLocalPlayer(), "volume") / 5
			local visibly = getElementData(getLocalPlayer(), "visibly") / 5
			local ready = true
			if ( distance > sound*3 + visibly*5 and scal <= 0 ) or ( distance > sound*3 + visibly*3 ) then -- Расстояние за которую он вас увидит и услышит (ДАЛЕКО)
				ready = false 
			end
			if ready then
				triggerServerEvent ( "chasedStartAttackC", getLocalPlayer(), ped )
			end
		end
	end
end
setTimer(checkbossBenz, 2000, 0)
setElementData ( localPlayer, "spawnedzombies", 0 )

checkbossCrais = function()
	for i,ped in ipairs(getElementsByType("ped",root,true)) do
		if getElementData(ped, "bossCrais") then
			local x,y,z = getElementPosition ( localPlayer )
			local zx,zy,zz = getElementPosition (ped)
			local zfrontx, zfronty, zfrontz = getPositionInfrontOfElement(ped, 3)
			
			local vect1X, vect1Y =  zx-x, zy-z
			local vect2X, vect2Y = zfrontx-zx, zfronty - zy
			
			local scal = vect2X*vect1X+vect2Y*vect1Y
			
			local distance = getDistanceBetweenPoints3D ( x,y,z, zx,zy,zz )
			local sound = getElementData(getLocalPlayer(), "volume") / 5
			local visibly = getElementData(getLocalPlayer(), "visibly") / 5
			local ready = true
			if ( distance > sound*3 + visibly*5 and scal <= 0 ) or ( distance > sound*3 + visibly*3 ) then -- Расстояние за которую он вас увидит и услышит (ДАЛЕКО)
				ready = false 
			end
			if ready then
				triggerServerEvent ( "chasedStartAttackC", getLocalPlayer(), ped )
			end
		end
	end
end
setTimer(checkbossCrais, 2000, 0)
setElementData ( localPlayer, "spawnedzombies", 0 )

function zombieJump(ped)
	if (isElement(source)) then
		setPedControlState(source,"jump",true)
		setTimer(function(source) 
			if (isElement(source)) then 
				setPedControlState(source,"jump",false) 
			end 
		end,800,1,source)
	end
end
addEventHandler("bot_Jump",getRootElement(),zombieJump)
addEvent("bot_Jump",true)

function getPositionInfrontOfElement(element, meters)
    if not element or not isElement(element) then
        return false
    end
    if not meters then
        meters = 3
    end
    local posX, posY, posZ = getElementPosition(element)
    local _, _, rotation = getElementRotation(element)
    posX = posX - math.sin(math.rad(rotation)) * meters
    posY = posY + math.cos(math.rad(rotation)) * meters
    return posX, posY, posZ
end

local fires = 0
local shotCheckAvailable = true

function onClientPlayerWeaponFireFunc(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement )
	if getElementData ( localPlayer, "isPlayerZombie" ) then return true end
	if shotCheckAvailable then
		if weapon > 9 and weapon ~= 23 then
			shotCheckAvailable = false
			setTimer ( function () shotCheckAvailable = true end, 4000, 1 )
			local zombs = getElementsByType ( "ped", getRootElement(), true )
			local x,y,z = getElementPosition ( localPlayer )
			for i,zomb in ipairs(zombs) do 
				if not getElementData ( zomb, "target" ) and not getElementData ( zomb, "zHeared" ) then
					local zx,zy,zz = getElementPosition (zomb)
					if getDistanceBetweenPoints3D ( x,y,z, zx,zy,zz ) < 50 then
						triggerServerEvent ("zombieHeared", localPlayer, zomb )
					end
				end
			end
		end
	end
end
addEventHandler ( "onClientPlayerWeaponFire", getLocalPlayer(), onClientPlayerWeaponFireFunc )

function findRotation(x1,y1,x2,y2)
	local t = -math.deg(math.atan2(x2-x1,y2-y1))
	if t < 0 then t = t + 360 end;
	return t
end

 

SurvivorSystem_client.Lua

Quote

setPlayerHudComponentVisible ( "area_name", false )
setPlayerHudComponentVisible ( "vehicle_name", false )
addEventHandler("onClientResourceStart",resourceRoot,function()
	versionLabel = guiCreateLabel(1,1,0.3,0.3,"DayZ Survival v1.1",true)
	guiSetSize(versionLabel, guiLabelGetTextExtent ( versionLabel ), guiLabelGetFontHeight ( versionLabel ), false )
	x,y = guiGetSize(versionLabel,true)
	guiSetPosition( versionLabel, 1-x, 1-y*1.8, true )
	guiSetAlpha(versionLabel,0.5)
	
	versionLabel2 = guiCreateLabel(1,1,0.3,0.3,"".. string.sub(getPlayerSerial(getLocalPlayer()), 25) .."",true)
	guiSetSize(versionLabel2, guiLabelGetTextExtent ( versionLabel2 ), guiLabelGetFontHeight ( versionLabel2 ), false )
	x,y = guiGetSize(versionLabel2,true)
	guiSetPosition(versionLabel2, 1-x, 1-y*2.6, true )
	guiSetAlpha(versionLabel2,0.5)
end)

for i,vestData in pairs(VestsTable) do
  file = vestData[1]:gsub(' ','')
  if fileExists("mods/"..file..".txd") and fileExists("mods/"..file..".dff")then
	txd = engineLoadTXD("mods/"..file..".txd",vestData[3])
	engineImportTXD(txd,vestData[3])
	dff = engineLoadDFF("mods/"..file..".dff",vestData[3])
	engineReplaceModel(dff,vestData[3])
  else
	outputChatBox("ERROR: mods/"..file)
  end
end

for i,helmetData in pairs(HelmetsTable) do
  file = helmetData[1]:gsub(' ','')
  if fileExists("mods/"..file..".txd") and fileExists("mods/"..file..".dff")then
	txd = engineLoadTXD("mods/"..file..".txd",helmetData[3])
	engineImportTXD(txd,helmetData[3])
	dff = engineLoadDFF("mods/"..file..".dff",helmetData[3])
	engineReplaceModel(dff,helmetData[3])
  else
	outputChatBox("ERROR: mods/"..file)
  end
end

Itens = {
  --{Arquivo="SteelSheet"},ID=1664},
  {Arquivo="Compass",ID=1488},
  {Arquivo="M203HE",ID=1925},
  {Arquivo="Handcuffs",ID=1551},
  {Arquivo="ScrapMetal",ID=1577},
  {Arquivo="Glass",ID=1654},
  {Arquivo="Bandage",ID=1578},
  {Arquivo="BloodBag",ID=1580},
  {Arquivo="BoxOfMatches",ID=328},
  {Arquivo="CookedMeat",ID=2806},
  {Arquivo="Engine",ID=929},
  {Arquivo="GasCanister",ID=1650},
  {Arquivo="Goggles",ID=368},
  {Arquivo="Goggles",ID=369},
  {Arquivo="GPS",ID=2976},
  {Arquivo="Map",ID=1277},
  {Arquivo="MedicBox",ID=1558},
  {Arquivo="Morphine",ID=1579},
  {Arquivo="MorphineAutoInjector",ID=14673},
  {Arquivo="RawMeat",ID=2804},
  {Arquivo="Roadflare",ID=324},
  {Arquivo="RoadflareOn",ID=354},
  {Arquivo="Rotor",ID=1669},
  {Arquivo="TankParts",ID=1008},
  {Arquivo="Tent2",ID=1512},
  {Arquivo="Tire",ID=1073},
  {Arquivo="Toolbox",ID=2969},
  {Arquivo="Watch",ID=2710},
  {Arquivo="WireFence2",ID=933},
  {Arquivo="WoodPile",ID=1463},
  {Arquivo="Mine",ID=1897}
}

for i,Item in pairs(Itens)do
  txd = engineLoadTXD("items/"..Item.Arquivo..".txd",Item.ID)
  engineImportTXD(txd,Item.ID)
  dff = engineLoadDFF("items/"..Item.Arquivo..".dff",Item.ID)
  engineReplaceModel(dff,Item.ID)
end


itemTXD = engineLoadTXD("mods/trap_closed.txd")
engineImportTXD(itemTXD,1918)
itemDFF = engineLoadDFF("mods/trap_closed.dff",1918)
engineReplaceModel(itemDFF,1918)
itemCOL = engineLoadCOL("mods/trap_closed.col")
engineReplaceCOL(itemCOL,1918)
itemTXD = engineLoadTXD("mods/trap_open.txd")
engineImportTXD(itemTXD,1920)
itemDFF = engineLoadDFF("mods/trap_open.dff",1920)
engineReplaceModel(itemDFF,1920)
itemCOL = engineLoadCOL("mods/trap_open.col")
engineReplaceCOL(itemCOL,1920)
snipertxd = engineLoadTXD("mods/jackcarrepair.txd")
engineImportTXD(snipertxd,2015)
sniperdff = engineLoadDFF("mods/jackcarrepair.dff",2015)
engineReplaceModel(sniperdff,2015)
snipertxd = engineLoadTXD("mods/canopen.txd")
engineImportTXD(snipertxd,2014)
sniperdff = engineLoadDFF("mods/canopen.dff",2014)
engineReplaceModel(sniperdff,2014)
snipertxd = engineLoadTXD("mods/Seringa.txd")
engineImportTXD(snipertxd,2000)
sniperdff = engineLoadDFF("mods/Seringa.dff",2000)
engineReplaceModel(sniperdff,2000)
snipertxd = engineLoadTXD("mods/sniper.txd")
engineImportTXD(snipertxd,285)
sniperdff = engineLoadDFF("mods/sniper.dff",285)
engineReplaceModel(sniperdff,285)
snipertxd = engineLoadTXD("mods/female.txd")
engineImportTXD(snipertxd,191)
sniperdff = engineLoadDFF("mods/female.dff",191)
engineReplaceModel(sniperdff,191)
snipertxd = engineLoadTXD("mods/ghillie_suit_woman.txd")
engineImportTXD(snipertxd,94)
sniperdff = engineLoadDFF("mods/ghillie_suit_woman.dff",94)
engineReplaceModel(sniperdff,94)
snipertxd = engineLoadTXD("mods/civ_girl.txd")
engineImportTXD(snipertxd,93)
sniperdff = engineLoadDFF("mods/civ_girl.dff",93)
engineReplaceModel(sniperdff,93)
snipertxd = engineLoadTXD("mods/civilian.txd")
engineImportTXD(snipertxd,179)
sniperdff = engineLoadDFF("mods/civilian.dff",179)
engineReplaceModel(sniperdff,179)
snipertxd = engineLoadTXD("mods/sniper2.txd")
engineImportTXD(snipertxd,287)
sniperdff = engineLoadDFF("mods/sniper2.dff",287)
engineReplaceModel(sniperdff,287)
snipertxd = engineLoadTXD("mods/standart.txd")
engineImportTXD(snipertxd,73)
sniperdff = engineLoadDFF("mods/standart.dff",73)
engineReplaceModel(sniperdff,73)
snipertxd = engineLoadTXD("mods/femalestandard.txd")
engineImportTXD(snipertxd,191)
sniperdff = engineLoadDFF("mods/femalestandard.dff",191)
engineReplaceModel(sniperdff,191)
itemTXD = engineLoadTXD("items/Antibiotics.txd")
engineImportTXD(itemTXD,1509)
itemDFF = engineLoadDFF("items/Antibiotics.dff",1509)
engineReplaceModel(itemDFF,1509)

itemTXD = engineLoadTXD("items/Clothes.txd")
engineImportTXD(itemTXD,1241)
itemDFF = engineLoadDFF("items/Clothes.dff",1241)
engineReplaceModel(itemDFF,1241)

itemTXD = engineLoadTXD("items/beans_can.txd")
engineImportTXD(itemTXD,2601)
itemDFF = engineLoadDFF("items/beans_can.dff",2601)
engineReplaceModel(itemDFF,2601)
itemTXD = engineLoadTXD("items/soda_bottle.txd")
engineImportTXD(itemTXD,2856)
itemDFF = engineLoadDFF("items/soda_bottle.dff",2856)
engineReplaceModel(itemDFF,2856)
itemTXD = engineLoadTXD("items/first_aid_kit.txd")
engineImportTXD(itemTXD,2891)
itemDFF = engineLoadDFF("items/first_aid_kit.dff",2891)
engineReplaceModel(itemDFF,2891)
itemTXD = engineLoadTXD("items/heat_pack.txd")
engineImportTXD(itemTXD,1576)
itemDFF = engineLoadDFF("items/heat_pack.dff",1576)
engineReplaceModel(itemDFF,1576)
itemTXD = engineLoadTXD("items/pain_killers.txd")
engineImportTXD(itemTXD,2709)
itemDFF = engineLoadDFF("items/pain_killers.dff",2709)
engineReplaceModel(itemDFF,2709)
itemTXD = engineLoadTXD("items/pasta_can.txd")
engineImportTXD(itemTXD,2770)
itemDFF = engineLoadDFF("items/pasta_can.dff",2770)
engineReplaceModel(itemDFF,2770)


itemTXD = engineLoadTXD("items/CannedSardines.txd")
engineImportTXD(itemTXD,1242)
itemDFF = engineLoadDFF("items/CannedSardines.dff",1242)
engineReplaceModel(itemDFF,1242)

itemTXD = engineLoadTXD("items/CanOfTacticalBacon.txd")
engineImportTXD(itemTXD,1247)
itemDFF = engineLoadDFF("items/CanOfTacticalBacon.dff",1247)
engineReplaceModel(itemDFF,1247)



itemTXD = engineLoadTXD("items/pistol_ammo.txd")
engineImportTXD(itemTXD,3013)
itemDFF = engineLoadDFF("items/pistol_ammo.dff",3013)
engineReplaceModel(itemDFF,3013)
itemTXD = engineLoadTXD("items/shotgun_ammo.txd")
engineImportTXD(itemTXD,2358)
itemDFF = engineLoadDFF("items/shotgun_ammo.dff",2358)
engineReplaceModel(itemDFF,2358)
itemTXD = engineLoadTXD("items/backpack_small.txd")
engineImportTXD(itemTXD,3026)
itemDFF = engineLoadDFF("items/backpack_small.dff",3026)
engineReplaceModel(itemDFF,3026)
itemTXD = engineLoadTXD("items/smg_ammo.txd")
engineImportTXD(itemTXD,2041)
itemDFF = engineLoadDFF("items/smg_ammo.dff",2041)
engineReplaceModel(itemDFF,2041)
itemTXD = engineLoadTXD("items/sniper_ammo.txd")
engineImportTXD(itemTXD,2358)
itemDFF = engineLoadDFF("items/sniper_ammo.dff",2358)
engineReplaceModel(itemDFF,2358)
itemTXD = engineLoadTXD("items/soda_can.txd")
engineImportTXD(itemTXD,2647)
itemDFF = engineLoadDFF("items/soda_can.dff",2647)
engineReplaceModel(itemDFF,2647)
itemTXD = engineLoadTXD("items/water_bottle.txd")
engineImportTXD(itemTXD,2683)
itemDFF = engineLoadDFF("items/water_bottle.dff",2683)
engineReplaceModel(itemDFF,2683)
itemTXD = engineLoadTXD("items/backpack_alice.txd")
engineImportTXD(itemTXD,1248)
itemDFF = engineLoadDFF("items/backpack_alice.dff",1248)
engineReplaceModel(itemDFF,1248)
itemTXD = engineLoadTXD("items/backpack_coyote.txd")
engineImportTXD(itemTXD,1252)
itemDFF = engineLoadDFF("items/backpack_coyote.dff",1252)
engineReplaceModel(itemDFF,1252)
itemTXD = engineLoadTXD("items/backpack_czech.txd")
engineImportTXD(itemTXD,2472)
itemDFF = engineLoadDFF("items/backpack_czech.dff",2472)
engineReplaceModel(itemDFF,2472)

--Skin ammo
itemTXD = engineLoadTXD("items/stanag_ammo.txd")
engineImportTXD(itemTXD,1271)
itemDFF = engineLoadDFF("items/stanag_ammo.dff",1271)
engineReplaceModel(itemDFF,1271)

itemTXD = engineLoadTXD("items/ak_ammo.txd")
engineImportTXD(itemTXD,1913)
itemDFF = engineLoadDFF("items/ak_ammo.dff",1913)
engineReplaceModel(itemDFF,1913)

itemTXD = engineLoadTXD("items/mp5_ammo.txd")
engineImportTXD(itemTXD,1920)
itemDFF = engineLoadDFF("items/mp5_ammo.dff",1920)
engineReplaceModel(itemDFF,1920)

itemTXD = engineLoadTXD("items/rambo_ammo.txd")
engineImportTXD(itemTXD,1921)
itemDFF = engineLoadDFF("items/rambo_ammo.dff",1921)
engineReplaceModel(itemDFF,1921)

itemTXD = engineLoadTXD("items/m107_ammo.txd")
engineImportTXD(itemTXD,1926)
itemDFF = engineLoadDFF("items/m107_ammo.dff",1926)
engineReplaceModel(itemDFF,1926)

itemTXD = engineLoadTXD("items/shot_ammo.txd")
engineImportTXD(itemTXD,1927)
itemDFF = engineLoadDFF("items/shot_ammo.dff",1927)
engineReplaceModel(itemDFF,1927)

--Novas Mochilas
itemTXD = engineLoadTXD("items/Tactical_Backpack.txd")
engineImportTXD(itemTXD,1815)
itemDFF = engineLoadDFF("items/Tactical_Backpack.dff",1815)
engineReplaceModel(itemDFF,1815)

--Novas Mochilas
itemTXD = engineLoadTXD("items/backpack_mossy_coyote.txd")
engineImportTXD(itemTXD,1743)
itemDFF = engineLoadDFF("items/backpack_mossy_coyote.dff",1743)
engineReplaceModel(itemDFF,1743)

--Novas Mochilas
itemTXD = engineLoadTXD("items/backpack_desert_coyote.txd")
engineImportTXD(itemTXD,1742)
itemDFF = engineLoadDFF("items/backpack_desert_coyote.dff",1742)
engineReplaceModel(itemDFF,1742)

--Novas Mochilas
itemTXD = engineLoadTXD("items/backpack_survival.txd")
engineImportTXD(itemTXD,2405)
itemDFF = engineLoadDFF("items/backpack_survival.dff",2405)
engineReplaceModel(itemDFF,2405)
--
--Novas Mochilas
itemTXD = engineLoadTXD("items/backpack_british.txd")
engineImportTXD(itemTXD,2406)
itemDFF = engineLoadDFF("items/backpack_british.dff",2406)
engineReplaceModel(itemDFF,2406)
--
--Novas Mochilas
itemTXD = engineLoadTXD("items/backpack_patrol.txd")
engineImportTXD(itemTXD,1486)
itemDFF = engineLoadDFF("items/backpack_patrol.dff",1486)
engineReplaceModel(itemDFF,1486)

--Novas Mochilas
itemTXD = engineLoadTXD("items/mountain_backpack.txd")
engineImportTXD(itemTXD,1517)
itemDFF = engineLoadDFF("items/mountain_backpack.dff",1517)
engineReplaceModel(itemDFF,1517)

--Novas Mochilas
itemTXD = engineLoadTXD("items/backpack_czech1.txd")
engineImportTXD(itemTXD,1520)
itemDFF = engineLoadDFF("items/backpack_czech1.dff",1520)
engineReplaceModel(itemDFF,1520)

--Novas Mochilas
itemTXD = engineLoadTXD("items/backpack_czech2.txd")
engineImportTXD(itemTXD,1541)
itemDFF = engineLoadDFF("items/backpack_czech2.dff",1541)
engineReplaceModel(itemDFF,1541)

--Novas Mochilas
itemTXD = engineLoadTXD("items/backpack_czech3.txd")
engineImportTXD(itemTXD,1542)
itemDFF = engineLoadDFF("items/backpack_czech3.dff",1542)
engineReplaceModel(itemDFF,1542)
--
--Novas Mochilas
itemTXD = engineLoadTXD("items/backpack_vest.txd")
engineImportTXD(itemTXD,1777)
itemDFF = engineLoadDFF("items/backpack_vest.dff",1777)
engineReplaceModel(itemDFF,1777)
--
itemTXD = engineLoadTXD("items/tent.txd")
engineImportTXD(itemTXD,3243)
itemDFF = engineLoadDFF("items/tent.dff",3243)
engineReplaceModel(itemDFF,3243)
col = engineLoadCOL("items/tent.col")
engineReplaceCOL(col,3243)
engineSetModelLODDistance(3243,60)
itemTXD = engineLoadTXD("items/bigtent.txd")
engineImportTXD(itemTXD,2779)
itemDFF = engineLoadDFF("items/bigtent.dff",2779)
engineReplaceModel(itemDFF,2779)
col = engineLoadCOL("items/bigtent.col")
engineReplaceCOL(col,2779)
engineSetModelLODDistance(2779,60)
itemTXD = engineLoadTXD("items/wirefence.txd")
engineImportTXD(itemTXD,983)
itemDFF = engineLoadDFF("items/wirefence.dff",983)
engineReplaceModel(itemDFF,983)
weaponTXD = engineLoadTXD("items/camera.txd")
engineImportTXD(weaponTXD,367)
weaponDFF = engineLoadDFF("items/camera.dff",367)
engineReplaceModel(weaponDFF,367)
weaponTXD = engineLoadTXD("items/katana.txd")
engineImportTXD(weaponTXD,339)
weaponDFF = engineLoadDFF("items/katana.dff",339)
engineReplaceModel(weaponDFF,339)

setTimer(function()
  if getElementData(getLocalPlayer(),"logedin") then
	toggleControl("radar",false)
	setPlayerHudComponentVisible("clock",false)
	setPlayerHudComponentVisible("radar",false)
	setPlayerHudComponentVisible("money",false)
	setPlayerHudComponentVisible("health",false)
	setPlayerHudComponentVisible("breath",false)
	if getElementData(getLocalPlayer(),"Map") >= 1 then
	  toggleControl("radar",true)
	end
	if 1 <= getElementData(getLocalPlayer(),"GPS") then
	  setPlayerHudComponentVisible("radar",true)
	end
	if 1 <= getElementData(getLocalPlayer(),"Watch") then
	  setPlayerHudComponentVisible("clock",true)
	end
  end
end,1000,0)
function playerZoom(key,keyState)
  if key == "n" then
	if getElementData(getLocalPlayer(),"Night Vision Goggles") >= 1 then
	  if nightvision then
		nightvision = false
		setCameraGoggleEffect("normal")
		local hour,minutes = getTime()
		setClientNight(hour,minutes)
	  else
		nightvision = true
		setCameraGoggleEffect("nightvision")
		setFarClipDistance(1000)
	  end
	end
  elseif key == "i" and getElementData(getLocalPlayer(),"Infrared Goggles") >= 1 then
	if infaredvision then
	  infaredvision = false
	  setCameraGoggleEffect("normal")
	  setClientNight(hour,minutes)
	else
	  infaredvision = true
	  setCameraGoggleEffect("thermalvision")
	end
  end
end
bindKey("n","down",playerZoom)
bindKey("i","up",playerZoom)
function setClientNight(hour,minutes)
  if hour == 21 then
	setSkyGradient(0,100 / minutes,196 / minutes,136 / minutes,170 / minutes,212 / minutes)
	setFarClipDistance(120 +(880 - minutes * 14.6))
	setFogDistance(-150 +(250 - minutes * 4.16))
  elseif hour == 7 then
	setSkyGradient(0,1.6 * minutes,638.9599999999999,307.35999999999996,481.1,748.36)
	setFarClipDistance(120 + minutes * 14.6)
	setFogDistance(-150 + minutes * 4.16)
  elseif hour == 22 or hour == 23 then
	setSkyGradient(0,0,0,0,0,0)
	setFarClipDistance(120)
	setFogDistance(-150)
  elseif hour >= 0 and hour <= 7 then
	setSkyGradient(0,0,0,0,0,0)
	setFarClipDistance(120)
	setFogDistance(-150)
  else
	setSkyGradient(0,100,196,136,170,212)
	setFarClipDistance(1000)
	setFogDistance(100)
  end
end
local skin = engineLoadTXD("skins/22.txd")
engineImportTXD(skin,22)
local skin = engineLoadTXD("skins/56.txd")
engineImportTXD(skin,56)
local skin = engineLoadTXD("skins/67.txd")
engineImportTXD(skin,67)
local skin = engineLoadTXD("skins/68.txd")
engineImportTXD(skin,68)
local skin = engineLoadTXD("skins/69.txd")
engineImportTXD(skin,69)
local skin = engineLoadTXD("skins/70.txd")
engineImportTXD(skin,70)
local skin = engineLoadTXD("skins/84.txd")
engineImportTXD(skin,84)
local skin = engineLoadTXD("skins/92.txd")
local skin = engineLoadTXD("skins/97.txd")
engineImportTXD(skin,97)
local skin = engineLoadTXD("skins/105.txd")
engineImportTXD(skin,105)
local skin = engineLoadTXD("skins/107.txd")
engineImportTXD(skin,107)
local skin = engineLoadTXD("skins/108.txd")
engineImportTXD(skin,108)
local skin = engineLoadTXD("skins/111.txd")
engineImportTXD(skin,111)
local skin = engineLoadTXD("skins/126.txd")
engineImportTXD(skin,126)
local skin = engineLoadTXD("skins/127.txd")
engineImportTXD(skin,127)
local skin = engineLoadTXD("skins/128.txd")
engineImportTXD(skin,128)
local skin = engineLoadTXD("skins/152.txd")
engineImportTXD(skin,152)
local skin = engineLoadTXD("skins/162.txd")
engineImportTXD(skin,162)
local skin = engineLoadTXD("skins/167.txd")
engineImportTXD(skin,167)
local skin = engineLoadTXD("skins/188.txd")
engineImportTXD(skin,188)
local skin = engineLoadTXD("skins/192.txd")
engineImportTXD(skin,192)
local skin = engineLoadTXD("skins/195.txd")
engineImportTXD(skin,195)
local skin = engineLoadTXD("skins/206.txd")
engineImportTXD(skin,206)
local skin = engineLoadTXD("skins/209.txd")
engineImportTXD(skin,209)
local skin = engineLoadTXD("skins/212.txd")
engineImportTXD(skin,212)
local skin = engineLoadTXD("skins/229.txd")
engineImportTXD(skin,229)
local skin = engineLoadTXD("skins/230.txd")
engineImportTXD(skin,230)
local skin = engineLoadTXD("skins/258.txd")
engineImportTXD(skin,258)
local skin = engineLoadTXD("skins/264.txd")
engineImportTXD(skin,264)
local skin = engineLoadTXD("skins/274.txd")
engineImportTXD(skin,274)
local skin = engineLoadTXD("skins/277.txd")
engineImportTXD(skin,277)
local skin = engineLoadTXD("skins/280.txd")
engineImportTXD(skin,280)

--[[function math.round(number,decimals,method)
  decimals = decimals or 0
  local factor = 10 ^ decimals
  if method == "ceil" or method == "floor" then
	return math[method](number * factor)/ factor
  else
	return tonumber(("%."..decimals.."f"):format(number))
  end
end]]

function math.round(number, decimals, method)
    decimals = decimals or 0
    local factor = 10 ^ decimals
    if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor
    else return tonumber(("%."..decimals.."f"):format(number)) end
end

statsLabel = {}

statsWindows = guiCreateStaticImage(0.85, 0.18, 0.19, 0.17, "images/debug.png",true)
guiSetAlpha(statsWindows,0.8)
 

statsLabel["zombieskilled1"] = guiCreateLabel(0.43, 0.19, 0.35, 0.15, "0", true, statsWindows)
	guiLabelSetHorizontalAlign(statsLabel["zombieskilled1"], "right", false)
	guiSetFont(statsLabel["zombieskilled1"], "default-medium-small" )
	setElementData(statsLabel["zombieskilled1"],"identifikation","zombieskilled")
statsLabel["murders1"] = guiCreateLabel(0.43, 0.04, 0.35, 0.15, "0", true, statsWindows)
	guiLabelSetHorizontalAlign(statsLabel["murders1"], "right", false)  
	guiSetFont(statsLabel["murders1"], "default-medium-small" )
	setElementData(statsLabel["murders1"],"identifikation","murders")
statsLabel["headshots1"] = guiCreateLabel(0.43, 0.48, 0.35, 0.15, "0", true, statsWindows)
	guiLabelSetHorizontalAlign(statsLabel["headshots1"], "right", false)
	guiSetFont(statsLabel["headshots1"], "default-medium-small" )
	setElementData(statsLabel["headshots1"],"identifikation","headshots")
statsLabel["banditskilled1"] = guiCreateLabel(0.43, 0.33, 0.35, 0.15, "0", true, statsWindows)
	guiLabelSetHorizontalAlign(statsLabel["banditskilled1"], "right", false)
	guiSetFont(statsLabel["banditskilled1"], "default-medium-small" )
	setElementData(statsLabel["banditskilled1"],"identifikation","banditskilled")
statsLabel["humanity1"] = guiCreateLabel(0.43, 0.62, 0.35, 0.15, "0", true, statsWindows)
	guiLabelSetHorizontalAlign(statsLabel["humanity1"], "right", false)
	guiSetFont(statsLabel["humanity1"], "default-medium-small" )
	setElementData(statsLabel["humanity1"],"identifikation","humanity")
statsLabel["blood1"] = guiCreateLabel(0.43, 0.76, 0.35, 0.15, " 12000", true, statsWindows)
	guiLabelSetHorizontalAlign(statsLabel["blood1"], "right", false)
	guiSetFont(statsLabel["blood1"], "default-medium-small" )
	guiLabelSetColor(statsLabel["blood1"], 255, 255, 255)
	setElementData(statsLabel["blood1"],"identifikation","blood")

statsLabel["murders"] = guiCreateLabel(0.02, 0.05, 0.31, 0.45, "Murders:",true,statsWindows)
statsLabel["murders"] = guiCreateLabel(0.02, 0.05, 0.31, 0.45, "Murders:",true,statsWindows)   
guiSetFont (statsLabel["murders"], "default-medium-small" )
guiLabelSetColor(statsLabel["murders"], 255, 255, 255)

statsLabel["zombieskilled"] = guiCreateLabel(0.02, 0.19, 0.41, 0.45, "Zombies killed:",true,statsWindows)
statsLabel["zombieskilled"] = guiCreateLabel(0.02, 0.19, 0.41, 0.45, "Zombies killed:",true,statsWindows)
guiSetFont (statsLabel["zombieskilled"], "default-medium-small" )
guiLabelSetColor(statsLabel["zombieskilled"], 255, 255, 255)

statsLabel["banditskilled"] = guiCreateLabel(0.02, 0.33, 0.41, 0.45,"Bandits killed:",true,statsWindows)
statsLabel["banditskilled"] = guiCreateLabel(0.02, 0.33, 0.41, 0.45,"Bandits killed:",true,statsWindows)
guiSetFont (statsLabel["banditskilled"], "default-medium-small" )
guiLabelSetColor(statsLabel["banditskilled"], 255, 255, 255)

statsLabel["headshots"] = guiCreateLabel(0.02, 0.47, 0.41, 0.45, "Headshots:",true,statsWindows)
statsLabel["headshots"] = guiCreateLabel(0.02, 0.47, 0.41, 0.45, "Headshots:",true,statsWindows)
guiSetFont (statsLabel["headshots"], "default-medium-small" )
guiLabelSetColor(statsLabel["headshots"], 255, 255, 255)

statsLabel["humanity"] = guiCreateLabel(0.02, 0.61, 0.41, 0.45, "Humanity:",true,statsWindows)
statsLabel["humanity"] = guiCreateLabel(0.02, 0.61, 0.41, 0.45, "Humanity:",true,statsWindows)
guiSetFont (statsLabel["humanity"], "default-medium-small" )
guiLabelSetColor(statsLabel["humanity"], 255, 255, 255)

statsLabel["blood"] = guiCreateLabel(0.02, 0.76, 0.41, 0.25, "Blood:",true,statsWindows)
statsLabel["blood"] = guiCreateLabel(0.02, 0.76, 0.41, 0.25, "Blood:",true,statsWindows)
guiSetFont (statsLabel["blood"], "default-medium-small" )
guiLabelSetColor(statsLabel["blood"], 255, 255, 255)


if getElementData(localPlayer,"logedin") then
    guiSetVisible(statsWindows,true)
else
    guiSetVisible(statsWindows,false)
end

function showDebugMonitor ()
    local visible = guiGetVisible(statsWindows)
    guiSetVisible(statsWindows,not visible)
end
bindKey("F5","down",showDebugMonitor)

function showDebugMintorOnLogin ()
    guiSetVisible(statsWindows,true)
end
addEvent("onClientPlayerDayZLogin", true)
addEventHandler("onClientPlayerDayZLogin", root, showDebugMintorOnLogin)

function refreshDebugMonitor()
    if getElementData(getLocalPlayer(),"logedin") then

    local value = getElementData(getLocalPlayer(),getElementData(statsLabel["zombieskilled1"],"identifikation"))
        guiSetText(statsLabel["zombieskilled1"]," "..value)
        
        local value = getElementData(getLocalPlayer(),getElementData(statsLabel["headshots1"],"identifikation"))
        guiSetText(statsLabel["headshots1"]," "..value)
        
        local value = getElementData(getLocalPlayer(),getElementData(statsLabel["banditskilled1"],"identifikation"))
        guiSetText(statsLabel["banditskilled1"]," "..value)
        
        local value = getElementData(getLocalPlayer(),getElementData(statsLabel["murders1"],"identifikation"))
        guiSetText(statsLabel["murders1"]," "..value)
        
        local value = getElementData(getLocalPlayer(),getElementData(statsLabel["blood1"],"identifikation"))
        guiSetText(statsLabel["blood1"]," "..value)
        
        local value = getElementData(getLocalPlayer(),getElementData(statsLabel["humanity1"],"identifikation"))
        guiSetText(statsLabel["humanity1"]," "..math.round(value,2))
        
    end         
end
setTimer(refreshDebugMonitor,2000,0)

function playRandomHitSound()
  local number = math.random(1,3)
  local sound = playSound("sounds/hit"..number..".mp3")
end
function playerGetDamageDayZ(attacker,weapon,bodypart,loss)
  cancelEvent()
  damage = 100
  headshot = false
  if weapon == 37 then
	return
  end
  if weapon == 49 then
	if loss > 30 then
	  setElementData(getLocalPlayer(),"brokenbone",true)
	  setControlState("jump",true)
	  x,y,z = getElementPosition(getLocalPlayer())
	  local Som3D = playSound3D("sounds/Actions/Brokenbone.ogg",x,y,z)
	  setSoundMaxDistance(Som3D,15)
	  setElementData(getLocalPlayer(),"blood",getElementData(getLocalPlayer(),"blood")- math.floor(loss * 10))
	end
	setElementData(getLocalPlayer(),"blood",getElementData(getLocalPlayer(),"blood")- math.floor(loss * 5))
  elseif weapon == 63 or weapon == 51 or weapon == 19 or weapon == 16 then
	setElementData(getLocalPlayer(),"blood",0)
	if getElementData(getLocalPlayer(),"blood")<= 0 and not getElementData(getLocalPlayer(),"isDead")== true then
	  triggerServerEvent("kilLDayZPlayer",getLocalPlayer(),attacker,headshot)
	end
  elseif weapon and weapon > 1 and attacker and getElementType(attacker)== "player" then
	do
	local number = math.random(1,8)
	  if number >= 6 or number <= 8 then
		setElementData(getLocalPlayer(),"bleeding",getElementData(getLocalPlayer(),"bleeding")+ math.floor(loss * 10))
	  end
	  local number = math.random(1,7)
	  if number == 2 then
		setElementData(getLocalPlayer(),"pain",true)
	  end
	  damage = getWeaponDamage(weapon,attacker)
	  if bodypart == 9 then
		var = "aa"
		for _,vest in pairs(HelmetsTable)do
		  if getElementData(getLocalPlayer(),vest[2])then
			var = vest[2]
			break
		  end
		end
		if getElementData(getLocalPlayer(),var)== true then
		  damage = damage*0.7
		else
		  damage = damage* 12000
		  headshot = true
		end
	  end
	  if bodypart == 3 then
		var = "aa"
		for _,vest in pairs(VestsTable)do
		  if getElementData(getLocalPlayer(),vest[2])then
			var = vest[2]
			break
		  end
		end
		if getElementData(getLocalPlayer(),var)== true then
		  damage = damage*0.2
		end
	  end
	  if bodypart == 7 or bodypart == 8 then
		setElementData(getLocalPlayer(),"brokenbone",true)
		x,y,z = getElementPosition(getLocalPlayer())
		local Som3D = playSound3D("sounds/Actions/Brokenbone.ogg",x,y,z)
		setSoundMaxDistance(Som3D,15)
	  end
	  playRandomHitSound()
	  setElementData(getLocalPlayer(),"blood",getElementData(getLocalPlayer(),"blood")- math.random(damage * 0.75,damage * 1.25))
	  if not getElementData(getLocalPlayer(),"bandit") then
		setElementData(attacker,"humanity",getElementData(attacker,"humanity")- math.random(40,200))
		if 0 > getElementData(attacker,"humanity") then
		  setElementData(attacker,"bandit",true)
		end
	  else
		setElementData(attacker,"humanity",getElementData(attacker,"humanity")+ math.random(40,200))
		if getElementData(attacker,"humanity")> 5000 then
		  setElementData(attacker,"humanity",5000)
		end
		if getElementData(attacker,"humanity")> 2000 then
		  setElementData(attacker,"bandit",false)
		end
	  end
	  if getElementData(getLocalPlayer(),"blood")<= 0 and not getElementData(getLocalPlayer(),"isDead") then
		triggerServerEvent("kilLDayZPlayer",getLocalPlayer(),attacker,headshot,getWeaponNameFromID(weapon))
		setElementData(getLocalPlayer(),"isDead",true)
	  end
	end
  elseif weapon == 54 or weapon == 63 or weapon == 49 or weapon == 51 then
	setElementData(getLocalPlayer(),"blood",getElementData(getLocalPlayer(),"blood")- math.random(100,1000))
	local number = math.random(1,5)
	if loss > 30 then
	  setElementData(getLocalPlayer(),"brokenbone",true)
	  setControlState("jump",true)
	  x,y,z = getElementPosition(getLocalPlayer())
	  local Som3D = playSound3D("sounds/Actions/Brokenbone.ogg",x,y,z)
	  setSoundMaxDistance(Som3D,15)
	end
	if loss >= 100 then
	  setElementData(getLocalPlayer(),"blood",49)
	  setElementData(getLocalPlayer(),"bleeding",50)
	end
	local number = math.random(1,11)
	if number == 3 then
	  setElementData(getLocalPlayer(),"pain",true)
	end
	if getElementData(getLocalPlayer(),"blood")<= 0 and not getElementData(getLocalPlayer(),"isDead")== true then
	  triggerServerEvent("kilLDayZPlayer",getLocalPlayer(),attacker,headshot,getWeaponNameFromID(weapon))
	  setElementData(getLocalPlayer(),"isDead",true)
	end
  end
end
addEventHandler("onClientPlayerDamage",getLocalPlayer(),playerGetDamageDayZ)
function pedGetDamageDayZ(attacker,weapon,bodypart,loss)
  cancelEvent()
  if attacker and attacker == getLocalPlayer() then
	damage = 100
	if weapon == 37 then
	  return
	end
	if weapon == 63 or weapon == 51 or weapon == 19 then
	  setElementData(source,"blood",0)
	  if 0 >= getElementData(source,"blood") then
		triggerServerEvent("onZombieGetsKilled",source,attacker)
	  end
	elseif weapon and weapon > 1 and attacker and getElementType(attacker)== "player" then
	  damage = getWeaponDamage(weapon,attacker)
	  if bodypart == 9 then
		damage = damage * 12000
		headshot = true
	  end
	  setElementData(source,"blood",getElementData(source,"blood")- math.random(damage * 0.75,damage * 1.25))
	  if 0 >= getElementData(source,"blood") then
		triggerServerEvent("onZombieGetsKilled",source,attacker,headshot)
	  end
	end
  end
end
addEventHandler("onClientPedDamage",getRootElement(),pedGetDamageDayZ)
function checkStats()
  if getElementData(getLocalPlayer(),"logedin") then
	if getElementData(getLocalPlayer(),"bleeding")> 20 then
	  setElementData(getLocalPlayer(),"blood",getElementData(getLocalPlayer(),"blood")- getElementData(getLocalPlayer(),"bleeding"))
	else
	  setElementData(getLocalPlayer(),"bleeding",0)
	end
	if getElementData(getLocalPlayer(),"blood")< 0 and not getElementData(getLocalPlayer(),"isDead") then
	  triggerServerEvent("kilLDayZPlayer",getLocalPlayer(),false,false)
	end
  end
end
setTimer(checkStats,3000,0)
function createBloodForBleedingPlayers()
  if getElementData(getLocalPlayer(),"logedin") then
	x,y,z = getElementPosition(getLocalPlayer())
	for i,player in ipairs(getElementsByType("player"))do
	  bleeding = getElementData(player,"bleeding")or 0
	  if bleeding > 0 then
		px,py,pz = getPedBonePosition(player,3)
		pdistance = getDistanceBetweenPoints3D(x,y,z,px,py,pz)
		if bleeding > 600 then
		  number = 5
		elseif bleeding > 300 then
		  number = 3
		elseif bleeding > 100 then
		  number = 1
		else
		  number = 0
		end
		if pdistance <= 120 then
		  fxAddBlood(px,py,pz,0,0,0,number,1)
		end
	  end
	end
  end
end
setTimer(createBloodForBleedingPlayers,300,0)


function createBloodForBleedingPlayers()
  if getElementData(getLocalPlayer(),"logedin") then
	local x,y,z = getElementPosition(getLocalPlayer())
	local bleeding = getElementData(getLocalPlayer(),"bleeding")or 0
	if bleeding > 0 then
	  local px,py,pz = getPedBonePosition(getLocalPlayer(),3)
	  if bleeding > 600 then
		number = 5
	  elseif bleeding > 300 then
		number = 3
	  elseif bleeding > 100 then
		number = 1
	  else
		number = 0
	  end
	  fxAddBlood(px,py,pz,0,0,0,number,1)
	end
  end
end
setTimer(createBloodForBleedingPlayers,300,0)


function checkInfection()
  if getElementData(getLocalPlayer(),"logedin") then
	if getElementData(getLocalPlayer(),"infection") then
	  setElementData(getLocalPlayer(),"bleeding",math.random(200,400))
	end
  end
end
setTimer(checkInfection,120000,0)
function checkBrokenbone()
  if getElementData(getLocalPlayer(),"logedin") then
	if getElementData(getLocalPlayer(),"brokenbone") then
	  if not isPedDucked(getLocalPlayer()) then
	  end
	  toggleControl("jump",false)
	  toggleControl("sprint",false)
	else
	  toggleControl("jump",true)
	  toggleControl("sprint",true)
	end
  end
end
setTimer(checkBrokenbone,1400,0)
function setPain()
  if getElementData(getLocalPlayer(),"logedin") and getElementData(getLocalPlayer(),"pain") then
	x,y,z = getElementPosition(getLocalPlayer())
	createExplosion(x,y,z + 15,6,false,1.5,false)
	--[[local x,y,z = getElementPosition(getLocalPlayer())
	createExplosion(x,y,z + 15,8,false,1,false)
	local x,y,z,lx,ly,lz = getCameraMatrix()
	x,lx = x + 1,lx + 1
	setCameraMatrix(x,y,z,lx,ly,lz)
	setCameraTarget(getLocalPlayer())]]
  end
end
setTimer(setPain,1500,0)
function checkCold()
  if getElementData(getLocalPlayer(),"logedin") and getElementData(getLocalPlayer(),"temperature")<= 31 then
	setElementData(getLocalPlayer(),"cold",true)
  end
end
setTimer(checkCold,3000,0)
function setCold()
  if getElementData(getLocalPlayer(),"logedin") and getElementData(getLocalPlayer(),"cold") then
	local x,y,z = getElementPosition(getLocalPlayer())
	createExplosion(x,y,z + 15,8,false,0.5,false)
	local x,y,z,lx,ly,lz = getCameraMatrix()
  end
end
setTimer(setCold,1500,0)
function debugJump()
  if getControlState("jump") then
	setElementData(getLocalPlayer(),"jumping",true)
	setTimer(debugJump2,650,1)
  end
end
setTimer(debugJump,100,0)
function debugJump2()
  setElementData(getLocalPlayer(),"jumping",false)
end
weaponNoiseTable = {
  {22,20},
  {23,0},
  {24,60},
  {28,40},
  {32,40},
  {29,40},
  {30,60},
  {31,60},
  {25,40},
  {26,60},
  {27,60},
  {33,40},
  {34,60},
  {36,60},
  {35,60}
}
function getWeaponNoise(weapon)
  for i,weapon2 in ipairs(weaponNoiseTable)do
	if weapon == weapon2[1] then
	  return weapon2[2]
	end
  end
  return 0
end
function debugShooting()
  if getControlState("fire") then
	local weapon = getPedWeapon(getLocalPlayer())
	local noise = getWeaponNoise(weapon)or 0
	setElementData(getLocalPlayer(),"shooting",noise)
	if shootTimer then
	  killTimer(shootTimer)
	end
	shootTimer = setTimer(debugShooting2,100,1)
  end
end
setTimer(debugShooting,100,0)
function debugShooting2()
  setElementData(getLocalPlayer(),"shooting",0)
  shootTimer = false
end

function nightvision ()
  local weapon = getPedWeapon(getLocalPlayer())
  if weapon == 44 and (getControlState("n")) then
	dxDrawImage(0, 0, 300, 300, "nvd.png")
  end
end
addEventHandler ( "onClientRender", root, nightvision )

function isVestOn()
  for _,vest in pairs(VestsTable)do
	if getElementData(getLocalPlayer(),vest[2]) == true then
	  return true
	end
  end
  return false
end

fading = 0
fading2 = "up"
local screenWidth,screenHeight = guiGetScreenSize()
function updateIcons()
  if (getElementData (localPlayer, "hideTable") or {}).icons then return true end
  if isMainMenuActive() then
	dxDrawImage(screenWidth-780,screenHeight-243,780,243,"images/survivorsteam.png",0,0,0,tocolor(255,255,255,255),true)
  end
  if getElementData(getLocalPlayer(),"logedin") then
	if fading >= 0 and fading2 == "up" then
	  fading = fading + 5
	elseif fading <= 255 and fading2 == "down" then
	  fading = fading - 5
	end
	if fading == 0 then
	  fading2 = "up"
	elseif fading == 255 then
	  fading2 = "down"
	end
    if (getCameraGoggleEffect() == "nightvision") or (getCameraGoggleEffect() == "thermalvision") then
        dxDrawImage( 0, 0, screenWidth, screenHeight, "images/night_vision.png")
    end	
	if isVestOn() then
	  vestLife = getElementData(getLocalPlayer(),"vestLife")
	  if vestLife > 60 then
		r,g,b = 95,141,71
	  elseif vestLife > 40 then
		r,g,b = 241,241,11
	  elseif vestLife > 25 then
		r,g,b = 234,74,15
	  else
		r,g,b = 235,15,15
	  end
	  dxDrawImage(screenWidth*0.94, screenHeight*0.81, screenHeight*0.053, screenHeight*0.053, "images/vest.png",0,0,0,tocolor(r,g,b,255))
	end
	if getElementData(getLocalPlayer(), "infection") then
	  dxDrawImage(screenWidth * 0.97, screenHeight * 0.81, screenHeight * 0.053, screenHeight * 0.053, "images/infection.png", 0, 0, 0, tocolor(255, 0, 0,fading))
    end   
	local x,y,z = getElementPosition(getLocalPlayer())
	for i,player in ipairs(getElementsByType("player"))do
	  setPlayerNametagShowing(player,false)
	  if player ~= getLocalPlayer() then
		local vehicle = getPedOccupiedVehicle(player)
		local px,py,pz = getElementPosition(player)
		local pdistance = getDistanceBetweenPoints3D(x,y,z,px,py,pz)
		if pdistance <= 2 then
		  local sx,sy = getScreenFromWorldPosition(px,py,pz + 0.95,0.06)
		  if sx and sy then
			if getElementData(player,"bandit") then
			  text = string.gsub(getPlayerName(player),"#%x%x%x%x%x%x","").."(Bandit)"
			else
			  text = string.gsub(getPlayerName(player),"#%x%x%x%x%x%x","")
			end
			local w = dxGetTextWidth(text,1.02,"default-bold")
			dxDrawText(text,sx - w / 2,sy,sx - w / 2,sy,tocolor(100,255,100,200),1.02,"default-bold")
		  end
		end
	  end
	end
	local x,y,z = getElementPosition(getLocalPlayer())
	for i,veh in ipairs(getElementsByType("vehicle"))do
	  local px,py,pz = getElementPosition(veh)
	  local vehID = getElementModel(veh)
	  local vehicle = getPedOccupiedVehicle(getLocalPlayer())
	  if veh ~= vehicle and vehID ~= 548 then
		local pdistance = getDistanceBetweenPoints3D(x,y,z,px,py,pz)
		if pdistance <= 6 then
		  local sx,sy = getScreenFromWorldPosition(px,py,pz + 0.95,0.06)
		  if sx and sy then
			local w = dxGetTextWidth(getVehicleName(veh),1.02,"default-bold")
			dxDrawText(getVehicleName(veh),sx - w / 2,sy,sx - w / 2,sy,tocolor(100,255,100,200),1.02,"default-bold")
		  end
		end
	  end
	end
	if not playerTarget then
	  return
	end
	local x,y,z = getElementPosition(playerTarget)
	local x,y,distance = getScreenFromWorldPosition(x,y,z + 0.5)
	distance = 20
	if getElementData(playerTarget,"bandit") then
	  text = string.gsub(getPlayerName(playerTarget),"#%x%x%x%x%x%x","").."(Bandit)"
	else
	  text = string.gsub(getPlayerName(playerTarget),"#%x%x%x%x%x%x","")
	end
	local w = dxGetTextWidth(text,distance * 0.033,"default-bold")
	dxDrawText(text,x - w / 2,y,x - w / 2,y,tocolor(100,255,100,200),distance * 0.033,"default-bold")
  end
end
addEventHandler("onClientRender",getRootElement(),updateIcons)
playerTarget = false
function targetingActivated(target)
  if target and getElementType(target)== "player" then
	playerTarget = target
  else
	playerTarget = false
  end
end
addEventHandler("onClientPlayerTarget",getRootElement(),targetingActivated)
function infection(source)
  if getElementData(getLocalPlayer(),"logedin") then
	if getElementData(getLocalPlayer(),"infection") then
	  local aleatorySound = math.random(1,3)
	  local sound = playSound("sounds/Actions/Infection/action_cough"..aleatorySound..".ogg")
	  setSoundVolume(sound,1.2)
	  setTimer(function()
	  destroyElement(sound)
	  destroyElement(1000)
	  end,1000,1)
	end
  end
end
setTimer(infection,10000,0)
function dayZDeathInfo()
  fadeCamera(false,1,0,0,0)
  setTimer(showDayZDeathScreen,1000,1)
  playSound("sounds/Actions/Death.mp3")
end
addEvent("onClientPlayerDeathInfo",true)
addEventHandler("onClientPlayerDeathInfo",getRootElement(),dayZDeathInfo)

dayZDeathInfo = function()
local x,y,z = getElementPosition(source)
fadeCamera(true,5)
setCameraMatrix (x,y,z, 0,0,5000)
local sound1 = playSound3D ("sounds/Actions/Death.mp3", x,y,z, true)
setSoundMaxDistance( sound1,10)
setTimer(function()
destroyElement(sound1)
    end,8000, 1)
end
addEvent("onClientPlayerDeathInfo",true)
addEventHandler("onClientPlayerDeathInfo",getRootElement(),dayZDeathInfo)

whiteWindow = guiCreateStaticImage(0,0,1,1,"images/white.png",true)
guiSetVisible(whiteWindow,false)
function showPlayerDamageScreen(visibly2,stateControle2)
  guiSetVisible(whiteWindow,true)
  visibly = visibly2 or visibly
  stateControle = stateControle2 or stateControle
  if visibly >= 0.15000000000000002 and stateControle == "up" then
	stateControle = "down"
  end
  if visibly < 0 then
	guiSetVisible(whiteWindow,false)
	return
  end
  if stateControle == "up" then
	visibly = visibly + 0.025
  elseif stateControle == "down" then
	visibly = visibly - 0.025
  end
  guiSetAlpha(whiteWindow,visibly)
  setTimer(showPlayerDamageScreen,50,1)
end
function showWhiteScreen(attacker,weapon,bodypart)
  showPlayerDamageScreen(0,"up")
end
addEventHandler("onClientPlayerDamage",getLocalPlayer(),showWhiteScreen)
supportWindow = guiCreateStaticImage(0.05,0.25,0.9,0.5,"images/scrollmenu_1.png",true)
guiSetVisible(supportWindow,false)
supportGridlist = guiCreateGridList(0.05,0.1,0.9,0.7,true,supportWindow)
nameColumn = guiGridListAddColumn(supportGridlist,"Name",0.2)
messageColumn = guiGridListAddColumn(supportGridlist,"Message",0.8)
messageInput = guiCreateEdit(0.05,0.825,0.9,0.075,"",true,supportWindow)
closeButton = guiCreateButton(0.9,0.015,0.09,0.05,"Close",true,supportWindow)
function openSupportChat()
  local showing = guiGetVisible(supportWindow)
  guiSetInputMode("no_binds_when_editing")
  guiSetVisible(supportWindow,not showing)
  if getElementData(getLocalPlayer(),"supporter")or getElementData(getLocalPlayer(),"admin") then
	guiSetVisible(supporterWindow,not showing)
  end
  if showing then
	guiSetVisible(supporterWindow,false)
  end
  showCursor(not showing)
  toggleControl("chatbox",showing)
  if showing == false then
	unbindKey("o","down",openSupportChat)
	unbindKey("j","down",showInventory)
  else
	bindKey("o","down",openSupportChat)
	bindKey("j","down",showInventory)
  end
end
bindKey("o","down",openSupportChat)
function outputEditBox()
  local showing = guiGetVisible(supportWindow)
  guiSetVisible(supportWindow,false)
  showCursor(false)
  toggleControl("chatbox",true)
  bindKey("o","down",openSupportChat)
  bindKey("j","down",showInventory)
end
addEventHandler("onClientGUIClick",closeButton,outputEditBox,false)
bindKey("o","down",outputEditBox)
addEventHandler("onClientGUIAccepted",messageInput,function(theElement)
  if not isSpamTimer() then
	local text = guiGetText(theElement)
	triggerServerEvent("onServerSupportChatMessage",getLocalPlayer(),getLocalPlayer(),text)
  end
  setAntiSpamActive()
  guiSetText(messageInput,"")
end)
function outputSupportChat(sourcePlayer,text)
  local row = guiGridListAddRow(supportGridlist)
  if sourcePlayer == "Sandra" or sourcePlayer == "James" or sourcePlayer == "Paul" then
	name = sourcePlayer.."(Bot)"
  elseif not getElementData(sourcePlayer,"logedin") then
	name = string.gsub(getPlayerName(sourcePlayer),"#%x%x%x%x%x%x","").."(Guest)"
  elseif getElementData(sourcePlayer,"admin") then
	name = string.gsub(getPlayerName(sourcePlayer),"#%x%x%x%x%x%x","").."(Admin)"
  elseif getElementData(sourcePlayer,"supporter") then
	name = string.gsub(getPlayerName(sourcePlayer),"#%x%x%x%x%x%x","").."(Supporter)"
  else
	name = string.gsub(getPlayerName(sourcePlayer),"#%x%x%x%x%x%x","").."(Player)"
  end
  guiGridListSetItemText(supportGridlist,row,nameColumn,name,false,false)
  guiGridListSetItemText(supportGridlist,row,messageColumn,text,false,false)
  if sourcePlayer == "Sandra" then
	r,g,b = 255,30,120
  elseif sourcePlayer == "James" or sourcePlayer == "Paul" then
	r,g,b = 255,255,22
  elseif getElementData(sourcePlayer,"admin") then
	r,g,b = 255,22,0
  elseif getElementData(sourcePlayer,"supporter") then
	r,g,b = 22,255,0
  else
	r,g,b = 255,255,255
  end
  guiGridListSetItemColor(supportGridlist,row,nameColumn,r,g,b)
end
addEvent("onSupportChatMessage",true)
addEventHandler("onSupportChatMessage",getRootElement(),outputSupportChat,true)
local antiSpamTimer = {}
function setAntiSpamActive()
  if not isTimer(antiSpamTimer) then
	antiSpamTimer = setTimer(killAntiSpamTimer,1000,1)
  else
	killTimer(antiSpamTimer)
	antiSpamTimer = setTimer(killAntiSpamTimer,2500,1)
  end
end
function isSpamTimer()
  if isTimer(antiSpamTimer) then
	outputChatBox("Please do not spam the support chat!",255,255,0,true)
	return true
  else
	return false
  end
end
function killAntiSpamTimer()
  killTimer(antiSpamTimer)
end
function getRankingPlayer(place)
  return playerRankingTable[place].Player
end
function getElementDataPosition(key,value)
  if key and value then
	local result = 1
	for i,player in pairs(getElementsByType("player"))do
	  local data = tonumber(getElementData(player,key))
	  if data and value < data then
		result = result + 1
	  end
	end
	return result
  end
end
function positionGetElementData(key,positions)
  if key and positions then
	local Position = {}
	for index,player in pairs(getElementsByType("player"))do
	  local data = tonumber(getElementData(player,key))
	  if data then
		for i1 = 1,positions do
		  if Position[tonumber(i1)] then
			if Position[tonumber(i1)].Wert < tonumber(data) then
			  local Position_Cache1 = Position[tonumber(i1)].Player
			  local Position_Cache2 = Position[tonumber(i1)].Wert
			  local Position_Cache3,Position_Cache4
			  for i2 = i1,positions do
				if Position[tonumber(i2)] then
				  Position_Cache3 = Position[tonumber(i2)].Player
				  Position_Cache4 = Position[tonumber(i2)].Wert
				  Position[tonumber(i2)].Player = Position_Cache1
				  Position[tonumber(i2)].Wert = Position_Cache2
				  Position_Cache1 = Position_Cache3
				  Position_Cache2 = Position_Cache4
				else
				  Position[tonumber(i2)] = {}
				  Position[tonumber(i2)].Player = Position_Cache1
				  Position[tonumber(i2)].Wert = Position_Cache2
				  break
				end
			  end
			  Position[tonumber(i1)] = {}
			  Position[tonumber(i1)].Player = player
			  Position[tonumber(i1)].Wert = data
			  break
			end
		  else
			Position[tonumber(i1)] = {}
			Position[tonumber(i1)].Player = player
			Position[tonumber(i1)].Wert = data
			break
		  end
		end
	  end
	end
	return Position
  end
end

--[[function math.round(number,decimals,method)
	decimals = decimals or 0
	local factor = 10 ^ decimals
	if(method == "ceil" or method == "floor") then return math[method](number * factor)/ factor
	else return tonumber(("%."..decimals.."f"):format(number))end
end]]

function formatTimeFromMinutes(value)
  if value then
	local hours = math.floor(value / 60)
	local minutes = math.round((value / 60 - math.floor(value / 60))* 100 / 1.6666666666666667)
	if minutes < 10 then
	  minutes = "0"..minutes
	end
	value = hours..":"..minutes
	return value
  end
  return false
end
playerRankingTable = {}
function checkTopPlayer()
  playerRankingTable = positionGetElementData("alivetime",#getElementsByType("player"))
end
checkTopPlayer()
setTimer(checkTopPlayer,10000,0)
function onQuitGame(reason)
  checkTopPlayer()
end
addEventHandler("onClientPlayerQuit",getRootElement(),onQuitGame)
yA = 0
local screenWidth,screenHeight = guiGetScreenSize()
function scoreBoard()
  if getKeyState("tab")== false then
	return
  end
  if getElementData(getLocalPlayer(),"logedin") then
	local offset = dxGetFontHeight(1.55,"default-bold")
	dxDrawImage(screenWidth * 0.15,screenHeight * 0.2,screenWidth * 0.7,screenHeight * 0.2 + yA,"images/background_scoreboard.png",0,0,0,tocolor(255,255,255))
	dxDrawRectangle(screenWidth * 0.15,screenHeight * 0.2 + offset * 2,screenWidth * 0.7,screenHeight * 0.0025,tocolor(255,255,255,220))
	dxDrawText("Name",screenWidth * 0.175,screenHeight * 0.2 + offset,screenWidth * 0.175,screenHeight * 0.2 + offset,tocolor(50,255,50,200),1.5,"default-bold")
	w1 = dxGetTextWidth("Name",1.5,"default-bold")
	dxDrawText("Murders",screenWidth * 0.3 + w1 * 1.6,screenHeight * 0.2 + offset,screenWidth * 0.3 + w1 * 1.6,screenHeight * 0.2 + offset,tocolor(50,255,50,200),1.5,"default-bold")
	w2 = dxGetTextWidth("Murders",1.5,"default-bold")
	dxDrawRectangle(screenWidth * 0.3 + w1 * 1.6 - w2 * 0.1 - screenWidth * 0.0025 / 2,screenHeight * 0.2,screenWidth * 0.0025,screenHeight * 0.2 + yA,tocolor(255,255,255,220))
	dxDrawRectangle(screenWidth * 0.3 + w1 * 1.6 + w2 * 1.1 - screenWidth * 0.0025 / 2,screenHeight * 0.2,screenWidth * 0.0025,screenHeight * 0.2 + yA,tocolor(255,255,255,220))
	dxDrawText("Zombies Killed",screenWidth * 0.3 + w1 * 1.6 + w2 * 1.1 - screenWidth * 0.0025 / 2 + w2 * 0.1,screenHeight * 0.2 + offset,screenWidth * 0.3 + w1 * 1.6,screenHeight * 0.2 + offset,tocolor(50,255,50,200),1.5,"default-bold")
	w3 = dxGetTextWidth("Zombies Killed",1.5,"default-bold")
	dxDrawRectangle(screenWidth * 0.3 + w1 * 1.6 + w2 * 1.1 + w3 + w2 * 0.1 + screenWidth * 0.0025 / 2,screenHeight * 0.2,screenWidth * 0.0025,screenHeight * 0.2 + yA,tocolor(255,255,255,220))
	dxDrawText("Alive Time",screenWidth * 0.3 + w1 * 1.6 + w2 * 1.1 + w3 + w2 * 0.1 + screenWidth * 0.0025 / 2 + w2 * 0.1,screenHeight * 0.2 + offset,screenWidth * 0.3 + w1 * 1.6,screenHeight * 0.2 + offset,tocolor(50,255,50,200),1.5,"default-bold")
	w4 = dxGetTextWidth("Alive Time",1.5,"default-bold")
	dxDrawRectangle(screenWidth * 0.3 + w1 * 1.6 + w2 * 1.1 + w3 + w2 * 0.1 + screenWidth * 0.0025 / 2 + w2 * 0.1 + w4 + w2 * 0.1,screenHeight * 0.2,screenWidth * 0.0025,screenHeight * 0.2 + yA,tocolor(255,255,255,220))
	dxDrawText("Players:"..#getElementsByType("player"),screenWidth * 0.3 + w1 * 1.6 + w2 * 1.1 + w3 + w2 * 0.1 + screenWidth * 0.0025 / 2 + w2 * 0.1 + w4 + w2 * 0.1 + w4 / 3,screenHeight * 0.2 + offset,screenWidth * 0.8,screenHeight * 0.2 + offset,tocolor(50,255,50,200),1.5,"default-bold")
	playerInList = false
	local playerAmount = #getElementsByType("player")
	if playerAmount > 10 then
	  playerAmount = 10
	end
	for i = 1,playerAmount do
	  yA = i * offset
	  local offset2 = dxGetFontHeight(1.5,"default-bold")
	  local player = getRankingPlayer(i)or false
	  if not player then
		break
	  end
	  r,g,b = 255,255,255
	  if getPlayerName(player)== getPlayerName(getLocalPlayer()) then
		r,g,b = 50,255,50
		playerInList = true
	  end
	  dxDrawText(i,screenWidth * 0.155,screenHeight * 0.2 + offset * 2 + yA,screenWidth * 0.175,screenHeight * 0.2 + offset + yA,tocolor(r,g,b,200),1.5,"default-bold")
	  dxDrawText(string.gsub(getPlayerName(player),"#%x%x%x%x%x%x",""),screenWidth * 0.175,screenHeight * 0.2 + offset * 2 + yA,screenWidth * 0.175,screenHeight * 0.2 + offset + yA,tocolor(r,g,b,200),1.5,"default-bold")
	  local murders = getElementData(player,"murders")
	  dxDrawText(murders,screenWidth * 0.3 + w1 * 1.6,screenHeight * 0.2 + offset * 2 + yA,screenHeight * 0.2 + offset * 2 + yA,screenHeight * 0.2 + offset + yA,tocolor(r,g,b,200),1.5,"default-bold")
	  local zombieskilled = getElementData(player,"zombieskilled")
	  dxDrawText(zombieskilled,screenWidth * 0.3 + w1 * 1.6 + w2 * 1.1 - screenWidth * 0.0025 / 2 + w2 * 0.1,screenHeight * 0.2 + offset * 2 + yA,screenWidth * 0.175,screenHeight * 0.2 + offset + yA,tocolor(r,g,b,200),1.5,"default-bold")
	  local alivetime = getElementData(player,"alivetime")or 0
	  dxDrawText(formatTimeFromMinutes(alivetime),screenWidth * 0.3 + w1 * 1.6 + w2 * 1.1 + w3 + w2 * 0.1 + screenWidth * 0.0025 / 2 + w2 * 0.1,screenHeight * 0.2 + offset * 2 + yA,screenWidth * 0.175,screenHeight * 0.2 + offset + yA,tocolor(r,g,b,200),1.5,"default-bold")
	end
	playerLocalAdd = 0
	if not playerInList then
	  playerLocalAdd = offset
	  r,g,b = 50,255,50
	  dxDrawRectangle(screenWidth * 0.15,screenHeight * 0.2 + offset * 2 +(playerAmount + 2)* offset - offset / 2,screenWidth * 0.7,screenHeight * 0.0025,tocolor(255,255,255,220))
	  local rank = getElementDataPosition("alivetime",getElementData(getLocalPlayer(),"alivetime"))
	  dxDrawText(rank,screenWidth * 0.155,screenHeight * 0.2 + offset * 2 +(playerAmount + 2)* offset,screenWidth * 0.175,screenHeight * 0.2 + offset * 2 +(playerAmount + 2)* offset,tocolor(r,g,b,200),1.5,"default-bold")
	  dxDrawText(string.gsub(getPlayerName(getLocalPlayer()),"#%x%x%x%x%x%x",""),screenWidth * 0.175,screenHeight * 0.2 + offset * 2 +(playerAmount + 2)* offset,screenWidth * 0.175,screenHeight * 0.2 + offset +(playerAmount + 2)* offset,tocolor(r,g,b,200),1.5,"default-bold")
	  local murders = getElementData(getLocalPlayer(),"murders")
	  dxDrawText(murders,screenWidth * 0.3 + w1 * 1.6,screenHeight * 0.2 + offset * 2 +(playerAmount + 2)* offset,screenWidth * 0.175,screenHeight * 0.2 + offset +(playerAmount + 2)* offset,tocolor(r,g,b,200),1.5,"default-bold")
	  local zombieskilled = getElementData(getLocalPlayer(),"zombieskilled")
	  dxDrawText(zombieskilled,screenWidth * 0.3 + w1 * 1.6 + w2 * 1.1 - screenWidth * 0.0025 / 2 + w2 * 0.1,screenHeight * 0.2 + offset * 2 +(playerAmount + 2)* offset,screenWidth * 0.175,screenHeight * 0.2 + offset +(playerAmount + 2)* offset,tocolor(r,g,b,200),1.5,"default-bold")
	  local alivetime = getElementData(getLocalPlayer(),"alivetime")or 0
	  dxDrawText(formatTimeFromMinutes(alivetime),screenWidth * 0.3 + w1 * 1.6 + w2 * 1.1 + w3 + w2 * 0.1 + screenWidth * 0.0025 / 2 + w2 * 0.1,screenHeight * 0.2 + offset * 2 +(playerAmount + 2)* offset,screenWidth * 0.175,screenHeight * 0.2 + offset +(playerAmount + 2)* offset,tocolor(r,g,b,200),1.5,"default-bold")
	end
	yA = playerAmount * offset + playerLocalAdd
  end
end
--addEventHandler("onClientRender",getRootElement(),scoreBoard)

function updatePlayTime()
  if getElementData(getLocalPlayer(),"logedin") then
	local playtime = getElementData(getLocalPlayer(),"alivetime")
	setElementData(getLocalPlayer(),"alivetime",playtime + 1)
  end
end
setTimer(updatePlayTime,60000,0)
bindKey("u","down","chatbox","radiochat")
local pingFails = 0
function playerPingCheck()
  if getPlayerPing(getLocalPlayer())> 9999 then
	pingFails = pingFails + 1
	if pingFails == 5 then
	  triggerServerEvent("kickPlayerOnHighPing",getLocalPlayer())
	  return
	end
	startRollMessage2("Ping","Your ping is over "..gameplayVariables.ping.."!("..pingFails.."/5)",255,22,0)
	if isTimer(pingTimer) then
	  return
	end
	pingTimer = setTimer(function()
	  pingFails = 0
	end,30000,1)
  end
end
setTimer(playerPingCheck,4000,0)

function toggleEngine()
  if getPedOccupiedVehicleSeat(getLocalPlayer()) ~= 0 then return end
  veh = getPedOccupiedVehicle(getLocalPlayer())
  vehCol = getElementData(veh,"parent")
  needengine = getElementData(vehCol,"needengines")
  needtires = getElementData(vehCol,"needtires")
  needrotor = getElementData(vehCol,"needrotor")
  needparts = getElementData(vehCol,"needparts")
  needglass = getElementData(vehCol,"needglass")
  engine = getElementData(vehCol,"Engine_inVehicle")or 0
  tires = getElementData(vehCol,"Tire_inVehicle")or 0
  rotor = getElementData(vehCol,"Rotor_inVehicle")or 0
  parts = getElementData(vehCol,"Parts_inVehicle")or 0
  fuel = getElementData(vehCol,"fuel")
  if needengine == engine and needtires == tires and needrotor == rotor and (fuel > 0) and needparts == parts then
	setVehicleEngineState(veh,not getVehicleEngineState(veh))
  end
  if getVehicleEngineState(veh)== true then
	triggerEvent("displayClientInfo",getLocalPlayer(),"Vehicle","Engine started!",22,255,0)
  else
	triggerEvent("displayClientInfo",getLocalPlayer(),"Vehicle","Engine stopped!",255,22,0)
  end
end
bindKey("k","down",toggleEngine)
-----------------------------------
addEventHandler("onClientPlayerDamage",getLocalPlayer(),function(attacker,weapon,bodypart,loss)
  if not getElementData(getLocalPlayer(),"vestLife") or not getElementData(getLocalPlayer(),"helmetLife") then
	setElementData(getLocalPlayer(),"vestLife",100)
	setElementData(getLocalPlayer(),"helmetLife",100)
  end
  if weapon and weapon > 1 and attacker and getElementType(attacker)== "player" then
	damage = getWeaponDamage(weapon,attacker) / 100
	if bodypart == 9 then
	  if getActiveHelmetVar(getLocalPlayer()) then
		helmetLife = getElementData(getLocalPlayer(),"helmetLife")
		setElementData(getLocalPlayer(),"helmetLife", helmetLife - damage)
		if getElementData(getLocalPlayer(),getActiveHelmet(getLocalPlayer())) >= 1 then
		  setElementData(getLocalPlayer(),getActiveHelmet(getLocalPlayer()),getElementData(getLocalPlayer(),getActiveHelmet(getLocalPlayer())) - 1)
		end
		if getElementData(getLocalPlayer(),"helmetLife") <= 0 then
		  setElementData(getLocalPlayer(),"helmetLife",100)
		  setElementData(getLocalPlayer(),getActiveHelmetVar(getLocalPlayer()),false)
		end
	  end
	end
	if bodypart == 3 then
	  if getActiveVestVar(getLocalPlayer()) then
		vestLife = getElementData(getLocalPlayer(),"vestLife")
		setElementData(getLocalPlayer(),"vestLife",vestLife - damage)
		if getElementData(getLocalPlayer(),getActiveVest(getLocalPlayer())) >= 1 then
		  setElementData(getLocalPlayer(),getActiveVest(getLocalPlayer()),getElementData(getLocalPlayer(),getActiveVest(getLocalPlayer())) - 1)
		end
		if getElementData(getLocalPlayer(),"vestLife") <= 0 then
		  setElementData(getLocalPlayer(),"vestLife",100)
		  setElementData(getLocalPlayer(),getActiveVestVar(getLocalPlayer()),false)
		end
	  end
	end
  end
end)
---------------------------------
function AddDeathPedClothes(ped,player)
  t0,m0 = getPedClothes(player,0)
  t1,m1 = getPedClothes(player,1)
  t2,m2 = getPedClothes(player,2)
  t3,m3 = getPedClothes(player,3)
  t4,m4 = getPedClothes(player,13)
  t5,m5 = getPedClothes(player,14)
  t6,m6 = getPedClothes(player,15)
  t7,m7 = getPedClothes(player,16)
  setTimer(function()
	addPedClothes(ped,t0,m0,0)
	addPedClothes(ped,t1,m1,1)
	addPedClothes(ped,t2,m2,2)
	addPedClothes(ped,t3,m3,3)
	addPedClothes(ped,t4,m4,13)
	addPedClothes(ped,t5,m5,14)
	addPedClothes(ped,t6,m6,15)
	addPedClothes(ped,t7,m7,16)
  end,100,1)
end
addEvent("AddDeathPedClothes",true)
addEventHandler("AddDeathPedClothes",getRootElement(),AddDeathPedClothes)
---------------------------------
---------------------------------
function getCurrentSniperModelID()
  for i,weaponData in pairs(weaponTable)do
	if weaponData[3] == 34 and getElementData(getLocalPlayer(),"currentweapon_1") == weaponData[1] then
	  return weaponData[6]
	end
  end
end
function getCurrentHelmetID()
  for i,helmet in pairs(HelmetsTable)do
	if getElementData(getLocalPlayer(),helmet[2]) then
	  return helmet[3]
	end
  end
end
bindKey("aim_weapon","both",function(_,state)
  if getPedWeaponSlot(localPlayer)== 6 then
	if state == "down" then alpha = 0 else alpha = 255 end
	for _,v in pairs(getElementsByType("object",root,true))do
	  if isElementAttachedToBone(v) and (getElementModel(v) == getCurrentSniperModelID() or getElementModel(v) == getCurrentHelmetID()) then
		setElementAlpha(v,alpha)
	  end
	end
  end
end)
---------------------------------
function healthandblod()
  if getElementData(getLocalPlayer(),"logedin") then
	if getElementHealth(getLocalPlayer())<= 0 then
	  setElementData(getLocalPlayer(),"blood",-1)
	  setElementHealth(getLocalPlayer(),100)
	end
  end
end
setTimer(healthandblod,3000,0)
---------------------------------
function soundtrap(player)
  playSound("sounds/trap.ogg")
end
addEvent("playTrapSound",true)
addEventHandler("playTrapSound",getRootElement(),soundtrap)
---------------------------------
binoculars = guiCreateStaticImage(0,0,1,1,"images/binoculars.png",true)
guiSetVisible(binoculars,false)

function isPlayerUsingBinoculars(button, press)
  if getPedWeapon(localPlayer) == 43 then
	if getElementData(localPlayer,"currentweapon_3") == "Binoculars" then
	  visible = binoculars
	else
	  visible = rangefinder
	end
	if button == "mouse2" then
	  if press then
		guiSetVisible(visible,true)
		showChat(false)
	  else
		guiSetVisible(visible,false)
		showChat(true)
	  end
	end
  end
end
addEventHandler("onClientKey",root,isPlayerUsingBinoculars)

--RECOIL DAS ARMAS
function shakeCamera(weapon)
x,y,z = getPedBonePosition ( getLocalPlayer(), 26 )
if weapon == 30  then
createExplosion ( x,y,z + 10,12,false,0.2,false)
elseif weapon == 31  then
createExplosion ( x,y,z + 10,12,false,0.1,false)
end
end
addEventHandler ( "onClientPlayerWeaponFire", getLocalPlayer(), shakeCamera )

-------------SET GPS Blips Map---------------
playerBlibs1 = {}
amouunt1 = 0
function updateGPS2 ()
    if not getElementData(getLocalPlayer(),"logedin") then return end    
    amouunt1 = 0
    for i, blip in ipairs(playerBlibs1) do
        if isElement(blip) then
            destroyElement(blip)
        end
    end
    playerBlibs1 = {}    
    for i, player in ipairs(getElementsByType("player")) do
       if getElementData(player,"GPSChannel") == getElementData(getLocalPlayer(),"GPSChannel") and getElementData(localPlayer,"GPSChannel") ~= 0 and player ~= localPlayer and getElementData(player,"GPS") > 0 then
            amouunt1 = amouunt1+1
            playerBlibs1[amouunt1] = createBlipAttachedTo(player,0,2,255,0,0)
            setBlipVisibleDistance(playerBlibs1[amouunt1],1000)
        end
    end
end
setTimer(updateGPS2,5000,0)
---------------------------
local alpha = 255 
bindKey ( "aim_weapon", "both", 
  function ( _, state ) 
   if getPedWeaponSlot ( localPlayer ) == 6 then 
    if ( state == "down" ) then 
     alpha = 0 
    elseif ( state == "up" ) then 
     alpha = 255 
    end 
    for _, v in ipairs ( getElementsByType ( "object", root, true ) ) do 
     if isElementAttachedToBone ( v ) then 
      local id = getElementModel ( v )
      if ( id == 1800 ) then -- Balanced Vest
       setElementAlpha ( v, alpha )
      elseif ( id == 1481 ) then -- Press Vest
       setElementAlpha ( v, alpha )
      elseif ( id == 1744 ) then -- Police Vest
       setElementAlpha ( v, alpha )
      elseif ( id == 1759 ) then -- Light Tactical Vest
       setElementAlpha ( v, alpha )
      elseif ( id == 1922 ) then -- Balistic Vest
       setElementAlpha ( v, alpha )
	  -----------------------------
      elseif ( id == 1604 ) then -- Ghillie Helmet
       setElementAlpha ( v, alpha )	   
      elseif ( id == 1515 ) then -- Helmet
       setElementAlpha ( v, alpha )	
      elseif ( id == 1924 ) then -- Helmet Tactical
       setElementAlpha ( v, alpha )	 	
      elseif ( id == 1923 ) then -- Helmet Military
       setElementAlpha ( v, alpha )		
      elseif ( id == 1834 ) then -- Helmet ONU
       setElementAlpha ( v, alpha )		
      -----------------------------   
      elseif ( id == 1867 ) then -- TEC-9
       setElementAlpha ( v, alpha )	   
      elseif ( id == 1484 ) then -- PDW
       setElementAlpha ( v, alpha )	 
      elseif ( id == 1866 ) then -- Bizon PP-19
       setElementAlpha ( v, alpha )	 
      elseif ( id == 2059 ) then -- MP5A5
       setElementAlpha ( v, alpha )	 
      elseif ( id == 2061 ) then -- MP5SD6
       setElementAlpha ( v, alpha )	 
	  -----------------------------  
      elseif ( id == 1852 ) then -- Machete
       setElementAlpha ( v, alpha )	 
      elseif ( id == 1853 ) then -- Chainsaw
       setElementAlpha ( v, alpha )	 
      elseif ( id == 1854 ) then -- Hatchet
       setElementAlpha ( v, alpha )	 
      elseif ( id == 1855 ) then -- Baseball Bat
       setElementAlpha ( v, alpha )	 
      elseif ( id == 1870 ) then -- Baseball Bat Barbed
       setElementAlpha ( v, alpha )	
      elseif ( id == 1871 ) then -- Baseball Bat With Nails
       setElementAlpha ( v, alpha )	
      elseif ( id == 1857 ) then -- Crowbar
       setElementAlpha ( v, alpha )	 
      elseif ( id == 1856 ) then -- Shovel
       setElementAlpha ( v, alpha )	 
	  -----------------------------
      elseif ( id == 1486 ) then -- Child Briefcase Backpack
       setElementAlpha ( v, alpha )	 	
      elseif ( id == 1777 ) then -- Vest Pouch Pack
       setElementAlpha ( v, alpha )	
      elseif ( id == 2405 ) then -- Taloon Backpack
       setElementAlpha ( v, alpha )	
      elseif ( id == 3026 ) then -- Assault Pack(ACU)
       setElementAlpha ( v, alpha )	
      elseif ( id == 1248 ) then -- Hunting Backpack
       setElementAlpha ( v, alpha )	
      elseif ( id == 2406 ) then -- British Assault Pack
       setElementAlpha ( v, alpha )	
      elseif ( id == 2472 ) then -- Czech Backpack
       setElementAlpha ( v, alpha )	
      elseif ( id == 1520 ) then -- Czech Backpack Black
       setElementAlpha ( v, alpha )	
      elseif ( id == 1541 ) then -- Czech Backpack Finn
       setElementAlpha ( v, alpha )	
      elseif ( id == 1542 ) then -- Czech Backpack Flack
       setElementAlpha ( v, alpha )	
      elseif ( id == 1517 ) then -- Mountain Backpack
       setElementAlpha ( v, alpha )	
      elseif ( id == 1252 ) then -- Coyote Backpack
       setElementAlpha ( v, alpha )		
      elseif ( id == 1742 ) then -- Coyote Desert Backpack
       setElementAlpha ( v, alpha )		
      elseif ( id == 1743 ) then -- Coyote Mossy Backpack
       setElementAlpha ( v, alpha )		
      elseif ( id == 1815 ) then -- Tactical Backpack
       setElementAlpha ( v, alpha )			   
      end 
     end 
    end 
   end 
  end 
)

 

1563734778-error.png

Link to comment

Hey, since this are not just a few lines of code..
The screen shows the error in nz_c.Lua. I assume ist the upper script, because you didnt write its name next to it.
Well in that case:

local distance = getDistanceBetweenPoints3D ( x,y,z, zx,zy,zz )

This is the line 128 of the upper script and i betthis is not the actual line 128 of your script where the error occurs - getDistanceBewerrnPoints3D would say something like this in case of failure:
"Bad argument @getDistanceBewerrnPoints3D, expected number at argument X, got ..."

So please tell us the correct line in the scripts here (or paste to the full script, or at least from beginning to error line).

..or maybe highlight the error line or put it once seperate below

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