Jump to content

[Help] createExplosion -- No damage


Perfect

Recommended Posts

Hi all, I am back to MTA after long time. I am trying to refresh my scripting skills. I make a simple script which will create an explosion at player, which will not damage him/her. But Somehow Players are getting damage.

Here is my script,

function des ( player ) 
    local pX, pY, pZ = getElementPosition ( player ) 
    createExplosion ( pX, pY, pZ, 6, true, -1.0, false ) 
end 
addCommandHandler ( "Boom", des ) 

Link to comment

Using the function will damage the player, if you don't want them to get damaged you should cancel the onPlayerDamage or onClientPlayerDamage whenever it is an explosion. Please note that exploding vehicles, grenades, RPG's and such will not work anymore too. ;)

Link to comment
Using the function will damage the player, if you don't want them to get damaged you should cancel the onPlayerDamage or onClientPlayerDamage whenever it is an explosion. Please note that exploding vehicles, grenades, RPG's and such will not work anymore too. ;)

I can't get an idea on how to do that!

The damage argument only works for client side explosions.

Well, I changed my script to client (in meta) but when i did that there is no explosion at all.

Link to comment
addEventHandler ( "onClientPlayerDamage", root, 
    function ( theWeapon ) 
        if ( theWeapon == 16 ) then -- if it's an grenade, just for an example. 
            cancelEvent(); 
        end 
    end 
); 

After that, change the 6 in your explosion to 0

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