SA-MP Forums Archive
%i time... - 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)
+--- Thread: %i time... (/showthread.php?tid=331906)



%i time... - Gooday - 06.04.2012

How can I make:

/adminjail ID time

And set the time?


Re: %i time... - MP2 - 06.04.2012

Use sscanf to get the parameters, then use gettime() to tell how many seconds have passed by storing the time when they were jailed and subtracting that from the current time - telling you how many seconds they've been in jail for.


Re: %i time... - Cjgogo - 06.04.2012

On top of your gamemode,or wherever before the command:

pawn Код:
new coutn;
new counttimer;

forward JailTime(playerid);
pawn Код:
COMMAND:adminjail(playerid,params[])
{
   if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_RED,"You're not admin");
   else
   {
      new time,playerid2;
      if(sscanf(params("ud",playerid,time)) return SendClientMessage(playerid,COLOR_RED,"USAGE:/adminjail [ID] [Time(in seconds)]");
      coutn=time;
      SetPlayerPos(playerid2,JAIL COORDINATES);
      counttimer=SetTimerEx("JailTime",1000,1,"i",playerid2);
      SendClientMessage(playerid,COLOR_GREEN,"Player has been jailed");
      SendClientMessage(playerid2,COLOR_RED,"You have been jailed by an admin!");
   }
 return 1;
}
After the command:
pawn Код:
public JailTime(playerid)
{
   countn--;
   if(countn<=-1)
   {
      KillTimer(counttimer);
      SetPlayerPos(playerid,OUTSIDEJAIL COORDINATES);
      SendClientMessage(playerid,COLOR_GREEN,"Unjailed!");
   }
 return 1;
}
I typed this in less then 5 mins,so,adapt it to your specifications :P


Re: %i time... - MP2 - 06.04.2012

Using a timer will impact performance, my method will not. Plus your method is in-accurate, as are timers.

EDIT: On second thoughts, if he wants to display the jail time to the player a timer probably would be best.


Re: %i time... - AndreT - 06.04.2012

Cjgogo, you need to use an array for storing the player's jail time. Otherwise all players will be jailed for the same time amount!


Re: %i time... - Gooday - 06.04.2012

How to:

%s has jailed you for %i seconds?

and to the "jailer" you have jailed %s for %i seconds


Re: %i time... - Cjgogo - 06.04.2012

pawn Код:
public JailTime(playerid)
{
   countn--;
   new string[250];
   format(string,sizeof(string),"You are jailed for %d seconds!",countn);
   GameTextForPlayer(playerid,string,countn*1000,4);
   if(countn<=-1)
   {
      KillTimer(counttimer);
      SetPlayerPos(playerid,OUTSIDEJAIL COORDINATES);
      SendClientMessage(playerid,COLOR_GREEN,"Unjailed!");
   }
 return 1;
}
That shows time to the jailed player


Re: %i time... - Gooday - 06.04.2012

Anyone? CJGOGO is not working... I would also send a message with "You have jailed %s for %i"

And "You have been admin jailed by %s for %i"


Re: %i time... - Harish - 07.04.2012

pawn Код:
///Arrest System --
forward JailTimer(playerid);
public JailTimer(playerid)
{
    SendClientMessage(playerid,0xFFFFFF,"You are Released be a good citizen");
    SetPlayerInterior(playerid,6);
    SetPlayerPos(playerid,246.783996,63.900199,1003.640625);//here use your release pos
}
//on Player Command
if(strcmp(cmd, "/ar", true) == 0)
    {
        new tmp[128];
        tmp = strtok(cmd,idx);

        if(strlen(tmp) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /ar [playerid]");
        new arid = strval(tmp);
        if(gTeam[playerid] != TEAM_LSPD)
        {
            SendClientMessage(playerid,COLOR_RED,"Only cops can use this..");
        }
        else
        {
            new Float:coppos[3];
            GetPlayerPos(playerid,coppos[0],coppos[1],coppos[2]);
            if(IsPlayerInRangeOfPoint(arid,10.0,coppos[0],coppos[1],coppos[2]))
            {
                new WantedLevel = GetPlayerWantedLevel(arid);
                if(WantedLevel !=0)
                {
                    SetPlayerInterior(arid,6);
                    SetPlayerPos(arid,246.783996,63.900199,1003.640625);//here use your jail pos                        
                    SetTimerEx("JailTimer",40000,0,"d",arid);///This the timer for releasing the suspect
                    new CName[MAX_PLAYER_NAME],ArName[MAX_PLAYER_NAME],Str[128];
                    GetPlayerName(playerid,CName,sizeof(CName));
                    GetPlayerName(arid,ArName,sizeof(ArName));
                                        new arTime = 40000;
                    format(Str,sizeof(Str),"officer %s Arrested the Suspect %s for %d Seconds",CName,ArName,arTime/1000);//check this
                    SendClientMessageToAll(0xFFFFFF,Str);
                }
                else{SendClientMessage(playerid,0xFFFFFF,"Suspect was an innocent");}
            }
            else{SendClientMessage(playerid,0xFFFFFF,"Arresting Player was not in Range");}
        }
        return 1;
    }