Jump to content
  • 0

[YARDIM] Headshot GOD Sistemi


India

Question

Merhabalar, Sunucumda headshot sistemi var. Tek sorunum greenzone(güvenli bölge) de oyuncuyu hiç bir türlü hasar veremezsiniz fakat Kafadan vurdugunuz zaman ölüyor. Tamamen headshot sistemi ile alakalıdır. Buna nasıl çözüm bulabiliriz? Yardımcı olabilecek birisi var mı acaba :))

 

headshot_s.Lua

function MakePlayerHeadshot( attacker, weapon, bodypart, loss )
if getElementType ( source ) == "player" then
        if bodypart == 9 and not (getElementData(source,"invencible")) then
            triggerEvent( "onPlayerHeadshot", source, attacker, weapon, loss )
            setPedHeadless ( source, true )
            killPed( source, attacker, weapon, bodypart )
            setTimer( BackUp, 900, 1, source )
        end
    end
end

function MakeHeadshot( source, attacker, weapon, loss )
    triggerEvent( "onPlayerHeadshot", source, attacker, weapon, loss )
    killPed( source, attacker, weapon, 9 )
    setPedHeadless ( source, true )
    setTimer( BackUp, 900, 1, source )
end

function BackUp( source )    
    if getElementType ( source ) == "player" then
        setPedHeadless ( source, false )
    end
end

function outputHeadshotIcon (killer, weapon, bodypart)
    if bodypart == 9 then
        cancelEvent()
        exports.killmessages:outputMessage (
        {getPlayerName(killer),{"padding",width=3},{"icon",id=weapon},{"padding",width=3},{"icon",id=256},{"padding",width=3},{"color",r=r1,g=g1,b=b1},getPlayerName(source) }, getRootElement(),r2,g2,b2)                 
    end
end
addEvent ( "onServerHeadshot", true )
addEventHandler( "onPlayerDamage", getRootElement(), MakePlayerHeadshot )
addEventHandler( "onPlayerKillMessage", getRootElement(), outputHeadshotIcon )
addEventHandler( "onServerHeadshot", getRootElement(), MakeHeadshot )

greenzone, server.Lua

-- Format is: {x = 0, y = 0, z = 0, width = 0, depth = 0, height = 0},
local greenzones = {
	{x = 110, y = -2075, z = -40, width = 257, depth = 333, height = 200}, -- Giriş Yeri
	
	{x = 1150, y = -1375, z = -10, width = 120, depth = 100, height = 100} -- Hastane
}

-- Initialize all zones on resource start
local z = {}
function initGreenzones()
	if greenzones and #greenzones ~= 0 then
		for _, v in ipairs(greenzones) do
			if v then
				if v.x and v.y and v.z and v.width and v.depth and v.height then
					local c = createColCuboid(v.x, v.y, v.z, v.width, v.depth, v.height)
					local rarea = createRadarArea(v.x, v.y, v.width, v.depth, 0, 255, 0, 150)
					setElementParent(rarea, c)
					if c then
						z[c] = true

						for _, p in ipairs(getElementsWithinColShape(c, "player")) do
							setElementData(p, "greenzone", true)
						end

						for _, v in ipairs(getElementsWithinColShape(c, "vehicle")) do
							setElementData(v, "greenzoneveh", true)
						end

						addEventHandler("onElementDestroy", c,
							function()
								if z[source] then
									z[source] = nil
								end
							end
						)

						addEventHandler("onColShapeHit", c,
							function(h)
								if h and isElement(h) and getElementType(h) == "player" then
									if getElementData(h, "colShapeFix_OUT") then
										setElementData(h, "colShapeFix_OUT", false)
										return
									end

									-- Hack to prevent shooting bug: if player teleports from one greenzone directly to another and fails to clean up (on time)
									if getElementData(h, "greenzone") then
										setElementData(h, "colShapeFix_IN", true)
										triggerClientEvent(h, "onEnterGreenzone", h)
									else
										setElementData(h, "greenzone", true)
										toggleControl(h, "fire", false)
										toggleControl(h, "next_weapon", false)	
										toggleControl(h, "previous_weapon", false)											
										toggleControl(h, "aim_weapon", false)
										toggleControl(h, "vehicle_fire", false)
										toggleControl(h, "vehicle_secondary_fire", false)
										--outputChatBox("[Hawk Yönetimi] Güvenli bölgeye giriş yaptınız.", h, 0, 220, 0)
										triggerClientEvent(h, "onEnterGreenzone", h)
									end
								end
							end
						)

						addEventHandler("onColShapeHit", c,
							function(h)
								if h and isElement(h) and getElementType(h) == "vehicle" then
									setElementData(h, "greenzoneveh", true)
								end
							end
						)

						addEventHandler("onColShapeLeave", c,
							function(h)
								if h and isElement(h) and getElementType(h) == "player" then
									if getElementData(h, "colShapeFix_IN") then
										setElementData(h, "colShapeFix_IN", false)
										return
									end

									if getElementData(h, "greenzone") then
										setElementData(h, "greenzone", false)
										toggleControl(h, "fire", true)
										toggleControl(h, "next_weapon", true)	
										toggleControl(h, "previous_weapon", true)										
										toggleControl(h, "aim_weapon", true)
										toggleControl(h, "vehicle_fire", true)
										toggleControl(h, "vehicle_secondary_fire", true)
										--outputChatBox("[Hawk Yönetimi] Güvenli bölgeden ayrılıyorsunuz.", h, 220, 220, 0)
										triggerClientEvent(h, "onLeaveGreenzone", h)
									else
										setElementData(h, "colShapeFix_OUT", true)
									end
								end
							end
						)

						addEventHandler("onColShapeLeave", c,
							function(h)
								if h and isElement(h) and getElementType(h) == "vehicle" then
									setTimer(setElementData, 350, 1, h, "greenzoneveh", false)
								end
							end
						)

					end
				end
			end
		end
	end
end
addEventHandler("onResourceStart", resourceRoot, initGreenzones)

function resetGreenzoneData()
	for _, p in ipairs(getElementsByType("player")) do
		if isElement(p) then
			removeElementData(p, "greenzone")
		end
	end
end
addEventHandler("onResourceStop", resourceRoot, resetGreenzoneData)

 

Link to comment

1 answer to this question

Recommended Posts

  • 0
function MakePlayerHeadshot( attacker, weapon, bodypart, loss )
  if getElementData(source, "greenzone") then return false -- if player has greenzone data return this function false
if getElementType ( source ) == "player" then
        if bodypart == 9 and not (getElementData(source,"invencible")) then
            triggerEvent( "onPlayerHeadshot", source, attacker, weapon, loss )
            setPedHeadless ( source, true )
            killPed( source, attacker, weapon, bodypart )
            setTimer( BackUp, 900, 1, source )
        end
    end
end

Gecikme için üzgünüm. Şunu bir dener misin?

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...