Jail - 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: Jail (
/showthread.php?tid=332329)
Jail -
Gooday - 07.04.2012
How to make Jail ID Time? And after the time unjail?
Re: Jail -
ReneG - 07.04.2012
This has stumped me before as well.
The way the God Father (or every single RP script out there) does it is they set a repeating timer of 1 second and loop through all the players. Every time the timer is called, their jail time variable is lowered, and once it equals 0, they become free.
Re: Jail -
Gooday - 07.04.2012
Example please? +REP!
Re: Jail -
Catalyst- - 07.04.2012
pawn Код:
new InJail[MAX_PLAYERS],
JailTime[MAX_PLAYERS];
public OnGameModeInit()
{
SetTimer("JailTimer", 1000, true);
return 1;
}
forward JailTimer();
public JailTimer()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(InJail[i] == 1)
{
if(JailTime[i] > 0)
JailTime[i]--;
if(JailTime[i] == 0)
{
JailTime[i] = 0;
InJail[i] = 0;
SpawnPlayer(i);
}
}
}
}
return 0;
}
Also, add this to your jail command...
pawn Код:
JailTime[playerid] = 300 // Change to amount of time you want to jail a player for, in seconds.
InJail[playerid] = 1;