• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] static const help
#1
https://fiddle.sa-mp.dev/CeramicDecisiveKronosaurus



Is it good to use?
  Reply
#2
You can use it! :)
Using Pawn.CMD?

If you're doing so, this is the very first sign that you absolutely shouldn't utilize your all powerful P-Code knowledge in any of the scripting discussion topics.
  Reply
#3
sorry, I just confuse myself
  Reply
#4
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.
  Reply


Forum Jump: