SA-MP Forums Archive
MAX_PLAYERS and MAX_PLAYER_NAME - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: MAX_PLAYERS and MAX_PLAYER_NAME (/showthread.php?tid=247976)



MAX_PLAYERS and MAX_PLAYER_NAME - Seven_of_Nine - 11.04.2011

Hi all!

I'm kinda new here so deal with my beginner question?

I want to know what does MAX_PLAYERS and MAX_PLAYER_NAME exactly.

I mean, MAX_PLAYERS ok ok it's like 50 but then why do you put after a new string?
And I don't even know what is MAX_PLAYER_NAME.

Please help me!


Re: MAX_PLAYERS and MAX_PLAYER_NAME - Jochemd - 11.04.2011

Max players after a new string? Sounds like a bad idea, cause you would put (if standard) 500 cells in the string.

MAX PLAYERS should be used in a loop, if you want to loop through all players. MAX PLAYER NAME is 24 and should be used when you get a players name with GetPlayerName.


Re: MAX_PLAYERS and MAX_PLAYER_NAME - Seven_of_Nine - 11.04.2011

Thanks but can you write down an explained example?


Re: MAX_PLAYERS and MAX_PLAYER_NAME - Jochemd - 11.04.2011

Quote:
Originally Posted by Seven_of_Nine
Посмотреть сообщение
Thanks but can you write down an explained example?
Yeah sure

pawn Код:
if(!strcmp(cmdtext,"/myname",true))
{
    new Playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid,Playername,sizeof(Playername));
    SendClientMessage(playerid,-1,Playername);
    return 1;
}
This just writes the players name.

Other example comes later.


Re: MAX_PLAYERS and MAX_PLAYER_NAME - Alby Fire - 11.04.2011

Quote:
Originally Posted by Jochemd
Посмотреть сообщение
Max players after a new string? Sounds like a bad idea, cause you would put (if standard) 500 cells in the string.

MAX PLAYERS should be used in a loop, if you want to loop through all players. MAX PLAYER NAME is 24 and should be used when you get a players name with GetPlayerName.
MAX PLAYERS is the same as 500... then if your server isn't a 500 slots server it's totally useless...
It would be better to put on the top of your gamemode
pawn Код:
#undef MAX_PLAYERS
#define MAX_PLAYERS (number_of_your_slots)



Re: MAX_PLAYERS and MAX_PLAYER_NAME - Jochemd - 11.04.2011

Quote:
Originally Posted by Jochemd
Посмотреть сообщение
Max players after a new string? Sounds like a bad idea, cause you would put (if standard) 500 cells in the string.
Here we go

I got the other example here;

pawn Код:
if(!strcmp(cmdtext,"/admins",true))
{
    new AdminName[MAX_PLAYER_NAME],string[15];
    for(new i = 0; i < MAX_PLAYERS; i ++) // This loops through all players, which means this code gets executed for every player
    {
        if(IsPlayerConnected(i)) // The code after this will only be executed if the player is connected
        {
            if(IsPlayerAdmin(i)) // The code after this will only be executed if the player is RCON Admin
            {
                GetPlayerName(i,AdminName,sizeof(AdminName); // Gets the player's name
                format(string,sizeof(string),"%s is RCON Admin.",AdminName); // Puts the Admins name in the string
                SendClientMessage(playerid,-1,string); // Sends the message we formatted above
            }
        }
    }
    return 1;
}



Re: MAX_PLAYERS and MAX_PLAYER_NAME - Seven_of_Nine - 11.04.2011

Thanks for replies, AND I wrote my first work:
Kicker / Banner
I'm not sure it works (of course I'm not..) because this is the first script I ever made so


Re: MAX_PLAYERS and MAX_PLAYER_NAME - Jochemd - 11.04.2011

Nope it wouldn't, since kickid would always be 0

Use a proper command processor, such as DCMD/ZCMD/YCMD. They're simple on processing params.


Re: MAX_PLAYERS and MAX_PLAYER_NAME - Seven_of_Nine - 11.04.2011

Quote:
Originally Posted by Jochemd
Посмотреть сообщение
Nope it wouldn't, since kickid would always be 0

Use a proper command processor, such as DCMD/ZCMD/YCMD. They're simple on processing params.
Can you bold that part or replace for me?

You're so kind by the way


Re: MAX_PLAYERS and MAX_PLAYER_NAME - Seven_of_Nine - 11.04.2011

Sorry for DB:
Is this right?