[Include] conversions.inc - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (
https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (
https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] conversions.inc (
/showthread.php?tid=623009)
-
OneDay - 29.11.2016
Some day I learned operator:
PHP код:
ones: operator=(a)
return ones: ( (a >= 0) ? a : ~(-a) )
And made a conversion:
PHP код:
Milliseconds: operator=(Seconds:a)
return Milliseconds: ( _:a * 1000 );
new Milliseconds:a = Seconds:5;
printf("%d", _:a);
// 5000
I now make more conversions:
http://pastebin.com/eCb7tir1
Example:
PHP код:
#include <a_samp>
#include <conversions>
main()
{
new Millimetres:mm = Millimetres:25.4 + Metres:1.0;
printf("%f millimetres",Float:mm);
new Celcius:cc = Celcius:10.0 + Kelvin:10.0;
printf("%f celcius",Float:cc);
new Tonnes:ww = Tonnes:10.0 * 90;
printf("%f tonnes",Float:ww);
}
In the server gives.
PHP код:
1025.4 millimetres
You can convert.
Milliseconds
Seconds
Minutes
Hours
Days
Weeks
Kelvin
Celcius
Millimetres
Centimetres
Metres
Kilometres
Units
Precision_Units
Square_Millimetres
Square_Centimetres
Square_Metres
Square_Kilometres
Hectares
Grammes
Kilogrammes
Tonnes
Millilitres
Litres
Cubic_Centimetres
Cubic_Metres
Units are from GTA.
Four types are:
weight
volume
area
distance
But you cannt combine as:
PHP код:
new Square_Metres:area = Metres:5.0 * Metres:2.0;
Maybe soon yes.
Re: conversions.inc -
Yashas - 29.11.2016
The compiler has to search through a list of tags and look for matching operators everywhere you use an operator. Your include has so many that it makes the compiler very slow.
You cannot make it faster without reducing the number of operator overloads.
Re: conversions.inc -
OneDay - 29.11.2016
Removed all imperial - was too slow compiling.
Removed ares, centiares, deciares, decares - too rare.
Removed decimetres - too rare.
Spelt "killograms" correctly.
CONVERT_TEMPERATURE -> DEFINE_TEMPERATURE
Fixed time tags
Added missing DEFINE_MEASUREMENTs
Multiplication