I really doubt that would happen in fact it would never happen
anyways I was very curious to see what is the best way to do this and it seems the switch() is the best method interestingly.
Код:
#include <a_samp>
static bool:RetVals[3] = {
false,
false,
true
};
public OnFilterScriptInit()
{
new time = GetTickCount();
new bool:locked;
new doors = -1;
for(new j = 0; j < 3; j++)
{
printf("\nResults When Doors = %i", doors);
for(new i = 0; i < 1000000; i++)
{
locked = doors == VEHICLE_PARAMS_ON ? true : false;
}
printf("Time::Assignment/Ternary::%i", GetTickCount() - time);
time = GetTickCount();
for(new i = 0; i < 1000000; i++)
{
locked = RetVals[doors+1];
}
printf("Time::Array Referencing::%i", GetTickCount() - time);
time = GetTickCount();
for(new i = 0; i < 1000000; i++)
{
switch(doors)
{
case VEHICLE_PARAMS_ON: locked = true;
default: locked = false;
}
}
printf("Time::Switch::%i", GetTickCount() - time);
for(new i = 0; i < 1000000; i++)
{
if(doors == 1) locked = true;
else locked = false;
}
printf("Time::if/else::%i", GetTickCount() - time);
time = GetTickCount();
doors++;
}
}
Results When Doors = -1
[12:49:27] Time::Assignment/Ternary::84
[12:49:27] Time::Array Referencing::78
[12:49:27] Time::Switch::71
[12:49:27] Time::if/else::146
Results When Doors = 0
[12:49:27] Time::Assignment/Ternary::85
[12:49:27] Time::Array Referencing::77
[12:49:27] Time::Switch::69
[12:49:27] Time::if/else::140
Results When Doors = 1
[12:49:27] Time::Assignment/Ternary::72
[12:49:28] Time::Array Referencing::75
[12:49:28] Time::Switch::78
[12:49:28] Time::if/else::173