A doubt with variables
#1

What's the difference between



Case 1:

pawn Код:
new bool:variable[MAX_PLAYERS char];
and

pawn Код:
new bool:variable[MAX_PLAYERS];


Case 2:

pawn Код:
new variable[MAX_PLAYERS char];
and

pawn Код:
new variable[MAX_PLAYERS];


Thanks.
Reply
#2

its not big differents but better use without "char"
Reply
#3

Quote:
Originally Posted by mineralo
Посмотреть сообщение
its not big differents but better use without "char"
Actually, you're not explaining what the char does or when it it used. And there is big different between them.

char (Read me!)
Reply
#4

I don't understand well that, can someone explain me better?
Reply
#5

It returns the number of cells required for that particular string/var. Also used for declaring a variable.
For example,
pawn Код:
new pvar[MAX_PLAYERS char];
//Returns the value of MAX_PLAYERS in the variable.
Reply
#6

I'll try explain this without saying something incorrect in real basic terms. Adding char to a variable reduces the size of the variable and is awesome for reducing sizes. Char restricts variables in the way that it only allows values from 0-255 (no negatives) but with bool there is only two values so why not :P? variable[MAX_PLAYERS] could only have a value from 0 - 255 though and if you want anything over you have to use a normal variable. Char's are accessed in a different way also e.g.

Normal variable
pawn Код:
variable[playerid] = true;
Char variable
pawn Код:
variable{playerid} = true;
Someone correct me if I'm wrong on any parts of this.
Reply
#7

Yes, but a char variable is faster than normal ones? It consume less memory? I already know that char variables support only values from 0 to 255, but my doubt is if I should use it or not, and for bool case the same. Thanks to all for answering.
Reply
#8

I don't understand well the documentation can you explain me better? Thank you.
Reply
#9

But I don't know english very well so I need to someone explain me in not so formal language.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)