27.09.2014, 11:33
(
Последний раз редактировалось V1ceC1ty; 27.09.2014 в 12:42.
)
I'm currently testing a formula to work out an incrementing value based on what number is entered but for some strange reason what is output is completely different from what should output. I'm just wondering if there is a specific way I need to format this for pawn that I'm doing wrong?
EDIT: TL; DR version, I need this PHP code converted to pawn.
I'm basing this off a php formula I found, which works 100%. Test it here if you need to http://writecodeonline.com/php/
This is my command for testing the formula
What outputs:
What should output but doesn't:
EDIT: TL; DR version, I need this PHP code converted to pawn.
I'm basing this off a php formula I found, which works 100%. Test it here if you need to http://writecodeonline.com/php/
Код:
function formula($L) { $a=0; for($x=1; $x<$L; $x++) { $a += floor($x+300*pow(2, ($x/7))); } return floor($a/4); } for($L=1;$L<100;$L++) { echo 'Result '.$L.': '.formula($L).'<br />'; }
pawn Код:
CMD:checkformula(playerid, params[])
{
new Float:formula, Float:result, string[128];
for(new i = 1; i<4; i++)
{
formula = (i+300*(floatpower(2, i/7)));
result = (formula/4);
format(string, sizeof(string), "For Input: %i, Formula = %i, Result = %i", i, floatround(formula), floatround(result));
SendClientMessage(playerid, 0xCCFF00AA, string);
}
return 1;
}
Код:
For input: 1, Formula = 301, Result = 75 For input: 2, Formula = 302, Result = 76 For input: 3, Formula = 303, Result = 76
Код:
For input: 1, Formula = 332, Result = 83 For input: 2, Formula = 699, Result = 174 For input: 3, Formula = 1105, Result = 276