TheMtaUser555 Posted June 27, 2012 Share Posted June 27, 2012 I got my other scripts to work, so I think it should be okay if I asked for some help here. I want to get vehicle's speed before he hits another vehicle, the problem is, it always returns the same speed (180 or 179kph), no matter how fast or slow I'm going. What I'm doing wrong here? https://wiki.multitheftauto.com/wiki/OnC ... eCollision function collision(collider,force, bodyPart, x, y, z, vx, vy, vz) if (getElementType (collider) == "vehicle") and (source == getPedOccupiedVehicle (getLocalPlayer())) then actualspeed = (vx^2 + vy^2 + vz^2)^(0.5) kmh = actualspeed * 180 outputChatBox(kmh) end end addEventHandler("onClientVehicleCollision", root, collision) Link to comment
Castillo Posted June 27, 2012 Share Posted June 27, 2012 But that event is triggered on collision, how do you expect to get the speed before hit on the event that is triggered on collision? Link to comment
TheMtaUser555 Posted June 27, 2012 Author Share Posted June 27, 2012 But that event is triggered on collision, how do you expect to get the speed before hit on the event that is triggered on collision? read the wiki, it says : velocityX: the X velocity of the source before the collision took place velocityY: the Y velocity of the source before the collision took place velocityZ: the Z velocity of the source before the collision took place Link to comment
Castillo Posted June 27, 2012 Share Posted June 27, 2012 Forget about what I said. function collision ( collider, force, bodyPart, x, y, z, vx, vy, vz ) if (getElementType (collider) == "vehicle") and (source == getPedOccupiedVehicle (getLocalPlayer())) then actualspeed = ( vx ^ 2 + vy ^ 2 + vz ^ 2 ) ^ 0.5 * 1.61 * 100 outputChatBox ( actualspeed ) end end addEventHandler("onClientVehicleCollision", root, collision) I copied how getElementSpeed function works, try it. Link to comment
TheMtaUser555 Posted June 27, 2012 Author Share Posted June 27, 2012 @Solidsnake14 got the same result (but 160/161kph this time), I guess it's bugged, or something else must be done. Thanks anyways 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