arciCZ Posted November 2, 2017 Share Posted November 2, 2017 Hello, I have a question, is there any chance to find out when a player shoots what part of the car he has hit? Link to comment
quindo Posted November 2, 2017 Share Posted November 2, 2017 You can use https://wiki.multitheftauto.com/wiki/OnClientVehicleDamage to get position where the bullet hit the car, and after that loop over vehicle components list and find which one was closest to the hit. It will not be at all precise, there may be some better way, i can't think of it now tho. Link to comment
ShayF2 Posted November 3, 2017 Share Posted November 3, 2017 addEventHandler('onClientPlayerWeaponFire',root,function(weapon,ammo,aic,x,y,z,hitElement) if hitElement then if getElementType(hitElement) == 'vehicle' then local components = getVehicleComponents(hitElement) for i=1,#components do local 2x,2y,2z = getComponentWorldPosition(components[i]) if x == 2x and y == 2y and z == 2z then return components[i] end end end end end) function getComponentWorldPosition(vehicle,component) local m = getElementMatrix(vehicle) local x,y,z = getVehicleComponentPosition(vehicle,component) local wX = x*m[1][1]+y*m[2][1]+z*m[3][1]+m[4][1] local wY = x*m[1][2]+y*m[2][2]+z*m[3][2]+m[4][2] local wY = x*m[1][3]+y*m[2][3]+z*m[3][3]+m[4][3] return wX,wY,wZ end This only works if you shoot dead center of the component. So you may have to modify it to do what you want. This is as far as I can help. Sorry. Link to comment
Moderators IIYAMA Posted November 3, 2017 Moderators Share Posted November 3, 2017 https://wiki.multitheftauto.com/wiki/OnClientPlayerWeaponFire with https://wiki.multitheftauto.com/wiki/ProcessLineOfSight would do the job. 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