24.01.2012, 15:41
I is it possilbe to save 1 slot for me becouse sometimes server is full and i (admin) can't get in
I is it possilbe to save 1 slot for me becouse sometimes server is full and i (admin) can't get in
|
if( ( g_ConnectedPlayers++ ) >= MAX_PLAYERS )
{
if( p_AdminLevel[ playerid ] < 1 )
{
//message
return Kick( playerid ), 1;
}
}
pawn Код:
You can remove the "++" within the if statement if doing so since it can bug. |
public OnPlayerConnect(playerid)
{
if(!IsPlayerAdmin(playerid)) if(playerid == MAX_PLAYERS-1) Kick(playerid);
return 1;
}
#include <a_samp>
main()
{
print("\n----------------------------------");
print(" Bare Script\n");
print("----------------------------------\n");
}
#define RESERVED_SLOTS 1 //Amount of reserved slots
#define DIALOG_ID 10 //Dialog ID to use for ReservedDialog
#define RESERVED_PASSWORD "yarhar" //Reserver Slots Password, case sensitive
#undef MAX_PLAYERS
#define MAX_PLAYERS 500 //Set this to the amount of slots your server has
new SlotsRemaining;
new ReservedList[RESERVED_SLOTS][MAX_PLAYER_NAME]=
{
//"Other_Names",
"Joe_Staff"
};
forward ReservedDialog(playerid,timeremaining,NameMatch);
public ReservedDialog(playerid,timeremaining,NameMatch)
{
//Compare Name to Reserved List
new tmp[256];
if(NameMatch==0)
{
GetPlayerName(playerid,tmp,24);
for(new name;name<RESERVED_SLOTS;name++)if(!strcmp(tmp,ReservedList[name]))NameMatch=1;
}
//If timeremaining = 0 then kick
if(timeremaining<=0)return Kick(playerid);
//if player's id doesn't reach the reserved slots range, let continue
if(playerid<=MAX_PLAYERS-SlotsRemaining)
{
if(NameMatch)SlotsRemaining--;
return 0;
}else{
if(NameMatch)
{
format(tmp,256,"Please type in the server's reserved slot password.\nYou have %02d seconds remaining...");
ShowPlayerDialog(playerid,DIALOG_ID,DIALOG_STYLE_MSGBOX,"Reserved Slot Password",tmp,"Submit","Cancel");
SetTimerEx("ReservedDialog",1000,0,"dd",playerid,timeremaining-1,1);
}else{
format(tmp,256,"This server has %d reserved slots. You must wait until more slots are available");
SendClientMessage(playerid,0xFFFFFF00,tmp);
return Kick(playerid);
}
}
return 0;
}
public OnGameModeInit()
{
SlotsRemaining=RESERVED_SLOTS;
}
public OnPlayerConnect(playerid)
{
ReservedDialog(playerid,30,0);
}
public OnPlayerDisconnect(playerid,reason)
{
new tmp[24];
GetPlayerName(playerid,tmp,24);
for(new name;name<RESERVED_SLOTS;name++)if(!strcmp(tmp,ReservedList[name]))SlotsRemaining++;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid!=DIALOG_ID)return 1;
if(!response)return Kick(playerid);
if(strcmp(inputtext,RESERVED_PASSWORD))
{
SendClientMessage(playerid,0xFFFFFF00,"Incorrect Password. Please wait until more slots are available");
Kick(playerid);
return 0;
}
SlotsRemaining--;
return 0;
}