A doubt with variables - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: A doubt with variables (
/showthread.php?tid=402327)
A doubt with variables -
JavoDiaz - 26.12.2012
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.
Re: A doubt with variables -
mineralo - 26.12.2012
its not big differents but better use without "char"
Re: A doubt with variables -
Konstantinos - 26.12.2012
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!)
Re: A doubt with variables -
JavoDiaz - 28.12.2012
I don't understand well that, can someone explain me better?
Re: A doubt with variables -
Lordzy - 28.12.2012
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.
Re: A doubt with variables -
[HiC]TheKiller - 28.12.2012
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.
Re: A doubt with variables -
JavoDiaz - 28.12.2012
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.
Re: A doubt with variables -
JavoDiaz - 29.12.2012
I don't understand well the documentation can you explain me better? Thank you.
Re: A doubt with variables -
JavoDiaz - 29.12.2012
But I don't know english very well so I need to someone explain me in not so formal language.