SA-MP Forums Archive
Serious JAIL Bug! - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Serious JAIL Bug! (/showthread.php?tid=197163)



Serious JAIL Bug! - ShawnMiller1337 - 08.12.2010

Alright to start off I am having a serious problem here everyone... Here's the story

When a cop types /arrest it sets the criminal inside LSPD Jail but the timer dosn't go down if the suspect in the jailcell types /time the Jail Time Left dosn't move it stays the same number , UNLESS THEY RELOG , If they relog.. the timer starts working going down

Now this command /jail is a admin command using the same things , jails them in LSPD etc , the suspect types /time and timer works ... So question is... What is the /arrest command not doing that the /jail command is doing ?


JAIL CODE
Code:
if(strcmp(cmd, "/jail", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /jail [playerid/PartOfName] [time(minutes)]");
				return 1;
			}
			new rand;
			new playa;
			new money;
			playa = ReturnUser(tmp);
			tmp = strtok(cmdtext, idx);
			money = strval(tmp);
			if (PlayerInfo[playerid][pAdmin] >= 2)
			{
			    if(IsPlayerConnected(playa))
			    {
			        if(playa != INVALID_PLAYER_ID)
			        {
				        GetPlayerName(playa, giveplayer, sizeof(giveplayer));
						GetPlayerName(playerid, sendername, sizeof(sendername));
						format(string, sizeof(string), "AdmCmd: %s has sent %s to Jail for %d mins,m trf.", sendername, giveplayer, money);
						SendClientMessageToAll(COLOR_LIGHTRED, string);
						ResetPlayerWeapons(playa);
						WantedPoints[playa] = 0;
						PlayerInfo[playa][pJailed] = 1;
						PlayerInfo[playa][pJailTime] = money*60;
						rand = random(sizeof(PrisonSpawns));
                        SetPlayerPos(playa, PrisonSpawns[rand][0], PrisonSpawns[rand][1], PrisonSpawns[rand][2]);
                        SetPlayerColor(playa, COLOR_PRISON);
                        SetPlayerSkin(playa, 50);
						format(string, sizeof(string), "You are jailed for %d minutes. Bail: Unable.", money);
						SendClientMessage(playa, COLOR_LIGHTBLUE, string);
					}
				}
			}
			else
			{
				SendClientMessage(playerid, COLOR_GRAD1, "   You are not authorized to use that command !");
			}
		}
		return 1;
	}
