AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Can somebody explain this to me? (https://forums.alliedmods.net/showthread.php?t=309281)

blAck. 07-19-2018 18:44

Can somebody explain this to me?
 
Since I'm new, I was wondering what does 'sz' stands for?
I've seen some stuff like szName, szNameReceiver, szAmount, szCommand...
Please can somebody explain this to me?

Ghosted 07-19-2018 18:49

Re: Can somebody explain this to me?
 
I don't know what sz means but we use sz to know if variable is string (for readability & not for compiling)

blAck. 07-19-2018 19:02

Re: Can somebody explain this to me?
 
Quote:

Originally Posted by Ghosted (Post 2604935)
I don't know what sz means but we use sz to know if variable is string (for readability & not for compiling)

I still don't get it.. Can you explain a little bit more?

Natsheh 07-19-2018 20:57

Re: Can somebody explain this to me?
 
Quote:

Originally Posted by blAck. (Post 2604937)
I still don't get it.. Can you explain a little bit more?

sz means "string of characters, terminated by a null character" (z stands for zero).

fysiks 07-19-2018 22:30

Re: Can somebody explain this to me?
 
Quote:

Originally Posted by blAck. (Post 2604933)
Since I'm new, I was wondering what does 'sz' stands for?
I've seen some stuff like szName, szNameReceiver, szAmount, szCommand...
Please can somebody explain this to me?

"string, zero-terminated"

Meaning that the end of the string is denoted by a value of zero. This is why you must always size an array being used as a string with one extra element (for the zero-termination).

Code:

szString[7] = "hello"

string[0] = 'h' = 104
string[1] = 'e' = 101
string[2] = 'l' = 108
string[3] = 'l' = 108
string[4] = 'o' = 111
string[5] = EOS = 0
string[6] =

I didn't show a value for string[6] because it is ignored because it comes after the zero-termination; it could be any value.

Prefixing is not required but because Pawn is typeless, it is generally recommended to prefix your variable so that people, including yourself, know what you are actually using the variable for.

Other often used prefixes:

Code:

integer:  i
boolean:  b
Float:  f
string:  sz

For more about basic Pawn programming, you should look through the tutorials. This one is really good. Other tutorials can be found here.

CrazY. 07-20-2018 10:42

Re: Can somebody explain this to me?
 
To be more easily and specific, it's just a tag to use when declaring variables that will store strings (words, chars, etc).

E1_531G 07-20-2018 15:02

Re: Can somebody explain this to me?
 
Quote:

Originally Posted by CrazY. (Post 2605069)
To be more easily and specific, it's just a tag to use when declaring variables that will store strings (words, chars, etc).

In fact, it isn't a tag, it's a sort of a name convention, like Hungarian Notation.

Tags are:
1. bool:
2. Float:
3. Array:
4. Trie:
and others.

CrazY. 07-20-2018 15:07

Re: Can somebody explain this to me?
 
I said "tag" to be more specific.
https://forums.alliedmods.net/showthread.php?t=308561

E1_531G 07-20-2018 16:57

Re: Can somebody explain this to me?
 
'Prefix' is the good word here.


All times are GMT -4. The time now is 12:34.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.