Simple MAX_PLAYERS question - 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: Simple MAX_PLAYERS question (
/showthread.php?tid=558284)
Simple MAX_PLAYERS question -
Supermaxultraswag - 16.01.2015
Код:
new var;
new var[MAX_PLAYERS];
Whats the difference between these 2? As I heard, "[MAX_PLAYERS]" is more for one specific player... Can you explain in more detail?
Re: Simple MAX_PLAYERS question -
mahdi499 - 16.01.2015
As far as i know,
The first one Is a global variable that can be assigned a value , and it only has 1 value always. so if you change it anywhere in the script it will be that value.
the 2nd one, is a global variable that is attatched to a player, When you change the value it will only change for that player. not for everyone.
Re: Simple MAX_PLAYERS question -
Dignity - 16.01.2015
The first line is a regular variable, whereas the second one is an array.
[MAX_PLAYERS] (default size of 500) is simply the size of the variable. It can be anything as long as it holds a value.
https://sampwiki.blast.hk/wiki/Scripting_Basics#Variables
https://sampwiki.blast.hk/wiki/Scripting_Basics#Arrays
Re: Simple MAX_PLAYERS question -
xVIP3Rx - 16.01.2015
"new var" is one storage, "new var[MAX_PLAYERS];" is storage for each player, it's called an array
Read This
Re: Simple MAX_PLAYERS question -
Sithis - 16.01.2015
If you use the first, you will be able to store one value in that one variable.
If you use the second, you will be able to store a value for every player in your server. This type of variable is called an array. You can access it by doing:
PHP код:
new Money[MAX_PLAYERS];
Money[playerid] = 500;
You can then set a variable per individual player: useful for other systems.
Re: Simple MAX_PLAYERS question -
Supermaxultraswag - 17.01.2015
Ok, thanks, now other question. MAX_PLAYERS define 500, yes? So, does it will be the same if I do
Re: Simple MAX_PLAYERS question -
jackx3rx - 17.01.2015
Yes, its the same - but its recommended to use MAX_PLAYERS.