Jump to content

[HELP] DayZ Helmet/Vest damageReduce


India

Recommended Posts

I have a dayz gamemode and there is a system for helmet and vest, player health protection is increased when normally wearing helmet and vest But it's not happening here

Anyone can help me? I really need it, i could not find a solution

editor_client.lua

editor_client.lua

clothDamageReduce = {
	[3] = 
	{ 
		"clothBody", 
		{ 
			["Yelek: Orman Kamuflajı [0 Zırh]"] = 10,
			["Yelek: Kurşun Geçirmez [30 Zırh]"] = 40,
			["Yelek: Balistik [60 Zırh]"] = 65, 
			["Yelek: Orman Kamuflajlı [50 Zırh]"] = 60, 
			["Yelek: ET-053 [80 Zırh]"] = 85,
		} 
	},
	[9] = 
	{ 
		"clothHead", 
		{ 
			["Motorsiklet Kaskı [97 Zırh]"] = 99, 
			["Kamuflajlı Kask [97 Zırh]"] = 99,
			["Kask: Bandanalı [20 Zırh]"] = 30,
			["Kask: C.E.L.L [90 Zırh]"] = 95,
			["Kask: Koyu Yeşil [70 Zırh]"] = 75,
			["Şapka: Çim Kamuflajlı [0 Zırh]"] = 10,
			["Bere: Siyah Komando [0 Zırh]"] = 10,
			["Bere: Kırmızı Komando [0 Zırh]"] = 10,
			["Şapka: Asker [0 Zırh]"] = 10,
		} 
	},
}
clothSlots = {
	["clothHead"] = 
	{
		["Motorsiklet Kaskı [97 Zırh]"] = true, 
		["Kamuflajlı Kask [97 Zırh]"] = true,
		["Kask: Bandanalı [20 Zırh]"] = true,
		["Kask: C.E.L.L [90 Zırh]"] = true,
		["Kask: Koyu Yeşil [70 Zırh]"] = true,
		["Şapka: Çim Kamuflajlı [0 Zırh]"] = true,
		["Bere: Siyah Komando [0 Zırh]"] = true,
		["Bere: Kırmızı Komando [0 Zırh]"] = true,
		["Şapka: Asker [0 Zırh]"] = true,
	},
	["clothBody"] = 
	{
		["Yelek: Orman Kamuflajı [0 Zırh]"] = true,
		["Yelek: Kurşun Geçirmez [30 Zırh]"] = true,
		["Yelek: Balistik [60 Zırh]"] = true, 
		["Yelek: Orman Kamuflajlı [50 Zırh]"] = true, 
		["Yelek: ET-053 [80 Zırh]"] = true,
	},
}

 

survivorSystem_client.lua

function Damage_ToCloth (bone)
	if clothDamageReduce[bone] then
		local cloth = getElementData ( localPlayer, clothDamageReduce[bone][1] ) or "no"
		for i, v in pairs ( clothDamageReduce[bone][2] ) do
			if cloth == i then
				return 1-v/100
			end
		end
	end
	return 1
end

function playerGetDamageDayZ ( attacker, weapon, bodypart, loss )
	cancelEvent()
	if getElementData(localPlayer,"inGreenZone") or (getElementData(localPlayer,"safe:spawn") or 0) > 0 then
		return
	end	
	if attacker and getElementType(attacker) == "vehicle" then
		speedx, speedy, speedz = getElementVelocity ( attacker )
		actualspeed = (speedx^2 + speedy^2 + speedz^2)^(0.5)
		kmh = actualspeed * 180
		if kmh >= 90 then
			local vehkiller = getVehicleOccupant ( attacker )
			setElementData(source,"blood",0)
			if getElementData(source,"blood") <= 0 then
				triggerServerEvent("kilLDayZPlayer",source,vehkiller)
			end
		end
	end
	damage = 100
	headshot = true
	if weapon == 37 then
		return
	end
	local damageded = Damage_ToCloth (bodypart)
	if attacker and getElementData(attacker,"zombie") then
		local number = math.random(1,3)
		-- local sound = playSound("sounds/attack_"..number..".ogg")
		setElementData(getLocalPlayer(),"blood",getElementData(getLocalPlayer(),"blood")-gameplayVariables["zombiedamage"]*damageded)
		local number = math.random(1,5)
		if number == 3 then
			setElementData(getLocalPlayer(),"infection",true)
		end
		local number = math.random(1,7)
		if number == 4 then
			setElementData(getLocalPlayer(),"bleeding",getElementData(getLocalPlayer(),"bleeding") + math.floor(loss*10))
		end
	end
	if attacker and getElementData(attacker,"bossie") then
		setElementData(localPlayer,"blood",getElementData(localPlayer,"blood")-(getElementData(attacker,"damage") or 1200) * damageded)
		local number = math.random(1,5)
		if number == 3 then
			setElementData(getLocalPlayer(),"infection",true)
		end
		local number = math.random(1,7)
		if number == 4 then
			setElementData(getLocalPlayer(),"bleeding",getElementData(getLocalPlayer(),"bleeding") + math.floor(loss*10))
		end
	end
	if weapon == 49 then
		if loss > 30 then
			setElementData(getLocalPlayer(),"brokenbone",true)
			-- setPedControlState ("jump",true)
			setPedControlState ("jump",true)
			setElementData(getLocalPlayer(),"blood",getElementData(getLocalPlayer(),"blood")-math.floor(loss*10)*damageded)
		end
		setElementData(getLocalPlayer(),"blood",getElementData(getLocalPlayer(),"blood")-math.floor(loss*5)*damageded)
	elseif weapon == 63 or weapon == 51 or weapon == 19 then
		setElementData(getLocalPlayer(),"blood",0)
		if getElementData(getLocalPlayer(),"blood") <= 0 then
			if not getElementData(getLocalPlayer(),"isDead") == true then
				triggerServerEvent("kilLDayZPlayer",getLocalPlayer(),attacker,headshot)
			end
		end
	elseif weapon and weapon > 1 and attacker and getElementType(attacker) == "player" then
		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 = sWeapons[getElementData(attacker,"selectedWeapon")].damage
		if bodypart == 9 then
			damage = damage*3       --Kafadan hasar verme DOĞRU YER BURA XD
			headshot = true
		end
		if bodypart == 7 or bodypart == 8 then
			setElementData(getLocalPlayer(),"brokenbone",true)
		end
