Burgershot
  • Home
  • Members
  • Team
  • Help
  • Search
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search
Burgershot SA-MP Pawn Scripting [Pawn] static const help

 
  • 0 Vote(s) - 0 Average
Pawn static const help
Zow
Offline

Burgershot Member
Posts: 34
Threads: 20
Joined: Apr 2019
Reputation: 0
Location: Malaysia
#1
2021-06-15, 03:15 PM
https://fiddle.sa-mp.dev/CeramicDecisiveKronosaurus

Is it good to use?
Pinch
Offline

Burgershot Member
Posts: 391
Threads: 19
Joined: Apr 2019
Reputation: 22
Location: Belgrade, Serbia
#2
2021-06-15, 05:04 PM
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.
Zow
Offline

Burgershot Member
Posts: 34
Threads: 20
Joined: Apr 2019
Reputation: 0
Location: Malaysia
#3
2021-06-15, 09:17 PM
sorry, I just confuse myself
Kwarde
Offline

Burgershot Member
Posts: 99
Threads: 2
Joined: Sep 2020
Reputation: 8
Location: The Netherlands
#4
2021-06-15, 11:36 PM (This post was last modified: 2021-06-15, 11:36 PM by Kwarde.)
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.
« Next Oldest | Next Newest »



  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Burgershot - Powered by our Community and MyBB Original Theme by Emerald

Linear Mode
Threaded Mode