Jump to content

block explosions through walls?


Fist

Recommended Posts

Is there a way to block a grenade or any other explosion on other side of the wall if it's near to blow/damage anything besides the wall? I saw it a long time ago on 1 server, but never realized how i can make it nor i can find anything on forums about this.

Edited by Fist
Link to comment
  • Moderators

Possible way to cancel damage and still see the effect.

https://wiki.multitheftauto.com/wiki/OnClientExplosion

https://wiki.multitheftauto.com/wiki/CreateExplosion

Might cause a little temporary desync with other players. (If you cancel the event and other players are near you.)

 

If you saw this at the server from bigbadbutler (chaos.de), then you have to know that he used custom health instead of normal health which is a very different approach.

 

Edited by IIYAMA
Link to comment
27 minutes ago, IIYAMA said:

Possible way to cancel damage and still see the effect.

https://wiki.multitheftauto.com/wiki/OnClientExplosion

https://wiki.multitheftauto.com/wiki/CreateExplosion

Might cause a little temporary desync with other players. (If you cancel the event and other players are near you.)

 

If you saw this at the server from bigbadbutler (chaos.de), then you have to know that he used custom health instead of normal health which is a very different approach.

 

addEventHandler("onClientExplosion",root,function(x,y,z,type)
	if getElementType(source) == "vehicle" or getElementType(source) == "player" or getElementType(source) == "ped" then
		local tX,tY,tZ = getElementPosition(source);
		if not isLineOfSightClear(x,y,z,tX,tY,tZ,true,false,false,true) then
			cancelEvent();
		end
	end
end);

funny is that when it cancels it, it just deletes grenade or explosion before it explodes but when someone else is near that is in sight it still explodes and even those that are not in sight but are near explosion still explodes.

  • Like 1
Link to comment
2 minutes ago, IIYAMA said:

yea, true

Explosions are forced to be sync.

 

Last thing: (clientside only)


 
  1. bool createExplosion ( float x, float y, float z, int theType [, bool makeSound = true, float camShake = -1.0, bool damaging = true ] )

 

Set damaging to false after recreation.

 

P.s. car explosions might look different.

 

i actually found better way doing this.

addEventHandler("onClientVehicleDamage",root,function(attacker,wep,loss,x,y,z,tyreid)
	if (wep == 63 or wep == 51 or wep == 19) then
		cancelEvent();
		local aX,aY,aZ = getElementPosition(attacker);
		local tX,tY,tZ = getElementPosition(source);
		iprint(isLineOfSightClear(tX,tY,tZ,aX,aY,aZ,true,false,false,true),aX,aY,aZ,tX,tY,tZ)
		if isLineOfSightClear(tX,tY,tZ,aX,aY,aZ,true,false,false,true) then
			blowVehicle(source,true);
		end
    end
end);

had to cancel event first though, otherwise it's already too late to cancel it after you checked if line of sight is clear.

  • Confused 1
Link to comment
  • Moderators
Quote

had to cancel event first though, otherwise it's already too late to cancel it after you checked if line of sight is clear.

You sure? Because isLineOfSignClear does not require a callback.

 

addEventHandler("onClientVehicleDamage",root,function(attacker,wep,loss,x,y,z,tyreid)
	if (wep == 63 or wep == 51 or wep == 19) then
		
		local aX,aY,aZ = getElementPosition(attacker);
		local tX,tY,tZ = getElementPosition(source);

		iprint(isLineOfSightClear(tX,tY,tZ,aX,aY,aZ,true,false,false,true),aX,aY,aZ,tX,tY,tZ)
		if not isLineOfSightClear(tX,tY,tZ,aX,aY,aZ,true,false,false,true) then
			cancelEvent();
		end
	end
end);

 

  • blowVehicle does not support the second argument clientside, only serverside. And I wouldn't recommend it to do it clientside because of desync.

 

Edited by IIYAMA
Link to comment
1 minute ago, IIYAMA said:

You sure? Because isLineOfSignClear does not require a callback.

 


addEventHandler("onClientVehicleDamage",root,function(attacker,wep,loss,x,y,z,tyreid)
	if (wep == 63 or wep == 51 or wep == 19) then
		
		local aX,aY,aZ = getElementPosition(attacker);
		local tX,tY,tZ = getElementPosition(source);

		iprint(isLineOfSightClear(tX,tY,tZ,aX,aY,aZ,true,false,false,true),aX,aY,aZ,tX,tY,tZ)
		if not isLineOfSightClear(tX,tY,tZ,aX,aY,aZ,true,false,false,true) then
			cancelEvent();
		end
	end
end);

 

  • blowVehicle does not support the second argument clientside, only serverside. And I wouldn't recommend it to do it clientside because of desync.

 

i'm sure, it didn't work if you cancel it afer you check line of sight. Syncing seems fine with blowVehicle on client side, i even reconnected and vehicle stayed destroyed.

  • Like 1
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...