SA-MP Forums Archive
What is MAX_PLAYERS and MAX_VEHICLES? - 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: What is MAX_PLAYERS and MAX_VEHICLES? (/showthread.php?tid=657185)



What is MAX_PLAYERS and MAX_VEHICLES? - R3SpaWn0 - 02.08.2018

Hi all ! I wonder why, some variables doesn't have [MAX_PLAYERS] and other have.. why? when i have to use MAX_PLAYERS?

same with MAX_VEHICLES

PHP код:
new FactionData[MAX_FACTIONS][factionData];
new 
FactionRanks[MAX_FACTIONS][15][32];
new 
GateData[MAX_GATES][gateData]; 
same with this? MAX_FACTIONS, MAX_GATES, WHY USING THIS MAX_&s ?


Re: What is MAX_PLAYERS and MAX_VEHICLES? - Juvanii - 02.08.2018

MAX_PLAYERS used in defining variables with an array contains the max ID's of players.
MAX_VEHICLES used in defining variables with an array contains the max ID's of vehicles.

PHP код:
new Banned[MAX_PLAYERS]; // Variable for players only
new Locked[MAX_VEHICLES]; // Variable for vehicles only
public OnPlayerConnect(playerid//playerid is the player who joined now.
{
    if(
Banned[playerid] == 1)
    {
        
SendClientMessage(playerid, -1"You are banned !");
        
Kick(playerid);
        return 
1;
    }
    return 
1;
}
public 
OnPlayerEnterVehicle(playeridvehicleidispassenger)
{
    if(
Locked[vehicleid] == 1// the vehicleid is the same vehicleid parameter of OnPlayerEnterVehicle Callback.
    
{
        
SendClientMessage(playerid, -1"This Vehicle is locked.");
        
ClearAnimations(playerid); // Clears the player's animation (stopping him from entering this vehicle)
        
return 1;
    }
    return 
1;




Re: What is MAX_PLAYERS and MAX_VEHICLES? - Dayrion - 02.08.2018

Quote:
Originally Posted by R3SpaWn0
Посмотреть сообщение
Hi all ! I wonder why, some variables doesn't have [MAX_PLAYERS] and other have.. why? when i have to use MAX_PLAYERS?

same with MAX_VEHICLES

PHP код:
new FactionData[MAX_FACTIONS][factionData];
new 
FactionRanks[MAX_FACTIONS][15][32];
new 
GateData[MAX_GATES][gateData]; 
same with this? MAX_FACTIONS, MAX_GATES, WHY USING THIS MAX_&s ?
There are constant values which you can found them in a_samp.inc. They can be redefined
PHP код:
// Limits and internal constants
#define MAX_PLAYER_NAME                            (24)
#define MAX_PLAYERS                                (1000)
#define MAX_VEHICLES                            (2000)
#define MAX_ACTORS                                (1000) 



Re: What is MAX_PLAYERS and MAX_VEHICLES? - R3SpaWn0 - 02.08.2018

Oh, thank you all, i understand now <3 +rep everyone, how to rep?!!


Re: What is MAX_PLAYERS and MAX_VEHICLES? - ISmokezU - 02.08.2018

Quote:
Originally Posted by Dayrion
Посмотреть сообщение
There are constant values which you can found them in a_samp.inc. They can be redefined
PHP код:
// Limits and internal constants
#define MAX_PLAYER_NAME                            (24)
#define MAX_PLAYERS                                (1000)
#define MAX_VEHICLES                            (2000)
#define MAX_ACTORS                                (1000) 
Don't we undefined before we redefined?


Re: What is MAX_PLAYERS and MAX_VEHICLES? - Unkovic - 02.08.2018

Kurac baki


Re: What is MAX_PLAYERS and MAX_VEHICLES? - GRiMMREAPER - 02.08.2018

Quote:
Originally Posted by ISmokezU
Посмотреть сообщение
Don't we undefined before we redefined?
Yes.

pawn Код:
#if defined MAX_PLAYERS
    #undef MAX_PLAYERS
    #define MAX_PLAYERS (200)
#endif

...

printf("%i", MAX_PLAYERS); // Will return the newly defined value, 200.
However, I believe all he was trying to do was show the predefined values (check Limits).


Re: What is MAX_PLAYERS and MAX_VEHICLES? - Dayrion - 03.08.2018

Quote:
Originally Posted by ISmokezU
Посмотреть сообщение
Don't we undefined before we redefined?
Yes, you right. I said redefined which mean undefine and define it again.


Re: What is MAX_PLAYERS and MAX_VEHICLES? - DBZdabIt3Bro7 - 03.08.2018

Quote:
Originally Posted by Dayrion
Посмотреть сообщение
There are constant values which you can found them in a_samp.inc. They can be redefined
PHP код:
// Limits and internal constants
#define MAX_PLAYER_NAME                            (24)
#define MAX_PLAYERS                                (1000)
#define MAX_VEHICLES                            (2000)
#define MAX_ACTORS                                (1000) 
Just to add on this, never redefine MAX_PLAYER_NAME, MAX_PLAYERS, MAX_VEHICLES or MAX_ACTORS unless you're lowering the value. Anything higher than what's stated at Wiki: Scripting Limits can cause the server to crash if the index is later on used over the already defined limits.