Behnam-Edit Posted June 7, 2020 Share Posted June 7, 2020 hey everyone , i have been trying to write a simple physics for my server but its been a week since im trying to do this but i cant figure it out im trying to make objects break instantly when they are collided by a vehicle but i dont want it to affect the vehicle ( i mean , disabling the car rotating after the crash or slowing down ) ive tried onClientVehicleCollision , onClientVehicleDamage , OnClientObjectBreak , onClientObjectDamage but i couldnt do it . so guys can you suggest me a way to make it work? Link to comment
MrKAREEM Posted June 7, 2020 Share Posted June 7, 2020 GetElementVelocity SetElementVelocity you can use OnClientVehicleCollision element theHitElement, float force, int bodypart, float collisionX, float collisionY, float collisionZ, float normalX, float normalY, float normalZ, float hitElementForce, int model The source of this event is the vehicle that collided with something so you can get the velocity of the source and controll the hitElement 1 Link to comment
Behnam-Edit Posted June 7, 2020 Author Share Posted June 7, 2020 1 hour ago, MrKAREEM said: GetElementVelocity SetElementVelocity you can use OnClientVehicleCollision element theHitElement, float force, int bodypart, float collisionX, float collisionY, float collisionZ, float normalX, float normalY, float normalZ, float hitElementForce, int model The source of this event is the vehicle that collided with something so you can get the velocity of the source and controll the hitElement thanks for the answer , i tried your method but it didnt work addEventHandler("onClientVehicleCollision", root, function(collider,force, bodyPart, x, y, z, nx, ny, nz) if ( source == getPedOccupiedVehicle(localPlayer) ) then local SX , SY , SZ = getElementVelocity ( source ) setTimer( setElementVelocity, 100, 1, source , SX , SY , SZ ) end end) i tried this if u meant to do it this way Link to comment
MrKAREEM Posted June 7, 2020 Share Posted June 7, 2020 1 minute ago, Behnam-Edit said: thanks for the answer , i tried your method but it didnt work addEventHandler("onClientVehicleCollision", root, function(collider,force, bodyPart, x, y, z, nx, ny, nz) if ( source == getPedOccupiedVehicle(localPlayer) ) then local SX , SY , SZ = getElementVelocity ( source ) setTimer( setElementVelocity, 100, 1, source , SX , SY , SZ ) end end) i tried this if u meant to do it this way addEventHandler("onClientVehicleCollision", root, function(collider,force, bodyPart, x, y, z, nx, ny, nz) local theVehicle = getPedOccupiedVehicle (localPlayer) if (theVehicle) and (source == theVehicle) then local SX , SY , SZ = getElementVelocity ( source ) setTimer( setElementVelocity, 100, 1, source , SX , SY , SZ ) end end) it's important to check if the ped in vehicle or not 1 Link to comment
Behnam-Edit Posted June 7, 2020 Author Share Posted June 7, 2020 1 hour ago, MrKAREEM said: addEventHandler("onClientVehicleCollision", root, function(collider,force, bodyPart, x, y, z, nx, ny, nz) local theVehicle = getPedOccupiedVehicle (localPlayer) if (theVehicle) and (source == theVehicle) then local SX , SY , SZ = getElementVelocity ( source ) setTimer( setElementVelocity, 100, 1, source , SX , SY , SZ ) end end) it's important to check if the ped in vehicle or not yea but it doesnt rly affect the functionality of the script , and still not working . do you have any other ideas ? cause im sure its not gonna work with these: onClientVehicleCollision , onClientVehicleDamage , OnClientObjectBreak , onClientObjectDamage Link to comment
MrKAREEM Posted June 7, 2020 Share Posted June 7, 2020 (edited) 5 minutes ago, Behnam-Edit said: yea but it doesnt rly affect the functionality of the script , and still not working . do you have any other ideas ? cause im sure its not gonna work with these: onClientVehicleCollision , onClientVehicleDamage , OnClientObjectBreak , onClientObjectDamage i think the problem not from the events try to get the speed of the vehicle GetElementSpeed SetElementSpeed because i used the event onClientVehicleCollision before but i force the velocity on the object with some maths not the vehicle Edited June 7, 2020 by MrKAREEM 1 Link to comment
Behnam-Edit Posted June 7, 2020 Author Share Posted June 7, 2020 1 hour ago, MrKAREEM said: i think the problem not from the events try to get the speed of the vehicle GetElementSpeed because i used the event onClientVehicleCollision before but i force the velocity on the object with some maths not the vehicle yeah but i think the problem is from the events cause idk if u saw this in need for speed games or not but when hit a barrier or a fence or lamp post , it doesnt affect the car at all! i mean it doesnt change your vehicle speed or acceleration , i had that in mind for long time i didnt know it was possible in mta but i saw they done it in nfssa server Link to comment
MrKAREEM Posted June 7, 2020 Share Posted June 7, 2020 can you show me an example right vedio or something and i will understand what you mean 1 Link to comment
Behnam-Edit Posted June 7, 2020 Author Share Posted June 7, 2020 1 hour ago, MrKAREEM said: can you show me an example right vedio or something and i will understand what you mean i found this in youtube from nfssa server , if u look closely u see the vehicle doesnt slow down at all when it hits breakable objects Link to comment
Moderators IIYAMA Posted June 8, 2020 Moderators Share Posted June 8, 2020 https://wiki.multitheftauto.com/wiki/EngineSetObjectGroupPhysicalProperty https://wiki.multitheftauto.com/wiki/EngineSetModelPhysicalPropertiesGroup Some new functions you can try. 2 Link to comment
Behnam-Edit Posted June 8, 2020 Author Share Posted June 8, 2020 Just now, IIYAMA said: https://wiki.multitheftauto.com/wiki/EngineSetObjectGroupPhysicalProperty https://wiki.multitheftauto.com/wiki/EngineSetModelPhysicalPropertiesGroup Some new functions you can try. thanks , but can you give me an example? cause ive never worked with physical properties Link to comment
Moderators IIYAMA Posted June 8, 2020 Moderators Share Posted June 8, 2020 16 minutes ago, Behnam-Edit said: thanks , but can you give me an example? cause ive never worked with physical properties Same here As far as I understand of the wiki. - You have group id's which are kind of slots you can use. I don't think you have to create them. Just use 1 for your first try. - Assign the object models you want to change to the group 1. - Then set the properties which you think you need to achieve your goal. 1 Link to comment
Zorgman Posted June 12, 2020 Share Posted June 12, 2020 Never tried to alter the object properties but in case that won't work for some reason, a workaround would be disabling collision for those objects, wrap them in colshapes and break them onColShapeHit. 1 Link to comment
Behnam-Edit Posted June 13, 2020 Author Share Posted June 13, 2020 On 12/06/2020 at 13:45, Zorgman said: Never tried to alter the object properties but in case that won't work for some reason, a workaround would be disabling collision for those objects, wrap them in colshapes and break them onColShapeHit. yea but that would take too much time :)) 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