Burgershot
[Pawn] static const help - Printable Version

+- Burgershot (https://www.burgershot.gg)
+-- Forum: SA-MP (https://www.burgershot.gg/forumdisplay.php?fid=3)
+--- Forum: Pawn Scripting (https://www.burgershot.gg/forumdisplay.php?fid=10)
+--- Thread: [Pawn] static const help (/showthread.php?tid=2111)



static const help - Zow - 2021-06-15

https://fiddle.sa-mp.dev/CeramicDecisiveKronosaurus

Is it good to use?


RE: static const help - Pinch - 2021-06-15

You can use it! :)


RE: static const help - Zow - 2021-06-15

sorry, I just confuse myself


RE: static const help - Kwarde - 2021-06-15

Yes, you can.

local static: When using 'static' on a lower level (like you did) it's value will be remembered.
Code:
myCode()
{
    for (new i; i < 10; i++)
    {
        static x;
        x++;
        printf("%i", x);
    }
}
This would print "1" up to "10". If you would use "new x;" it would print "1" 10 times.

global static: When using 'static' on highest level (outside any function, eg. near your includes) it means that variable may only be used in that file.

const: constant. When declaring a variable as a constant it cannot be altered. Eg. if you'd try to use format() or simply setting the value of your string in your example, it would not compile.