09.08.2012, 10:59
Okay. This can be scripted, but it will have one problem. The problem is you will have limited number of players that are jailed.
Didn't test it, but checked it few times, and it looks good.
pawn Код:
//--------------definitions-----------------
#define MAX_JAILED_PLAYERS 1500
//_________________________________________________
//--------------global variables------------
new JailedName[MAX_JAILED_PLAYERS][MAX_PLAYER_NAME];
new JailedTime[MAX_JAILED_PLAYERS];
//_________________________________________________
//-------------forwarded functions-----------------
forward public OneSecondTimer();
//-------------------------------------------------
public OnGameModeInit()
{
new i;
for(i=0;i<MAX_JAILED_PLAYERS;i++)
{
JailedName[i][0]=0;
JailedTime[i]=0;
}
SetTimer("OneSecondTimer",1000,true);
}
ReleasePlayerFromJail(num)
{
new i;
for(i=0;i<MAX_PLAYERS;i++)if(IsPlayerConnected(i))
{
if(!strcmp(JailedName[num],GetPlayerName(i))
{
SendClientMessage(i,0x00FF00FF,"You have served you time in jail.");
//released player is online, set him on his "released" position
}
}
for(i=num;i<MAX_JAILED_PLAYERS && JailedName[i][0]!=0;i++)
{
JailedName[i]="";
strcat(JailedName[i],JailedName[i+1]);
JailedTime[i]=JailedTime[i+1];
}
}
public OneSecondTimer()// It would be good if you use this timer not only for Jailed peapole.
{
for(new i=0;i<MAX_JAILED_PLAYERS && JailedName[i][0]!=0;i++)
{
if(--JailedTime[i]==0)ReleasePlayerFromJail(i);
}
}
//when prisoning someone
{
new i;
for(i=0;JailedName[i][0]!=0 &&i<MAX_JAILED_PLAYERS;i++)
if(i==MAX_JAILED_PLAYERS)SendClientMessage(PlayerThatIsPrisoning,0xFF0000FF,"Prison is full at moment");
else
{
JailedTime[i]=TimeToServeInJailInSeconds;
JailedName[i]="";
strcat(JailedName[i],GetPlayerName(PrisonedGuyID));
}
}