MAX_PLAYERS what is this?
#1

what is [MAX_PLAYERS] and what is it used for. i dont get it. ive seen it numerous times but i personally dont use it lol, only because i have no idea whats it for
Reply
#2

MAX_PLAYERS is the maximum amount of players that SA-MP server can hold at once, which means that MAX_PLAYERS is 200.

Usually MAX_PLAYERS is used in variables that check if player does something or for example counts kills:

pawn Код:
new kills[MAX_PLAYERS];

public OnPlayerDeath(playerid, killerid, reason)
{
    kills[killerid]++; // Adds one kill for killedid.
    return 1;
}
Reply
#3

i still dont get it. why even use it then. so max_players puts a playerid unique to a declaration?
Reply
#4


new kills[MAX_PLAYERS];

public OnPlayerDeath(playerid, killerid, reason)
{
kills[killerid]++; // Adds one kill for killedid.
return 1;
}

if(strcmp(cmd, "/kills", true) == 0)
{
new str[256];

format(str, sizeof(str), "You have killed %d players )!",kills);//this is a example to haw to use this
SendClientMessage(playerid, 0xAA3333AA, str);
return 1;
}

This code besikly stores information of a playerid...


Reply
#5

Roban[swe]: Learn to indent, script and use [ pawn ] tags.
Reply
#6

Quote:
Originally Posted by icey--t
i still dont get it. why even use it then. so max_players puts a playerid unique to a declaration?
it would usually be used in an array, to create a variable slot for each player.

e.g.

pawn Код:
new money;
Is just one cell. You can only store one number in it.
pawn Код:
new money[MAX_PLAYERS];
Creates 200 cells (MAX_PLAYERS is just a define for 200). You can store a number in each of them.

_________________________________________________

With that, you can store players information easily.

pawn Код:
money[playerid] = GetPlayerMoney(playerid);
printf("playerid %d has $%d",playerid, money[playerid]);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)