it took me time to find out a really really simple problem! Anyways here's the fully tested code, it works perfectly and doesn't return and incorrect values.
pawn Код:
public OnGameModeInit()
{
printf("Tax 10%% of 1,000 = %.2f", CalculateTax(1000, 5.0) );
printf("Tax 10%% of 1,000 = %.2f", CalculateTax(1000, 10.0) );
printf("Tax 15%% of 1,000 = %.2f", CalculateTax(1000, 15.0) );
printf("Tax 20%% of 1,000 = %.2f", CalculateTax(1000, 20.0) );
printf("Tax 25%% of 1,000 = %.2f", CalculateTax(1000, 25.0) );
printf("Tax 30%% of 1,000 = %.2f", CalculateTax(1000, 30.0) );
printf("Tax 35%% of 1,000 = %.2f", CalculateTax(1000, 35.0) );
printf("Tax 40%% of 1,000 = %.2f", CalculateTax(1000, 40.0) );
printf("Tax 45%% of 1,000 = %.2f", CalculateTax(1000, 45.0) );
printf("Tax 50%% of 1,000 = %.2f", CalculateTax(1000, 50.0) );
printf("Tax 55%% of 1,000 = %.2f", CalculateTax(1000, 55.0) );
printf("Tax 60%% of 1,000 = %.2f", CalculateTax(1000, 60.0) );
printf("Tax 65%% of 1,000 = %.2f", CalculateTax(1000, 65.0) );
printf("Tax 70%% of 1,000 = %.2f", CalculateTax(1000, 70.0) );
printf("Tax 75%% of 1,000 = %.2f", CalculateTax(1000, 75.0) );
printf("Tax 80%% of 1,000 = %.2f", CalculateTax(1000, 80.0) );
printf("Tax 85%% of 1,000 = %.2f", CalculateTax(1000, 85.0) );
printf("Tax 90%% of 1,000 = %.2f", CalculateTax(1000, 90.0) );
printf("Tax 95%% of 1,000 = %.2f", CalculateTax(1000, 95.0) );
return true;
}
CalculateTax(args1, Float:args2)
{
if(0.0 > args2 > 100.0 && args1 < 0) return false; //return false if args2 is above 100% and below 0% same as the args1.
return _:(args1 / 100 * args2);
}
/*
[19:28:21] Tax 10% of 1,000 = 50.00
[19:28:21] Tax 10% of 1,000 = 100.00
[19:28:21] Tax 15% of 1,000 = 150.00
[19:28:21] Tax 20% of 1,000 = 200.00
[19:28:21] Tax 25% of 1,000 = 250.00
[19:28:21] Tax 30% of 1,000 = 300.00
[19:28:21] Tax 35% of 1,000 = 350.00
[19:28:21] Tax 40% of 1,000 = 400.00
[19:28:21] Tax 45% of 1,000 = 450.00
[19:28:21] Tax 50% of 1,000 = 500.00
[19:28:21] Tax 55% of 1,000 = 550.00
[19:28:21] Tax 60% of 1,000 = 600.00
[19:28:21] Tax 65% of 1,000 = 650.00
[19:28:21] Tax 70% of 1,000 = 700.00
[19:28:21] Tax 75% of 1,000 = 750.00
[19:28:21] Tax 80% of 1,000 = 800.00
[19:28:21] Tax 85% of 1,000 = 850.00
[19:28:21] Tax 90% of 1,000 = 900.00
[19:28:21] Tax 95% of 1,000 = 950.00
*/