Jump to content

Super Annotying Colshape Issue (Not Attaching)


f8upd8

Recommended Posts

I tried to create Colshape-based antiDM system. It looks like this:

antiDeathMatchColShapes= {353.71392822266, 170.66009521484, 1005.3893432617, 100, 100, 1, 3}
animebankess = createPed (233, 359.71392822266, 173.66009521484, 1008.3893432617, -90)
outputChatBox(tostring(animebankess))
setElementDimension ( animebankess, 1 )
setElementInterior ( animebankess, 3 )
addEventHandler("onClientResourceStart", getRootElement(), function ()
	outputChatBox("Yeah!")
	outputChatBox(antiDeathMatchColShapes[1])
	local i = 1
	local count = 1
	AntiDmZones = {}
	repeat
		outputChatBox("done once!")
		colX = antiDeathMatchColShapes[i]
		colY = antiDeathMatchColShapes[i+1]
		colZ = antiDeathMatchColShapes[i+2]
		colR = antiDeathMatchColShapes[i+3]
		colH = antiDeathMatchColShapes[i+4]
		colDim = antiDeathMatchColShapes[i+5]
		colInt = antiDeathMatchColShapes[i+6]
		table.insert(AntiDmZones, createColTube(colX, colY, colZ, colR, colH))
		setElementDimension(AntiDmZones[count], colDim)
		setElementInterior(AntiDmZones[count], colInt)
		count = count + 1
		i=i+8
	until not antiDeathMatchColShapes[i]
    
	addEventHandler("onClientPedDamage", getRootElement(), function (attacker)
	local i = 1
	while AntiDmZones[i]
	do
		outputChatBox(tostring(source))
		checkOne = isElementWithinColShape(source, AntiDmZones[i])
		checkTwo = isElementWithinColShape(attacker, AntiDmZones[i])
		outputChatBox(tostring(checkOne))
		outputChatBox(tostring(checkTwo))
		if isElementWithinColShape(source, AntiDmZones[i]) or isElementWithinColShape(attacker, AntiDmZones[i]) then
			cancelEvent()
		end
		i=i+1
	end
	end)

	addEventHandler("onClientPlayerDamage", getRootElement(), function (attacker)
	local i = 1
	while AntiDmZones[i]
	do
		outputChatBox(tostring(getElementType(AntiDmZones[i])))
		if isElementWithinColShape(source, AntiDmZones[i]) or isElementWithinColShape(attacker, AntiDmZones[i]) then
			cancelEvent()
		end
		i=i+1
	end
	end)

	addEventHandler("onClientVehicleDamage", getRootElement(), function (attacker)
	local i = 1
	while AntiDmZones[i]
	do
		outputChatBox(tostring(getElementType(AntiDmZones[i])))
		if isElementWithinColShape(source, AntiDmZones[i]) or isElementWithinColShape(attacker, AntiDmZones[i]) then
			cancelEvent()
		end
		i=i+1
	end
	end)

	addEventHandler("onClientPlayerStealthKill", getRootElement(), function (attacker)
	local i = 1
	while AntiDmZones[i]
	do
		outputChatBox(tostring(getElementType(AntiDmZones[i])))
		if isElementWithinColShape(source, AntiDmZones[i]) or isElementWithinColShape(attacker, AntiDmZones[i]) then
			cancelEvent()
		end
		i=i+1
	end
	end)

	end)

And even if ped inside the colshape, check returns false. But if player inside colshape - check returns true. Two hours spent to find out what is the problem - two hours just wasted.

 

Sorry for my weird usage of loops.

Edited by f8upd8
Link to comment

Guys... Imma very, very angry now, because i wasted three hours finding error in my little code, but it is a MTA bug. When i re-connected to the server, interior and ped loaded normally, and both checks returned true. Before, i just reloaded hundred and hundred times my script by resource manager. Visually, ped was exist. But in fact - client thinked that source Ped is outside the colshape. All working fine now. Thank you.

Link to comment
14 minutes ago, f8upd8 said:

Guys... Imma very, very angry now, because i wasted three hours finding error in my little code, but it is a MTA bug. When i re-connected to the server, interior and ped loaded normally, and both checks returned true. Before, i just reloaded hundred and hundred times my script by resource manager. Visually, ped was exist. But in fact - client thinked that source Ped is outside the colshape. All working fine now. Thank you.

It's all lies. I reloaded server, and first check returned false again. Awww. crap!

Link to comment
12 hours ago, StormFighter said:

So... your ped is in the 3rd interior in the 2nd zone. If the dimension or the interior is different for the colshape or something, your script won't work.

Actually, problem was in freeze state of my ped. Because they're didi not move, colshape hit never happened. When i removed freeze state and hit my ped with grenade, both checks returned true. So i decided not to remove freeze state, i decided to spawn ped a quite upper (Z coord), so ped moves any way and colshape hit is happening. Colshape and ped is in same dimension and interior.

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