SA-MP Forums Archive
Jail Time - 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 Time (/showthread.php?tid=481389)



Jail Time - AnonScripter - 15.12.2013

hey all, i made a script for Jail Command:
(/jail [playerid] [time in minutes] [reason])

it works great, but how to make a TextDraw shows for the player how much time remaining till he get released from jail


Re: Jail Time - Dawno - 15.12.2013

Код:
	format(string, sizeof(string), "You are jailed for %d minutes.   Bail: Unable", minutes);



Re: Jail Time - AnonScripter - 15.12.2013

Quote:
Originally Posted by Dawno
Посмотреть сообщение
Код:
	format(string, sizeof(string), "You are jailed for %d minutes.   Bail: Unable", minutes);
this is shit man -_-
i want a timer textdraw, u gave me something that any beginner scripter can script it.


Re: Jail Time - SilentSoul - 15.12.2013

You need to show us your timer that will jail the player or release him , also if you want to use it as textdraw you should store the time on timer and use TextDrawSetString , i suggest you to use GameTextForPlayer instead of the textdraw!


Re: Jail Time - Jankingston - 15.12.2013

Use : "GameTextForPlayer(playerid, "~w~You are jailed for %s seconds", minutes);"

If you have a timing enum, then you can use this "minutes"


Re: Jail Time - erminpr0 - 15.12.2013

Create textdraw using iPLEOMAX / Zamaroth TD editor, or whatever else.
Assing textdraw to some id so you can use it later in some parts.

Ex.
pawn Код:
new Text: timeLeft;

timeLeft = TextDrawCreate(299.5 ,400 , " ");
TextDrawFont(timeLeft , 1);
TextDrawLetterSize(timeLeft , 1, 7);
TextDrawColor(timeLeft , 0xed37b3FF);
TextDrawSetOutline(timeLeft , false);
TextDrawSetProportional(timeLeft , true);
TextDrawSetShadow(timeLeft , 0);


forward UpdateJailText()
public UpdateJailText()
{
   foreach(Player, i)
   {
      if(GetPVarInt(i, "Jailed") >= 1)
      {
         new string[32];
         format(string, sizeof string, "Time left in jail: %d minutes!", GetPVarInt(i, "Jailed"));
         TextDrawSetString(timeLeft, string);
         TextDrawShowForPlayer(playerid, timeLeft);
      }
      if(GetPVarInt(i, "Jailed") == 0)
      {
         TextDrawHideForPlayer(playerid, timeLeft);
      }
    }
}

// at the top
new timlf_tm;
// on game mode init
timlf_tm = SetTimer(UpdateJailText, 5000, true);
// gmx
KillTimer(timlf_tm);



Re: Jail Time - AnonScripter - 15.12.2013

thanks all and here is my jail command.

pawn Код:
CMD:jail(playerid,params[])
{
    new targetid,reason[50],string[128],minutes;
    if(!IsPlayerAdmin(playerid)) return 0;
    if(sscanf(params, "uds[50]", targetid, minutes, reason))return SendClientMessage(playerid, COLOR_WHITE, "/jail [playerid/name] [time in minutes] [reason]");
    if(!IsPlayerConnected(targetid))return SendClientMessage(playerid, COLOR_WHITE, "Error: This player is not connected.");
    if(Spawned[targetid] == 0) return SendClientMessage(playerid,COLOR_WHITE,"Error: This Player Is Not Spawned.");
    if(PlayerInfo[targetid][pJailed] == 1) return SendClientMessage(playerid,COLOR_WHITE,"Error: This player is already in jail.");
    else
    {
        new calc = minutes*60;
        PlayerInfo[targetid][pJailTime] = calc;
        PlayerInfo[targetid][pAdminJailed] = 1;
        ResetPlayerWeapons(targetid);
        SetPlayerScore(targetid,GetPlayerScore(targetid)-1);
        GameTextForPlayer(targetid,"~r~JAILED!",7000,4);
        PutPlayerInJail(targetid);
        format(string, sizeof(string), "%s(%d) has been Jailed by an Administrator - Reason: %s", GetName(targetid), targetid, reason);
        SendClientMessageToAll(COLOR_WHITE,string);
        Releaser[targetid] = SetTimerEx("JailTime",calc*1000, false, "i", targetid);
    }
    return 1;
}



Re: Jail Time - SilentSoul - 15.12.2013

Post your unjail timer please i mean this 'JailTime' btw if you will understand me
pawn Код:
public JailTime(playerid)//just add this codes in your unjail timeri mean when the player get unjailed
{
     new timer[20];
     Releaser[playerid]--;
     if(Releaser[playerid] > 0)
     {
     format(timer,sizeof(timer),"~r~Jailed: %d",Releaser[playerid]);
     GameTextForPlayer(playerid,time,500,3);
     }
     return 1;
}



Re: Jail Time - AnonScripter - 15.12.2013

@erminpr0 thanks this is worked, but i want it as a timer like (Time Left: 1:30)
and keep decreasing until the player get released from jail.