--		playRandomHitSound()
		setElementData(getLocalPlayer(),"blood",getElementData(getLocalPlayer(),"blood")-math.random(damage*0.5,damage*0.5))   -- Sol/Sağ bacak hasar oranı
		if not getElementData(getLocalPlayer(),"bandit") then
			setElementData(attacker,"humanity",getElementData(attacker,"humanity")-math.random(40,200))
			if getElementData(attacker,"humanity") < 0 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 then
			if 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)*damageded)
		local number = math.random(1,5)
		if loss > 30 then
			setElementData(getLocalPlayer(),"brokenbone",true)
			setPedControlState ("jump",true)
		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 then
			if not getElementData(getLocalPlayer(),"isDead") == true then
				triggerServerEvent("kilLDayZPlayer",getLocalPlayer(),attacker,headshot,getWeaponNameFromID (weapon))
				setElementData(getLocalPlayer(),"isDead",true)
			end
		end
	end
end
addEventHandler ( "onClientPlayerDamage", getLocalPlayer (), playerGetDamageDayZ )

function playLocalSound3D_client(x,y,z,music,radius) 
	local sound = playSound3D(music, x, y, z, true) 
	if not radius then radius = 50 end 
	setSoundMaxDistance(sound, radius) 
	local soundLength = getSoundLength(sound) 
	setTimer(stopSound, soundLength*1000, 1, sound) 
end
addEvent ("playLocalSound3D_client", true) 
addEventHandler ("playLocalSound3D_client", getRootElement(), playLocalSound3D_client)


function pedGetDamageDayZ ( attacker, weapon, bodypart, loss )
	cancelEvent()
	if attacker and getElementType(attacker) == "vehicle" and not getElementData(source,"bossie") then
		speedx, speedy, speedz = getElementVelocity ( attacker )
		actualspeed = (speedx^2 + speedy^2 + speedz^2)^(0.5)
		kmh = actualspeed * 180
		if kmh >= 50 then
			local vehkiller = getVehicleOccupant ( attacker )
			setElementData(source,"blood",0)
			if getElementData(source,"blood") <= 0 then
				triggerServerEvent("onZombieGetsKilled",source,vehkiller)
			end
		end
	end
	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 getElementData(source,"blood") <= 0 then
				if not getElementData(source,"bossie") then
					triggerServerEvent("onZombieGetsKilled",source,attacker)
				else
					triggerServerEvent("onbossieGetsKilled",source,attacker)
				end	
			end
		elseif weapon and weapon > 1 and attacker and getElementType(attacker) == "player" then
		damage = sWeapons[getElementData(attacker,"selectedWeapon")].damage
		if bodypart == 9 then
			damage = damage*1   --KAFA HASAR VERME ORANI
			headshot = true    -- true olursa ( Kafaya Tek Atıyor )
		end
			setElementData(source,"blood",getElementData(source,"blood")-math.random(damage*0.75,damage*1.25))
			if getElementData(source,"blood") <= 0 then
				if not getElementData(source,"bossie") then
					triggerServerEvent("onZombieGetsKilled",source,attacker,headshot)
				else
					triggerServerEvent("onbossieGetsKilled",source,attacker,headshot)
				end
			end
		end
	end
end
addEventHandler ( "onClientPedDamage", getRootElement(), pedGetDamageDayZ )

 

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