Jump to content

[HELP-ME] Sync HitMarker


AnnaBelle

Recommended Posts

Posted
local screenX, screenY
local drawTimer
local isDrawing = false
local sound

function drawHitMarker()
	dxDrawImage(screenX-16,screenY-16,32,32,"hitmarker.png")
end

addEventHandler("onClientPlayerWeaponFire",localPlayer,
function(weapon,ammo,ammoInClip,hitX,hitY,hitZ,hitElement)
	if hitElement then
		if getElementType(hitElement)== "vehicle" or getElementType(hitElement)== "player" then
			screenX, screenY = getScreenFromWorldPosition(hitX, hitY, hitZ)
			if not screenX then return end 
			if isDrawing then return end 
			isDrawing = true
			local sound = playSound("hitmarker-sound.wav")
			setSoundVolume( sound , 1)
			
			addEventHandler("onClientRender", root,drawHitMarker) 
			if drawTimer and isTimer(drawTimer) then
				killTimer(drawTimer)
			end
			
			drawTimer = setTimer(function() 
				isDrawing = false
				removeEventHandler("onClientRender",root,drawHitMarker) 
			end, 500, 1)
		end
	end
end)

addEventHandler("onClientPlayerDamage",getLocalPlayer(),function()
	fadeCamera(false,1,255,0,0)
	local hit_sound = playSound("hitmarker-sound.wav")
	setSoundVolume(hit_sound,0.5)
	function cam()
	fadeCamera(true,1)
	end
	setTimer(cam,150,1)
end)

 

I explain ... when I shoot it runs "onClientPlayerWeaponFire" And if that bullet hits a ped, user or auto it generates this image at the point of impact
" dxDrawImage(screenX-16, screenY-16, 32, 32, "hitmarker.png")"

There is a problem with ping. I can shoot you but you do not get the bullet, the script does not verify that, what I want is that something like an IF asks you if you received damage before Which generates the image ... osea syncronize the 2 parts. This because in users occasions they shoot others and when they see the X they think that they did and it is not true then they complain of hack or abuse.

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