MAX_PLAYERS what is this? -
icey--t - 18.02.2009
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
Re: MAX_PLAYERS what is this? -
Finn - 18.02.2009
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;
}
Re: MAX_PLAYERS what is this? -
icey--t - 18.02.2009
i still dont get it. why even use it then. so max_players puts a playerid unique to a declaration?
Re: MAX_PLAYERS what is this? -
robanswe - 20.02.2009
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...
Re: MAX_PLAYERS what is this? -
Mikep - 20.02.2009
Roban[swe]: Learn to indent, script and use [ pawn ] tags.
Re: MAX_PLAYERS what is this? -
kc - 20.02.2009
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.
Is just one cell. You can only store one number in it.
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]);