SA-MP Forums Archive
A better way to do this pattern? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: A better way to do this pattern? (/showthread.php?tid=642359)



A better way to do this pattern? - Rotzank - 29.09.2017

So I'm doing this

PHP Code:
for(new 010i++)
{
    
printf("%i"- (((5) * 2) * (5)));
}
 
// output
[00:49:200
[00:49:201
[00:49:202
[00:49:203
[00:49:204
[00:49:205
[00:49:204
[00:49:203
[00:49:202
[00:49:20
I just wanna know if there's a better way to do that.


Re: A better way to do this pattern? - Misiur - 29.09.2017

You are worrying too much too early. Unless you notice that it's a bottleneck, I would not worry about it. However if you want more readable code, I'd go with
pawn Code:
new
    total = 10,
    peak = total / 2
;

for(new i = 0; i < total; i++)
{
    new j = i;
    if (i >= peak) {
        j = total - i;
    }

    printf("%i", j);
}