SA-MP Forums Archive
Why does my /jail command not fix the person's interior after their time is up? - 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: Why does my /jail command not fix the person's interior after their time is up? (/showthread.php?tid=499621)



Why does my /jail command not fix the person's interior after their time is up? - K9IsGodly - 09.03.2014

So here is my code:

Код:
	if(strcmp(cmd, "/jail", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_WHITE, "USAGE: /jail [playerid/PartOfName] [minutes] [reason]");
				return 1;
			}
			new playa;
			new time;
			playa = ReturnUser(tmp);
			tmp = strtok(cmdtext, idx);
			time = strvalEx(tmp);
			if(PlayerInfo[playerid][pAdmin] >= 2)
			{
			    if(IsPlayerConnected(playa))
			    {
			        if(playa != INVALID_PLAYER_ID)
			        {
				        GetPlayerName(playa, giveplayer, sizeof(giveplayer));
						GetPlayerName(playerid, sendername, sizeof(sendername));
						new length = strlen(cmdtext);
						while ((idx < length) && (cmdtext[idx] <= ' '))
						{
							idx++;
						}
						new offset = idx;
						new result[64];
						while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
						{
							result[idx - offset] = cmdtext[idx];
							idx++;
						}
						result[idx - offset] = EOS;
						if(!strlen(result))
						{
							SendClientMessage(playerid, COLOR_WHITE, "USAGE: /jail [playerid/PartOfName] [minutes] [reason]");
							return 1;
						}
						format(string, sizeof(string), "{AA3333}AdmCmd{FFFF00}: %s has been jailed by an Admin, reason: %s", giveplayer, (result));
                		SendClientMessageToAll(COLOR_LIGHTRED, string);
                		ClearGuns(playa);
						ResetPlayerWeapons(playa);
						PlayerInfo[playa][pWantedLevel] = 0;
						SetPlayerWantedLevel(playa, 0);
						SetPlayerToTeamColor(playa);
						PlayerInfo[playa][pJailed] = 1;
						PlayerInfo[playa][pJailTime] = time*60;
						SetPlayerInterior(playa, 6);
						SetPlayerVirtualWorld(playerid, 0);
						PlayerInfo[giveplayerid][pVirtualWorld] = 0;
						SetPlayerPos(playa, 264.6288,77.5742,1001.0391);
						SetPlayerFacingAngle(playa, -90);
						format(string, sizeof(string), "You are jailed for %d minutes.   Bail: Unable", time);
						SendClientMessage(playa, COLOR_LIGHTBLUE, string);
					}
				}
			}
			else
			{
				SendClientMessage(playerid, COLOR_GRAD1, "You are not authorized to use that command!");
			}
		}
		return 1;
	}
I also have this little bit of code, which allows for the player to be set into the jail, or something along those lines.

Код:
		if(PlayerInfo[playerid][pJailed] == 1)
		{
            HideArea(playerid);
		    SetPlayerInterior(playerid, 6);
			SetPlayerPos(playerid,264.6288,77.5742,1001.0391);
			SetCameraBehindPlayer(playerid);
			SetPlayerFacingAngle( playerid, -90);
			SetPlayerToTeamColor(playerid);
			CanTalk[playerid] = 1;
			return 1;
		}
Basically, my issue is when you put someone in jail, for any increment of time, when they get released their interior is bugged. The jail's interior is 6, and when they get taken out of jail because their time is up, the interior must stay at 6 because it bugs the player. Why is this?


Re: Why does my /jail command not fix the person's interior after their time is up? - iThePunisher - 09.03.2014

that happens because you do not have release.
you should add this
pawn Код:
@Release(playerid);
@Release(playerid)
{
    new string[120];
    new TimeX = GetPVarInt(playerid, "JailTime");
    if(!IsPlayerConnected(playerid))
        return 0;

    if(TimeX < 1)
    {
      SetPVarInt(playerid, "Jailed", 0);
      SetPlayerInterior(playerid, 6);
      SetPlayerPos(playerid, 246.5301,86.7577,1003.6406);
      SetPlayerFacingAngle(playerid, 176.7961);
      SetPlayerHealth(playerid,100);
      format(string,sizeof(string),"%s(%d) is free from the jail now. go party biatch :PPP  %d",PlayerInfo(playerid),playerid,GetPVarInt(playerid, "JailTime"),playerid);
      SendClientMessageToAll(COLOR_ORANGE,string);
      return 1;
    }

    new str[30];
    format(str, sizeof(str), "You will be free from this damn jail in: %d", TimeX);
    GameTextForPlayer(playerid, str, 2500, 3);

    SetPVarInt(playerid, "JailTime", TimeX - 1);
    SetTimerEx("@Release", 1000, false, "i", playerid);
    return 1;
}
and add
pawn Код:
@Release(targetid);
at jail command


Re: Why does my /jail command not fix the person's interior after their time is up? - K9IsGodly - 09.03.2014

I didn't even know @Release was something that existed, unless I'm just seeming stupid here. I don't know.


Re: Why does my /jail command not fix the person's interior after their time is up? - K9IsGodly - 09.03.2014

I'm kind of confused on the user's response above, can someone clarify a bit on it?


Re: Why does my /jail command not fix the person's interior after their time is up? - Scones - 09.03.2014

Here's the unjail shit, i dont see why it wont work either

http://pastebin.com/uUTT6VDA


Re: Why does my /jail command not fix the person's interior after their time is up? - Abagail - 09.03.2014

Maybe try setting their VW to 0, too... Just a thought, though.


Re: Why does my /jail command not fix the person's interior after their time is up? - K9IsGodly - 09.03.2014

Quote:
Originally Posted by Abagail
Посмотреть сообщение
Maybe try setting their VW to 0, too... Just a thought, though.
I just tried this on the SetPlayerUnjail bit. I think it might work, guess we'll see.