SA-MP Forums Archive
Change Player Slots In Script - 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: Change Player Slots In Script (/showthread.php?tid=87756)



Change Player Slots In Script - V1ceC1ty - 22.07.2009

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


Re: Change Player Slots In Script - Badger(new) - 22.07.2009

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.


Re: Change Player Slots In Script - Diogo_Linheiro - 22.07.2009

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;
}



Re: Change Player Slots In Script - V1ceC1ty - 22.07.2009

i get this error

error 017: undefined symbol "NEW_MAX_PLAYERS"

and i have put #define NEW_MAX_PLAYERS 50 at the top


Re: Change Player Slots In Script - V1ceC1ty - 22.07.2009

if anyone could help it would be appriciated


Re: Change Player Slots In Script - yezizhu - 22.07.2009

Код:
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;
}



Re: Change Player Slots In Script - V1ceC1ty - 22.07.2009

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"



Re: Change Player Slots In Script - yezizhu - 22.07.2009


Код:
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?


Re: Change Player Slots In Script - V1ceC1ty - 22.07.2009

Server: Unknown Command when i try /changemax



Re: Change Player Slots In Script - yezizhu - 22.07.2009

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