would it be more proffesional to replace MAX_PLAYERS?
#1

I am about to open server that is going to have 30-40 players, and the thing about making loops with "MAX_PLAYERS" bothers me(MAX_PLAYERS defined as 255 so every "for" loop from 0 to 255 goes 255 times while the server has only 40 players and its not necesery) so I thought about making an integer lets name it "HigestID" evry time someone connects then this "HighestID" checks if the id of player is higher then varible in "HighestID", when its is higher then HighestID=playerid, its seems cool but when the player with the "HighestID" disconnects then its have to loop all way downto the next high id, so I am wondering would it be more proffesional to work in that way? or should I just stick with MAX_PLAYERS?

Reply
#2

IsPlayerConnected()
Reply
#3

pawn Код:
for (new i = 0; i < GetMaxPlayers ; i++)
https://sampwiki.blast.hk/wiki/GetMaxPlayers
Reply
#4

Quote:
Originally Posted by //exora
IsPlayerConnected()
How is that helpful at all...

If you are already using MAX_PLAYERS, put this at the top of your script:

pawn Код:
#undef MAX_PLAYERS
#define MAX_PLAYERS 40
Reply
#5

the problem is, that the server would be running with 40 people but its can get to 200 players, the solution of GetMaxPlayers would just return me 200 and ill have to check(in most of the time) 160 id's for nothing... and you didn't told me what you think about my idea, you just gave another solution...
Reply
#6

Quote:
Originally Posted by dice7
pawn Код:
for (new i = 0; i < GetMaxPlayers ; i++)
https://sampwiki.blast.hk/wiki/GetMaxPlayers
So you want to call that function time and time again? Not exactly efficient, is it?
Reply
#7

GetServerVarsAsInteger("maxplayers");
Reply
#8

Quote:
Originally Posted by Pghpunkid
GetServerVarsAsInteger("maxplayers");
pawn Код:
#undef MAX_PLAYERS
new MAX_PLAYERS = GetServerVarsAsInteger("maxplayers");
should work
Reply
#9

Quote:
Originally Posted by /^We(stie|z+[e|a
r)$/ ]
Quote:
Originally Posted by dice7
pawn Код:
for (new i = 0; i < GetMaxPlayers ; i++)
https://sampwiki.blast.hk/wiki/GetMaxPlayers
So you want to call that function time and time again? Not exactly efficient, is it?
GetMaxPlayers

Returns the maximum number of players that can play on your server. You can not use predefined MAX_PLAYERS instead of this function, as MAX_PLAYERS defaults to 200. GetMaxPlayers is in contrast read from the server.cfg

that's what the wiki says there i dunno what u mean
it just get's ur maximum players that u can have on you server.

tho u could make a variable like.

pawn Код:
new players;

OnPlayerConnect(playerid)
{
players ++;
return 1;
}

OnPlayerDisconnect(playerid,reason)
{
players --;
return 1;
}
and then simply

for (new i = 0; i < players ; i++)
Reply
#10

The above solution plain wouldn't work.

The best thing to do, is simply redefine MAX_PLAYERS

pawn Код:
#undef MAX_PLAYERS
#define MAX_PLAYERS 100
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)