Change Player Slots In Script
#1

is there a way to change amount of players inside the script? Not the server.cfg?
Reply
#2

you could do:
pawn Код:
#define NEW_MAX_PLAYERS 64
// replace 64 with the ammount you want

public OnPlayerConnect(playerid)
{
  new p;
  for(new i; i<NEW_MAX_PLAYERS;i++)
  {
    if(IsPlayerConnected(i);p++;
  }
  if(p>=64){SendClientMessage(playerid,0xFF0000AA,"This server is full. Try again later."); Kick(playerid);}
  return 1;
}
However it wouldn't keep trying to connect the player, it would just kick them.
Reply
#3

Quote:
Originally Posted by -The_Badger-
you could do:
pawn Код:
#define NEW_MAX_PLAYERS 64
// replace 64 with the ammount you want

public OnPlayerConnect(playerid)
{
  new p;
  for(new i; i<NEW_MAX_PLAYERS;i++)
  {
    if(IsPlayerConnected(i);p++;
  }
  if(p>=64){SendClientMessage(playerid,0xFF0000AA,"This server is full. Try again later."); Kick(playerid);}
  return 1;
}
However it wouldn't keep trying to connect the player, it would just kick them.
this is the right code...

pawn Код:
#define NEW_MAX_PLAYERS 64
// replace 64 with the ammount you want

public OnPlayerConnect(playerid)
{
  new p;
  for(new i; i<NEW_MAX_PLAYERS;i++)
  {
    if(IsPlayerConnected(i))p++;
  }
  if(p>=64){SendClientMessage(playerid,0xFF0000AA,"This server is full. Try again later."); Kick(playerid);}
  return 1;
}
Reply
#4

i get this error

error 017: undefined symbol "NEW_MAX_PLAYERS"

and i have put #define NEW_MAX_PLAYERS 50 at the top
Reply
#5

if anyone could help it would be appriciated
Reply
#6

Код:
new 
  server_max_player = MAX_PLAYERS;
OnPlayerConnect(playerid){
  new 
    pAmount;
  for(new i;i<MAX_PLAYERS;i++)
    if(IsPlayerConnected(i)
      pAmount++;
  if(pAmount > server_max_player){
    SendClientMessage(playerid,COLOR_YOUWANT,"Server is full.");
    kick(playerid);
  }
  return true;
}

OnPlayerCommandText(playerid,cmdtext[]){
  if(!strcmp("/changemax ",cmdtext,true,11){
    server_max_player = strval(cmdtext[11]);
    printf("max player changed to %d",server_max_player);
    return true;
  }
  return false;
}
Reply
#7

im getting 3 errors on the /changemax command

pawn Код:
C:\DOCUME~1\Jake\Desktop\SAMP-S~1\GAMEMO~1\DMA.pwn(1231) : error 001: expected token: ")", but found "{"
C:\DOCUME~1\Jake\Desktop\SAMP-S~1\GAMEMO~1\DMA.pwn(1232) : error 017: undefined symbol "server_max_player"
C:\DOCUME~1\Jake\Desktop\SAMP-S~1\GAMEMO~1\DMA.pwn(1233) : error 017: undefined symbol "server_max_player"
Reply
#8


Код:
new 
  server_max_player = MAX_PLAYERS;
OnPlayerConnect(playerid){
  new 
    pAmount;
  for(new i;i<MAX_PLAYERS;i++)
    if(IsPlayerConnected(i)
      pAmount++;
  if(pAmount > server_max_player){
    SendClientMessage(playerid,COLOR_YOUWANT,"Server is full.");
    kick(playerid);
  }
  return true;
}

OnPlayerCommandText(playerid,cmdtext[]){
  if(!strcmp("/changemax ",cmdtext,true,11)){
    server_max_player = strval(cmdtext[11]);
    printf("max player changed to %d",server_max_player);
    return true;
  }
  return false;
}
okay?
Reply
#9

Server: Unknown Command when i try /changemax
Reply
#10

Try
"/changemax 36"
not "/changemax"
Aren't you want anyone in your server know this command?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)