[Include] conversions.inc
#1

Some day I learned operator:

PHP код:
onesoperator=(a)
    return 
ones: ( (>= 0) ? : ~(-a) ) 
And made a conversion:

PHP код:
Millisecondsoperator=(Seconds:a)
    return 
Milliseconds: ( _:1000 );
new 
Milliseconds: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.
Reply
#2

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.
Reply
#3

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)