Tockra Posted May 12, 2010 Posted May 12, 2010 Hi guys, i want know, how i can make a speedometer (clock). And how can i get the currently moving speed? I know, that i can download a resource for it already but i want to make my own...
dzek (varez) Posted May 12, 2010 Posted May 12, 2010 Hi guys,i want know, how i can make a speedometer (clock). And how can i get the currently moving speed? I know, that i can download a resource for it already but i want to make my own... download and look how it's done .. you will do it same way anyway.. Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online! programista php rzeszów Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting. Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!
Tockra Posted May 12, 2010 Author Posted May 12, 2010 Hi guys,i want know, how i can make a speedometer (clock). And how can i get the currently moving speed? I know, that i can download a resource for it already but i want to make my own... download and look how it's done .. you will do it same way anyway.. Yes i know but I am inclined to copy parts ^^ And i need a little instruction
dzek (varez) Posted May 12, 2010 Posted May 12, 2010 hmm, well, i know nothing about it.. when i was in need of getting veh speed (for another script - checking if speed is enough), i just copy few lines from speedometer res. i thought there was no need to reinvent the wheel Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online! programista php rzeszów Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting. Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!
50p Posted May 12, 2010 Posted May 12, 2010 You get speed with getElementVelocity. This function returns 3 values (x, y and z) which indicate speed on each axis. If you want to calculate actual speed, you have to 1. Multiply these 3 values by themselves 2. Add them new values up 3. Square root the value you get from adding the new 3 values 4. Multiply new value by 100 or 160 to get actual speed You can also use getElementPosition and getDistanceBetweenPoints3D to get the distance you travelled between last and current frame (onClientRender calls). I find it cleaner and quicker to use the first method. So, like varez said, simpler would be to copy 2 functions from speedometer resource which do exactly what I explained here. - MTA Script Editor - Ask your scripting questions properly, please. - 50p's public resources - Meta.xml - what is it for? How is it possible LOL
Tockra Posted May 13, 2010 Author Posted May 13, 2010 You get speed with getElementVelocity. This function returns 3 values (x, y and z) which indicate speed on each axis. If you want to calculate actual speed, you have to1. Multiply these 3 values by themselves 2. Add them new values up 3. Square root the value you get from adding the new 3 values 4. Multiply new value by 100 or 160 to get actual speed You can also use getElementPosition and getDistanceBetweenPoints3D to get the distance you travelled between last and current frame (onClientRender calls). I find it cleaner and quicker to use the first method. So, like varez said, simpler would be to copy 2 functions from speedometer resource which do exactly what I explained here. Thank you... I have now a idea how i can count the actual axis, but for it i must order the indicator at regular intervals but i dont know how i can make thats. I know only, that i can set them with the gui editor, but so i cant order it in regular intervals...
Salem Posted May 18, 2010 Posted May 18, 2010 4. Multiply new value by 100 or 160 to get actual speed Yes. This values 100 or sth else is the scale of the speed relativity. You have to define world units to obtain this parameter, for example, for yards it takes about 164, for meters about 180. Higher value returns higher speed. Or You can also take this value from your head, withuot any scaling. And, of course, this first method is better. The second one gives strange vibrations taken from 'onClientRender' events. My race maps available here: http://chomikuj.pl/salemander/mta+maps
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