Jail Timer
#5

Okay. This can be scripted, but it will have one problem. The problem is you will have limited number of players that are jailed.
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));
    }
}
Didn't test it, but checked it few times, and it looks good.
Reply


Messages In This Thread
Jail Timer - by Armands - 08.08.2012, 23:08
Re: Jail Timer - by Shetch - 09.08.2012, 10:20
Re: Jail Timer - by Roko_foko - 09.08.2012, 10:25
Re: Jail Timer - by Shetch - 09.08.2012, 10:28
Re: Jail Timer - by Roko_foko - 09.08.2012, 10:59
Re: Jail Timer - by IceMeteor - 09.08.2012, 11:33

Forum Jump:


Users browsing this thread: 1 Guest(s)