Auto jail issue, when reconnects [Simple] - 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: Auto jail issue, when reconnects [Simple] (
/showthread.php?tid=649386)
Auto jail issue, when reconnects [Simple] -
PundacheMakalae - 08.02.2018
I have a jail system, it cannot be evaded even if a player quits and come back. Theres a timer added under ongamemodeinit and it calls in every second to see if the player jailed variable is set 0 and if it is 0, the player will be released from the jail. The script is set to jail the player when they spawn after the quit and join back [anti evade]. But the problem here is when someone quits and connect back, the variable is set to 0 on OnPlayerConnect [remember the timer is running every second], until they login and within seconds it calls that the player isnt in jail with the varible set as 0 as they connect. Heres the code so that you would understand it much better
pawn Код:
//Ongamemodeinit
SetTimer("AutoUnjail",1020,1);
//AutoJail as this calls in every second
public AutoUnjail(player1){
if(PlayerInfo[player1][Jailed] == 1){
if (PlayerInfo[player1][LJailTime] > 0){
PlayerInfo[player1][LJailTime] --;
new jtime;
new string[128];
jtime = (PlayerInfo[player1][LJailTime]);
format(string, sizeof(string), "~w~JAILTIME..~n~ %d",jtime);
GameTextForPlayer(player1, string, 3000,6);
JailTimeServed[player1] ++;}
if (PlayerInfo[player1][LJailTime] == 0){
new pname[24];
GetPlayerName(player1, pname, 24);
new string[128];
SetPlayerInterior(player1,3);
SetPlayerPos(player1,210.5272,146.3341,1003.0234);
SetPlayerFacingAngle(player1,179.4662);
SetCameraBehindPlayer(player1);
cannotescapejail[player1] =0;
SendClientMessage(player1,0x00C7FFAA,"You have been released from jail. You are free to leave the area.");
format(string, sizeof(string), "%s(%d) has been released from jail. JailTime Served: %d Seconds",pname,player1,JailTimeServed[player1]);
SendClientMessageToAll(0x00C7FFAA, string);
PlayerInfo[player1][Jailed] = 0;
JailTimer[player1] = -1;
JailTimeServed[player1] =0;}}}
I cant think of anything to fix this, any ideas to how to fix it would be appreciated
Re: Auto jail issue, when reconnects [Simple] -
Hrb - 08.02.2018
Try this:
Код:
new bool:IsLoggedIn[MAX_PLAYERS];
forward AutoUnjail();
//OnGameModeInit
SetTimer("AutoUnjail", 1020, 1);
//OnPlayerDissconnect
IsLoggedIn[playerid] = false;
// when player successfully logs in
IsLoggedIn[playerid] = true;
//AutoJail as this calls in every second
public AutoUnjail()
{
for(new i;i<MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i))
{
if(IsLoggedIn[i])
{
if(PlayerInfo[i][Jailed] == 1)
{
if(PlayerInfo[i][LJailTime] > 0)
{
new string[24];
format(string, sizeof(string), "~w~JAILTIME..~n~ %d",PlayerInfo[i][LJailTime]);
GameTextForPlayer(i, string, 1000, 6);
//------------------------------------------------------
PlayerInfo[i][LJailTime] --;
JailTimeServed[i] ++;
}
else if(PlayerInfo[i][LJailTime] == 0)
{
new pname[MAX_PLAYER_NAME], string[97];
GetPlayerName(i, pname, MAX_PLAYER_NAME);
format(string, sizeof(string), "%s (%d) has been released from jail. JailTime Served: %d Seconds", pname, i, JailTimeServed[i]);
SendClientMessageToAll(0x00C7FFAA, string);
SendClientMessage(i,0x00C7FFAA,"You have been released from jail. You are free to leave the area.");
//------------------------------------------------------
SetPlayerInterior(i,3);
SetPlayerPos(i,210.5272,146.3341,1003.0234);
SetPlayerFacingAngle(i,179.4662);
SetCameraBehindPlayer(i);
cannotescapejail[i] = 0;
PlayerInfo[i][Jailed] = 0;
JailTimer[i] = -1;
JailTimeServed[i] =0;
}
}
}
}
}
return 1;
}
Re: Auto jail issue, when reconnects [Simple] -
Mugala - 08.02.2018
does the player's jail state have a saver?