AleksCore Posted June 11, 2015 Share Posted June 11, 2015 (edited) 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 June 12, 2015 by Guest Link to comment
AleksCore Posted June 11, 2015 Author Share Posted June 11, 2015 When I use lua function to make it unbreakable it works bad, because I can stuck in this arrows and car collides badly with themIdk 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
AleksCore Posted June 11, 2015 Author Share Posted June 11, 2015 I can show why setObjectBreakable function working bad for me on the video, but later Link to comment
Blaawee Posted June 11, 2015 Share Posted June 11, 2015 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 IIYAMA Posted June 11, 2015 Moderators Share Posted June 11, 2015 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
AleksCore Posted June 11, 2015 Author Share Posted June 11, 2015 setObjectBreakable is bad, I stuck in object. onClientObjectBreak a bit better but still stuck Link to comment
Moderators IIYAMA Posted June 11, 2015 Moderators Share Posted June 11, 2015 You could try to attach an army door to it and set the alpha to 0. Link to comment
AleksCore Posted June 11, 2015 Author Share Posted June 11, 2015 Well seems like this is the only solution Link to comment
AleksCore Posted June 12, 2015 Author Share Posted June 12, 2015 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
AleksCore Posted June 12, 2015 Author Share Posted June 12, 2015 I need to getCreatedElements at first somehow Link to comment
Ren_712 Posted June 12, 2015 Share Posted June 12, 2015 I'd suggest changing the object into more appropriate one. How about this: -- 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
Moderators IIYAMA Posted June 12, 2015 Moderators Share Posted June 12, 2015 Destroy elements? The cleanest way is porbably setElementParent. When the map stops the children will be destroyed too. Link to comment
Pipee20k Posted June 12, 2015 Share Posted June 12, 2015 Destroy elements? The cleanest way is porbably setElementParent. When the map stops the children will be destroyed too. Didn't know this function haha Link to comment
AleksCore Posted June 12, 2015 Author Share Posted June 12, 2015 Destroy elements? The cleanest way is porbably setElementParent. When the map stops the children will be destroyed too. Sounds great. But who(what element) must be parent in this case? If it should be map root, then how can I get it? Link to comment
Moderators IIYAMA Posted June 12, 2015 Moderators Share Posted June 12, 2015 The glass object would be enough. Link to comment
AleksCore Posted June 12, 2015 Author Share Posted June 12, 2015 Thanks man! The solution was so easy You helped very much, thanks! Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now