19.04.2013, 08:09
Just wondering which method is 'better':
They both have the exact same result.
pawn Код:
stock GetVehicleTireStates(vehicleid, &FL, &BL, &FR, &BR)
{
if(GetVehicleModel(vehicleid) == 0) return 0; // Vehicle doesn't exist
new panels, doors, lights, tires;
GetVehicleDamageStatus(vehicleid, panels, doors, lights, tires);
// Which is better
// THIS
FL = !!(tires & 0b1000); // 8
BL = !!(tires & 0b100); // 4
FR = !!(tires & 0b10); // 2
BR = !!(tires & 0b1); // 1
// !! turns the value in to a bool (1/0).
// or THIS?
BR = tires & 1;
FR = tires >> 1 & 1;
BL = tires >> 2 & 1;
FL = tires >> 3 & 1;
return 1;
}