ARREST CODE:
Code:
	if(strcmp(cmd, "/arrest", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	   	{
			if(IsALawEnforcer(playerid))
			{
    			if(OnDuty[playerid] != 1)
				{
			    	SendClientMessage(playerid, COLOR_GREY, "   You are not on Duty!");
			    	return 1;
				}
				if(IsAtArrestPoint(playerid) > 0)
				{
       				tmp = strtok(cmdtext, idx);
					if(!strlen(tmp))
					{
						SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /arrest [price] [time (minutes)] [bail (0=no 1=yes)] [bailprice]");
						return 1;
					}
					moneys = strval(tmp);
					if(moneys < 1 || moneys > 99999) { SendClientMessage(playerid, COLOR_GREY, "   Jail Price can't be below $1 or above $99,999 !"); return 1; }
					tmp = strtok(cmdtext, idx);
					if(!strlen(tmp))
					{
						SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /arrest [price] [time (minutes)] [bail (0=no 1=yes)] [bailprice]");
						return 1;
					}
					new time = strval(tmp);
					if(time < 1 || time > 20) { SendClientMessage(playerid, COLOR_GREY, "   Jail Time Minutes can't be below 1 or above 20 (Take the person to prison then) !"); return 1; }
					tmp = strtok(cmdtext, idx);
					if(!strlen(tmp))
					{
						SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /arrest [price] [time (minutes)] [bail (0=no 1=yes)] [bailprice]");
						return 1;
					}
					new bail = strval(tmp);
					if(bail < 0 || bail > 1) { SendClientMessage(playerid, COLOR_GREY, "   Jail Bailing can't be below 0 or above 1 !"); return 1; }
					tmp = strtok(cmdtext, idx);
					if(!strlen(tmp))
					{
						SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /arrest [price] [time (minutes)] [bail (0=no 1=yes)] [bailprice]");
						return 1;
					}
					new bailprice = strval(tmp);
					if(bailprice < 0 || bailprice > 3000000) { SendClientMessage(playerid, COLOR_GREY, "   Jail Bailing can't be below $0 or above $3,000,000 !"); return 1; }
					new suspect = GetClosestPlayer(playerid);
					if(IsPlayerConnected(suspect))
					{
						if(GetDistanceBetweenPlayers(playerid,suspect) < 5)
						{
						    if(IsPlayerNPC(suspect))
			   	 			{
			        			SendClientMessage(playerid, COLOR_GREY, "This command is disabled for usage against a NPC.");
			        			return 1;
							}
							GetPlayerName(suspect, giveplayer, sizeof(giveplayer));
							GetPlayerName(playerid, sendername, sizeof(sendername));
							if(WantedLevel[suspect] < 1)
							{
							    SendClientMessage(playerid, COLOR_GREY, "   Player must be at least Wanted Level 1 !");
							    return 1;
							}
							format(string, sizeof(string), "* You arrested %s !", giveplayer);
							SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
							ConsumingMoney[suspect] = 1;
							GivePlayerMoney(suspect, -moneys);
							PlayerInfo[suspect][pCash] -= moneys;
							format(string, sizeof(string), "arrested by %s ~n~    for %s", sendername, ConvertToMoney(moneys));
							GameTextForPlayer(suspect, string, 5000, 5);
							ResetPlayerWeapons(suspect);
							new price = WantedLevel[suspect] * 2000;
							format(string, sizeof(string), "~w~Running Suspect~r~~n~Captured~n~Bonus~g~%s", ConvertToMoney(price));
							GameTextForPlayer(playerid, string, 5000, 1);
							ConsumingMoney[playerid] = 1;
							GivePlayerMoney(playerid, price / 2);
							PlayerInfo[playerid][pCash] += price / 2;
							PlayerPlaySound(playerid, 1058, 0.0, 0.0, 0.0);
							PlayerXbust[suspect] = 0;
							PlayerYbust[suspect] = 0;
							PlayerZbust[suspect] = 0;
							PlayerCarbust[suspect] = 0;
							PlayerCuffed[suspect] = 0;
							TogglePlayerControllable(suspect, 1);
							if(PlayerInfo[playerid][pMember]==1||PlayerInfo[playerid][pLeader]==1)
							{
								format(string, sizeof(string), "<< Officer %s arrested suspect %s >>", sendername, giveplayer);
								OOCNews(COLOR_LIGHTRED, string);
							}
							else if(PlayerInfo[playerid][pMember]==2||PlayerInfo[playerid][pLeader]==2)
							{
								format(string, sizeof(string), "<< FBI Agent %s arrested suspect %s >>", sendername, giveplayer);
								OOCNews(COLOR_LIGHTRED, string);
							}
							else if(PlayerInfo[playerid][pMember]==3||PlayerInfo[playerid][pLeader]==3)
							{
								format(string, sizeof(string), "<< Soldier %s arrested suspect %s >>", sendername, giveplayer);
								OOCNews(COLOR_LIGHTRED, string);
							}

							if(IsAtArrestPoint(playerid)) // LSPD Jail
							{
                                new rand;
							    WantedPoints[suspect] = 0;
						        PlayerInfo[suspect][pJailed] = 1;
						        PlayerInfo[suspect][pJailTime] = time*60;
						        rand = random(sizeof(PrisonSpawns));
             	                SetPlayerPos(suspect, PrisonSpawns[rand][0], PrisonSpawns[rand][1], PrisonSpawns[rand][2]);
             	                SetPlayerColor(suspect, COLOR_PRISON);
             	                SetPlayerSkin(suspect, 50);
							}
							if(bail == 1)
							{
								JailPrice[suspect] = bailprice;
								format(string, sizeof(string), "You are jailed for %d seconds.   Bail: %s.", PlayerInfo[suspect][pJailTime], ConvertToMoney(JailPrice[suspect]));
								SendClientMessage(suspect, COLOR_LIGHTBLUE, string);
							}
							else
							{
		  	  					JailPrice[suspect] = 0;
								format(string, sizeof(string), "You are jailed for %d seconds.   Bail: Unable.", PlayerInfo[suspect][pJailTime]);
								SendClientMessage(suspect, COLOR_LIGHTBLUE, string);
							}
				        	PlayerInfo[suspect][pArrested] += 1;
							SetPlayerFree(suspect,playerid, "Got Arrested");
							WantedPoints[suspect] = 0;
							WantedLevel[suspect] = 0;
							WantLawyer[suspect] = 1;
						}
					}
					else
					{
					    SendClientMessage(playerid, COLOR_GREY, "   No-one close enough to arrest.");
					    return 1;
					}
				}
				else
				{
				    SendClientMessage(playerid, COLOR_GREY, "   You not at a arrest station !");
				    return 1;
				}
			}
		}
		return 1;
	}



Re: Serious JAIL Bug! - Toreno - 08.12.2010

Mhm... your both codes are looking good,
the /arrest has the same code as /jail

pawn Code:
PlayerInfo[suspect][pJailTime] = time*60;
I think the bug is somewhere else, maybe the timer...


Re: Serious JAIL Bug! - NotoriousMOB - 08.12.2010

Having same problem here never fixed it so intresting in knowing aswell.
but ye i think its the timer to but can't figure out whats wrong with it.


Re: Serious JAIL Bug! - ShawnMiller1337 - 08.12.2010

Code:
new unjailtimer;
Code:
	KillTimer(unjailtimer);
Code:
unjailtimer = SetTimer("SetPlayerUnjail", 1000, 1);
Timer only starts working if the player reconnects...


Re: Serious JAIL Bug! - Mehtab - 08.12.2010

edit this code

Code:
if(strcmp(cmd, "/arrest", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	   	{
			if(IsALawEnforcer(playerid))
			{
				if(OnDuty[playerid] != 1)
				{
				    SendClientMessage(playerid, COLOR_GREY, "** You are not on Duty!");
				    return 1;
				}
				if(PlayerInfo[playerid][pDBanned] == 1)
				{
			    	SendClientMessage(playerid, COLOR_GREY, "** You are Banned From Cop Duty!");
			    	return 1;
				}

				if(IsAtArrestPoint(playerid) > 0)
				{

					tmp = strtok(cmdtext, idx);
					if(!strlen(tmp))
					{
						SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /arrest [price] [time (minutes)] [bail (0=no 1=yes)] [bailprice]");
						return 1;
					}
					moneys = strval(tmp);
					if(moneys < 1 || moneys > 20000) { SendClientMessage(playerid, COLOR_GREY, "   Jail Price can't be below $1 or above $20000!"); return 1; }
					tmp = strtok(cmdtext, idx);
					if(!strlen(tmp))
					{
						SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /arrest [price] [time (minutes)] [bail (0=no 1=yes)] [bailprice]");
						return 1;
					}
					new time = strval(tmp);
					if(time < 1 || time > 5) { SendClientMessage(playerid, COLOR_GREY, "   Jail Time Minutes can't be below 1 or above 5 (Take the person to prison then)!"); return 1; }
					tmp = strtok(cmdtext, idx);
					if(!strlen(tmp))
					{
						SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /arrest [price] [time (minutes)] [bail (0=no 1=yes)] [bailprice]");
						return 1;
					}
					new bail = strval(tmp);
					if(bail < 0 || bail > 1) { SendClientMessage(playerid, COLOR_GREY, "   Jail Bailing can't be below 0 or above 1!"); return 1; }
					tmp = strtok(cmdtext, idx);
					if(!strlen(tmp))
					{
						SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /arrest [price] [time (minutes)] [bail (0=no 1=yes)] [bailprice]");
						return 1;
					}
					new bailprice = strval(tmp);
					if(bailprice < 0 || bailprice > 2000000) { SendClientMessage(playerid, COLOR_GREY, "** Jail Bailing can't be below $0 or above $2000000!"); return 1; }
					new suspect = GetClosestPlayer(playerid);
					if(IsPlayerConnected(suspect))
					{
						if(GetDistanceBetweenPlayers(playerid,suspect) < 5)
						{
							GetPlayerName(suspect, giveplayer, sizeof(giveplayer));

							if(WantedLevel[suspect] < 1)
							{
						    	SendClientMessage(playerid, COLOR_GREY, "** Player must be at least Wanted Level 1!");
						    	return 1;
							}
							format(string, sizeof(string), "* You arrested %s!", giveplayer);
							SendClientMessage(playerid, COLOR_WHITE, string);
							SafeGivePlayerMoney(suspect, -moneys);
							format(string, sizeof(string), "arrested by %s ~n~    for $%d", sendername, moneys);
							GameTextForPlayer(suspect, string, 5000, 5);
							SafeResetPlayerWeapons(suspect);
						PlayerInfo[suspect][pJailed] = 1;
				     	   	PlayerInfo[suspect][pArrested] += 1;
							SetPlayerFree(suspect,playerid, "Got Arrested");
							TextDrawShowForPlayer(suspect, Textdraw1[suspect]);
							WantedPoints[suspect] = 0;
							WantedLevel[suspect] = 0;
							WantLawyer[suspect] = 1;
							PlayerCuffed[suspect] = 0;
							GaveUp[suspect] = 0;
							new y, m, d;
							new h,mi,s;
							getdate(y,m,d);
							gettime(h,mi,s);
							format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s Has Arrested %s for %s Seconds. Bail: $%d, Price: $%d",d,m,y,h,mi,s,sendername,giveplayer, PlayerInfo[suspect][pJailTime],JailPrice[suspect],moneys);
							JailLog(string);
							KillTimer(cufftimer[suspect]);
						}//distance
					}//not connected
				}
			}
			else
			{
			    SendClientMessage(playerid, COLOR_GREY, "** You are not COP!");
			    return 1;
			}
		}//not connected
		return 1;
	}



Re: Serious JAIL Bug! - Toreno - 08.12.2010

First, check Mehtab's code... If it's not working, then tell me if you have that kind of code on your /time command.
pawn Code:
if(strcmp(cmd, "/time", true) == 0)
{
    if(IsPlayerConnected(playerid))
    {
        if(PlayerInfo[playerid][pWatch] == 0) return SendClientMessage(playerid,COLOR_GREY,"  You don`t have a watch you can buy one in the 24/7");
        new mtext[20];
        new year, month,day;
        getdate(year, month, day);
        if(month == 1) { mtext = "January"; }
        else if(month == 2) { mtext = "February"; }
        else if(month == 3) { mtext = "March"; }
        else if(month == 4) { mtext = "April"; }
        else if(month == 5) { mtext = "May"; }
        else if(month == 6) { mtext = "June"; }
        else if(month == 7) { mtext = "Juli"; }
        else if(month == 8) { mtext = "August"; }
        else if(month == 9) { mtext = "September"; }
        else if(month == 10) { mtext = "October"; }
        else if(month == 11) { mtext = "November"; }
        else if(month == 12) { mtext = "December"; }
        new hour,minuite,second;
        gettime(hour,minuite,second);
        FixHour(hour);
        hour = shifthour;
        if (minuite < 10)
        {
            if (PlayerInfo[playerid][pJailTime] > 0)
            {
                format(string, sizeof(string), "~y~%d %s~n~~g~|~w~%d:0%d~g~|~n~~w~Jail Time Left: %d sec", day, mtext, hour, minuite, PlayerInfo[playerid][pJailTime]-10);
            }
            else
            {
                format(string, sizeof(string), "~y~%d %s~n~~g~|~w~%d:0%d~g~|", day, mtext, hour, minuite);
            }
        }
        else
        {
            if (PlayerInfo[playerid][pJailTime] > 0)
            {
                format(string, sizeof(string), "~y~%d %s~n~~g~|~w~%d:%d~g~|~n~~w~Jail Time Left: %d sec", day, mtext, hour, minuite, PlayerInfo[playerid][pJailTime]-10);
            }
            else
            {
                format(string, sizeof(string), "~y~%d %s~n~~g~|~w~%d:%d~g~|", day, mtext, hour, minuite);
            }
        }
        GameTextForPlayer(playerid, string, 5000, 1);
        GetPlayerName(playerid, sendername, sizeof(sendername));
        format(string, sizeof(string), "* %s raises up his hand and looks at his clock.", sendername);
        ProxDetector(10.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
        if(!IsPlayerInAnyVehicle(playerid))
        {
            ApplyAnimation(playerid,"COP_AMBIENT","Coplook_watch",4.1,0,0,0,0,0);
        }
    }
    return 1;
}
Just compare between both codes, because this one works fine to me... and ignore the pWatch part...
Just compare between both them and try to fix yours, hope it helps


Re: Serious JAIL Bug! - ShawnMiller1337 - 08.12.2010

Code:
	if(strcmp(cmd, "/time", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
		{
		    new mtext[20];
			if(month == 1) { mtext = "January"; }
			else if(month == 2) { mtext = "February"; }
			else if(month == 3) { mtext = "March"; }
			else if(month == 4) { mtext = "April"; }
			else if(month == 5) { mtext = "May"; }
			else if(month == 6) { mtext = "June"; }
			else if(month == 7) { mtext = "July"; }
			else if(month == 8) { mtext = "August"; }
			else if(month == 9) { mtext = "September"; }
			else if(month == 10) { mtext = "October"; }
			else if(month == 11) { mtext = "November"; }
			else if(month == 12) { mtext = "December"; }
		    new hour,minuite,second;
			gettime(hour,minuite,second);
			if (minuite < 10)
			{
				if (PlayerInfo[playerid][pJailTime] > 0)
				{
					format(string, sizeof(string), "~y~%d %s~n~~g~|~w~%d:0%d~g~|~n~~w~Jail Time Left: %d sec", day, mtext, hour, minuite, PlayerInfo[playerid][pJailTime]-10);
				}
				else
				{
					format(string, sizeof(string), "~y~%d %s~n~~g~|~w~%d:0%d~g~|", day, mtext, hour, minuite);
				}
			}
			else
			{
				if (PlayerInfo[playerid][pJailTime] > 0)
				{
					format(string, sizeof(string), "~y~%d %s~n~~g~|~w~%d:%d~g~|~n~~w~Jail Time Left: %d sec", day, mtext, hour, minuite, PlayerInfo[playerid][pJailTime]-10);
				}
				else
				{
					format(string, sizeof(string), "~y~%d %s~n~~g~|~w~%d:%d~g~|", day, mtext, hour, minuite);
				}
			}
			GameTextForPlayer(playerid, string, 5000, 1);
		}
		return 1;
	}
That is my /time code
also I check his code , Looks the same just a differant format..

Still same error occurs.... Officer sends the suspect to prison for 1 min... suspect does /time right when he gets in prison it says " Jail Time Left : 50 seconds " And it stays like that.. I have no idea what is causing this problem... , But if the suspect relogs while in jail , once it says "Incomplete Jail Sentenced , Returned to jail " The timer starts working and the time goes down until the suspect is free from jail


Re: Serious JAIL Bug! - Voldemort - 08.12.2010

I bet that you have putted return 1; in some global timer, I guess it was OtherTimer() or SetPlayerFree, uhh, it was long time ago when I did something with GFs


Re: Serious JAIL Bug! - Toreno - 08.12.2010

Quote:
Originally Posted by ShawnMiller1337
View Post
Code:
	if(strcmp(cmd, "/time", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
		{
		    new mtext[20];
			if(month == 1) { mtext = "January"; }
			else if(month == 2) { mtext = "February"; }
			else if(month == 3) { mtext = "March"; }
			else if(month == 4) { mtext = "April"; }
			else if(month == 5) { mtext = "May"; }
			else if(month == 6) { mtext = "June"; }
			else if(month == 7) { mtext = "July"; }
			else if(month == 8) { mtext = "August"; }
			else if(month == 9) { mtext = "September"; }
			else if(month == 10) { mtext = "October"; }
			else if(month == 11) { mtext = "November"; }
			else if(month == 12) { mtext = "December"; }
		    new hour,minuite,second;
			gettime(hour,minuite,second);
			if (minuite < 10)
			{
				if (PlayerInfo[playerid][pJailTime] > 0)
				{
					format(string, sizeof(string), "~y~%d %s~n~~g~|~w~%d:0%d~g~|~n~~w~Jail Time Left: %d sec", day, mtext, hour, minuite, PlayerInfo[playerid][pJailTime]-10);
				}
				else
				{
					format(string, sizeof(string), "~y~%d %s~n~~g~|~w~%d:0%d~g~|", day, mtext, hour, minuite);
				}
			}
			else
			{
				if (PlayerInfo[playerid][pJailTime] > 0)
				{
					format(string, sizeof(string), "~y~%d %s~n~~g~|~w~%d:%d~g~|~n~~w~Jail Time Left: %d sec", day, mtext, hour, minuite, PlayerInfo[playerid][pJailTime]-10);
				}
				else
				{
					format(string, sizeof(string), "~y~%d %s~n~~g~|~w~%d:%d~g~|", day, mtext, hour, minuite);
				}
			}
			GameTextForPlayer(playerid, string, 5000, 1);
		}
		return 1;
	}
That is my /time code
also I check his code , Looks the same just a differant format..

Still same error occurs.... Officer sends the suspect to prison for 1 min... suspect does /time right when he gets in prison it says " Jail Time Left : 50 seconds " And it stays like that.. I have no idea what is causing this problem... , But if the suspect relogs while in jail , once it says "Incomplete Jail Sentenced , Returned to jail " The timer starts working and the time goes down until the suspect is free from jail
It means that good... what's the problem? when you arressting the susepct and he does /time, it should show how much time he has until he gets out... and if he log off and log in back it says "Incomplete..." then he can see his time... that's how it needs to be, i don't know other way..


Re: Serious JAIL Bug! - ShawnMiller1337 - 08.12.2010

The timer dosn't work unless he relogs.... If the officer jails him for 1 minute... and right when he is sent to jail he does /time it says " Jail time Left : 50 Seconds " It stays like that and dosn't go down... Just stays at 50 seconds....


Re: Serious JAIL Bug! - NotoriousMOB - 08.12.2010

When a officer jails the guy he can do /time and it should show him how much jailtime he has left and then drop down til 0 til his released. The problem here is that when the officer jails him and he does /time the timer will freeze on a special number witch means he needs to relog to get the timer to start working again and he can get released.


Re: Serious JAIL Bug! - john501 - 10.12.2010

Quote:
Originally Posted by NotoriousMOB
View Post
When a officer jails the guy he can do /time and it should show him how much jailtime he has left and then drop down til 0 til his released. The problem here is that when the officer jails him and he does /time the timer will freeze on a special number witch means he needs to relog to get the timer to start working again and he can get released.
thats weird


Re: Serious JAIL Bug! - ShawnMiller1337 - 06.04.2011

Quote:
Originally Posted by NotoriousMOB
View Post
When a officer jails the guy he can do /time and it should show him how much jailtime he has left and then drop down til 0 til his released. The problem here is that when the officer jails him and he does /time the timer will freeze on a special number witch means he needs to relog to get the timer to start working again and he can get released.
Exactly still havent fixed this bug yet