Jump to content

[How to script] Variables - PART 1


DeclineD
 Share

Recommended Posts

  • Co-Founder

What are variables?

 

The variables are basically just names/simbols which hold a value

To create them you have to use 'new', 'static' or 'const' (you can also use 'new const').

 

new x = 0
---------
const x = 0
---------
static x; x = 0;
// or
static x
x = 0
--------
new const x = 0

 

What's the difference between 'new', 'static' and 'const'?

 

When you create a variable with 'new', the variable can be changes afterwards.

When you create a variable with 'static', you can only set the value after you created it, you can't set it when you create it. (Shown in the example above)

When you create a variable with 'const', you can only set the value when you create it and can't be changed afterwards.

 

How many types of variables exist?

 

Regardless of the way you create it, there are 6 types:

- Float Variables, which hold numbers with .x.

- Number Variables, which hold numbers

- Bool Variables, which hold 2 different values, true or false.

- Strings Variables, which hold text.

- Character Variables, which hold a single character.

- Byte Variables, which hold bytes.

 

new Float:x = 1.3
new x = 0
new bool:x = false
new x[3] = "idk"
new x = 'A'
new x = (1<<4)

 

If you have any question, ask here

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

  • Noxx changed the title to [How to script] Variables - PART 1
  • Founder

Can you make it better with images maybe, and is it important, and in which things we use this variables 🤨

@ DeclineD  please tell me 😂 

3v2wBBE.png

newlife.png

3v2wBBE.png

AT9fjk3.png

2dF2JCB.gifConnect : 93.115.53.168:27016 - ZE

2dF2JCB.gifConnect : 93.115.53.168:27017 - FR

2dF2JCB.gifConnect : 93.115.53.168:27021 - ZP

2dF2JCB.gifConnect : 93.115.53.168:27018 - SF

AT9fjk3.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use