Jail Help
#1

I have an arrest command that works fine, except when the player enters the jail, i want there to be a jail timer.

A timer from like 200 seconds as soon as they are in jail that counts down to 0. When it hits 0 the player is released.


I tried making one, and it never turns out right.


Can someone give me a quick example on how i might do this
Reply
#2

show us the code please
Reply
#3

what code? i dont have any jail code except /ar which jus teleports them to the jail
Reply
#4

pawn Код:
//Under the /jail command add this for the player your placing in jail
//Might wanna replace playerid's
SetPVarInt(playerid, "ReleaseTimer", SetTimerEx("ReleaseFromJail", 200000, false, "i", playerid));

//This will be called for a player after the timer is over...
//Will be released after 2 minutes
stock ReleaseFromJail(playerid)
{
    KillTimer(GetPVarInt(playerid, "ReleaseTimer"));
    SpawnPlayer(playerid);
    return 1;
}
Reply
#5

Quote:
Originally Posted by [___
PotH3Ad ]
pawn Код:
//Under the /jail command add this for the player your placing in jail
//Might wanna replace playerid's
SetPVarInt(playerid, "ReleaseTimer", SetTimerEx("ReleaseFromJail", 200000, false, "i", playerid));

//This will be called for a player after the timer is over...
//Will be released after 2 minutes
stock ReleaseFromJail(playerid)
{
    KillTimer(GetPVarInt(playerid, "ReleaseTimer"));
    SpawnPlayer(playerid);
    return 1;
}
This will only make the timer, i'm not sure how to make it display for the player This is my /ar command:

http://pastebin.com/cpgYmf0T
Reply
#6

Anyone?
Reply
#7

I tried figureing out how to do this too, and it wont work.


I need mine the same as his, so when player gets sent to jail, it sets a timer that shows to the player and counts down.
Reply
#8

Do you people ever read the wiki ? , it would save you a lot of time. Also not many will help you when you cant be bothered to read a few lines in the wiki, i will however help this time because im bored:

https://sampwiki.blast.hk/wiki/SetTimerEx

From wiki:
Note: The function that should be called must be public. That means it has to be forwarded.

So add this line in top of script:
forward ReleaseFromJail(playerid);

Also change the function from stock to public:
public ReleaseFromJail(playerid)

Reply
#9

Quote:
Originally Posted by hansen111
Do you people ever read the wiki ? , it would save you a lot of time. Also not many will help you when you cant be bothered to read a few lines in the wiki, i will however help this time because im bored:

https://sampwiki.blast.hk/wiki/SetTimerEx

From wiki:
Note: The function that should be called must be public. That means it has to be forwarded.

So add this line in top of script:
forward ReleaseFromJail(playerid);

Also change the function from stock to public:
public ReleaseFromJail(playerid)

I do have that.

Код:
forward AutoUnjailAlcatraz();
Код:
public AutoUnjailAlcatraz()
{
  for(new i=0; i < MAX_PLAYERS; i++)
  {
    if (IsPlayerConnected(i))
    {
      if(Jailed[i] == 1 && InAlcatraz[i] == 1)
      {
        if (JailTime[i] > 0)

        {
          JailTime[i] --;
          new jtime;
          jtime = (JailTime[i]);
          format(szstring, sizeof(szstring), "~w~ALCATRAZ~n~..JAILTIME..~n~ %d",jtime);
          GameTextForPlayer(i, szstring, 3000,6);
          JailTimeServed[i] ++;
        }
        if (JailTime[i] == 0)
        {
         GetPlayerName(i, pname, 24);
         new timeserved;
         timeserved = (JailTimeServed[i]);
         SetPlayerPos(i,230.0633,121.7518,1010.2188);
         SetPlayerFacingAngle(i,208.3710);
         SetCameraBehindPlayer(i);
         cannotescapejail[i] =0;
         SendClientMessage(i, 0xA9A9A9AA, "|_Released From Alcatraz_|");
         SendClientMessage(i,0x00C7FFAA,"You have been auto-released from Alcatraz. You are free to leave Alcatraz Island");
         format(szstring, sizeof(szstring), "%s(%d) Has been auto-released from Alcatraz. Time Served: %d Seconds",pname,i,timeserved);
         SendClientMessageToAll(0x00C7FFAA, szstring);
         Jailed[i] = 0;
         InAlcatraz[i] =0;
         JailTimeServed[i] =0;
        }
      }
    }
  }
}
That is my whole unjail thing, I'm not sure how the timer will work...
Reply
#10

My unjail is exactly like ruckfles and i have the same problem
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)