What is MAX_PLAYERS and MAX_VEHICLES?
#1

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 ?
Reply
#2

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;

Reply
#3

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) 
Reply
#4

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

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?
Reply
#6

Kurac baki
Reply
#7

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).
Reply
#8

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.
Reply
#9

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)