Jump to content

Object Damage


joedajoester

Recommended Posts

Hi, i need a script that when a object gets damages it will disappear when it gets damaged like with a gun, how would i make a object dissappear or fall when it gets damage? I attempted using parts of kwksnd 's titan script when you shoot all 3 of the cores. I just need a script that enables objects that are created with scripts and disappear when damaged.

this is the part of the script i found on wiki.

https://wiki.multitheftauto.com/wiki/SetElementData

Thanks :D

Link to comment
function onClientPlayerWeaponFireFunc(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement) 
    if (hitElement and getElementType(hitElement) == "object") then 
        destroyElement(hitElement) 
    end 
end 
addEventHandler("onClientPlayerWeaponFire", root, onClientPlayerWeaponFireFunc) 

This should destroy the object you've just shoot at.

Link to comment

Hi, i used the script like this (below) and nothing happens, the object is created but i shoot at it and nothing happens.

object = createObject (2976, 2, 2, 2) 
function onClientPlayerWeaponFireFunc(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement) 
    if (hitElement and getElementType(hitElement) == "object") then 
        destroyElement(hitElement) 
    end 
end 
addEventHandler("onClientPlayerWeaponFire", root, onClientPlayerWeaponFireFunc) 

Please help with this someone

Link to comment
object = createObject (2976, 2, 2, 2) 
  
function onClientPlayerWeaponFireFunc(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement) 
    if (hitElement and getElementType(hitElement) == "object" and hitElement == object) then 
        destroyElement(hitElement) 
    end 
end 
addEventHandler("onClientPlayerWeaponFire", root, onClientPlayerWeaponFireFunc) 

Link to comment
object = createObject (2976, 2, 2, 2) 
  
function onClientPlayerWeaponFireFunc(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement) 
    if (hitElement == object) then 
        destroyElement(hitElement) 
    end 
end 
addEventHandler("onClientPlayerWeaponFire", root, onClientPlayerWeaponFireFunc) 

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