Jump to content

Unbreakable glass [Solved]


Recommended Posts

https://community.multitheftauto.com/ind ... s&id=11609

In this resource arrow-object is glass. But glass is breakable object. And I want unbreakable arrows.

It is glass because when I use other objects, I can't make them transparent using shader that good as it works with glass.

When I use lua function to make it unbreakable it works bad, because I can stuck in this arrows and car collides badly with them.

So I have one solution in mind - attach normal dff to this arrows with alpha 0. But maybe someone knows better solution?

Edited by Guest
Link to comment
When I use lua function to make it unbreakable it works bad, because I can stuck in this arrows and car collides badly with them
Idk why it happens, maybe because object is too thin. In this case I must try to make a bit thicker collision and check it again. But I don't think that problem in this
Link to comment

How about this?

addEventHandler( "onClientResourceStart", root, 
    function( ) 
        for _, object in ipairs( getElementsByType ( "object" ) ) do 
            if getElementModel( object ) == 3851 and isObjectBreakable( object ) then 
                setObjectBreakable( object, false ); 
            end 
    end 
); 

Link to comment
  • Moderators

or: https://wiki.multitheftauto.com/wiki/On ... bjectBreak

addEventHandler("onClientObjectBreak", root, 
    function(attacker) 
        if getElementModel( source ) == 3851 then 
            cancelEvent() 
        end 
    end 
) 

This code will stay working when you start another map with the same objects etc.

This is a solid solution, without bugs. It only uses a little bit more memory, but you won't notice it.

Enjoy.

Link to comment

I creating objects this way:

addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        local objects = getElementsByType("object") 
        for k, object in ipairs(objects) do  
            if getElementModel(object) == 3851 then 
            setObjectBreakable(object, false) 
            local x, y, z = getElementPosition(object) 
            local rx, ry, rz = getElementRotation(object) 
            newObj = createObject(18000, x, y, z, rx, ry, rz) 
            setElementAlpha(newObj, 0) 
            end 
        end 
    end 
) 

But how can I destroy all this objects when resource stop?

Link to comment

I'd suggest changing the object into more appropriate one. How about this:

200px-UVScollScreen.jpg

-- Apply to world texture 
engineApplyShaderToWorldTexture ( shader, "bobo_2" ) 
  
-- Create object with model 4729 (billboard) 
local x,y,z = getElementPosition( getLocalPlayer() ) 
theObject = createObject ( 4729, x-15, y, z+3 ) 
setElementAlpha(theObject, 254) 

You might get some alpha issues. Might 'in an ugly way' fix them by exporting the object from gta3.img, then replacing ingame using mta engine functions - setting alpha transparency to 'true'. Or just create this object in front of the breakable one, set alpha to 0 so the wall is not visible.

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