%i time...
#1

How can I make:

/adminjail ID time

And set the time?
Reply
#2

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.
Reply
#3

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
Reply
#4

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.
Reply
#5

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!
Reply
#6

How to:

%s has jailed you for %i seconds?

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

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
Reply
#8

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"
Reply
#9

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


Forum Jump:


Users browsing this thread: 1 Guest(s)