JailTime Dosent Apper On String
#1

Hello guys i made a jail system
and i noticed after i get unjailed it shows a message [PG]DarkLored Has been released from Los Santos Police Station after 0 seconds
it dosent read the jail time that i was for for exsample if i get jailed for 25 seconds it still shows unjailed after 0 seconds

here is my code
pawn Код:
@Release(playerid);
@Release(playerid)
{
    new string[120];
    new Time = GetPVarInt(playerid, "JailTime");
    if(!IsPlayerConnected(playerid))
        return 0;

    if(Time < 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) Has been realesed from Los Santos Jail after %d seconds",GetName(playerid),playerid,Time);
      SendClientMessageToAll(COLOR_ORANGE,string);
      return 1;
    }

    new str[30];
    format(str, sizeof(str), "You will be released in: %d", Time);
    GameTextForPlayer(playerid, str, 2500, 3); // Change it if you want

    SetPVarInt(playerid, "JailTime", Time - 1); // Decrease the player's jail time
    SetTimerEx("@Release", 1000, false, "i", playerid);
    return 1;
}
Reply
#2

Any help?
Reply
#3

It's because the JailTime now = 0 so when you add it to the string it will say 0 Seconds.
Reply
#4

You can tell me how to make it read the time then cause i dont have any idea
Reply
#5

Any help guys ?
Reply
#6

Maybe at the moment you jail the player:
SetPVarInt(playerid, "JailTime", [YourTimeValueHere]);

Or DID you set the Player Variable and doesn't it read it correctly?

Edit:
I didn't saw it directly that you where also doing the countdown in the same variable that you wanted
to read out, so follow the suggestion of -Prodigy- please.

BTW, Please read the 24h bumping rules
'bumping a topic in which you have or require further information is allowed after at least 24 hours. '
Reply
#7

pawn Код:
// at the top:
new gJailTime[MAX_PLAYERS] = {-1, ...};

// OnPlayerConnect
gJailTime[playerid] = 0;

// OnPlayerDisconnect
gJailTime[playerid] = 0;

// When you jail the player:
gJailTime[playerid] = jail_time_var;
Then replace this line:
pawn Код:
format(string,sizeof(string),"%s(%d) Has been realesed from Los Santos Jail after %d seconds",GetName(playerid),playerid,gJailTime[playerid]);
Reply
#8

Edit:
Okay just do what -Prodigy- typed,
that was also what i was trying to state
only i messed up because I had to edit my post a couple of times due to a
bad Internet connection at the time here.
Reply
#9

Quote:
Originally Posted by -Prodigy-
Посмотреть сообщение
pawn Код:
// at the top:
new gJailTime[MAX_PLAYERS] = {-1, ...};

// OnPlayerConnect
gJailTime[playerid] = 0;

// OnPlayerDisconnect
gJailTime[playerid] = 0;

// When you jail the player:
gJailTime[playerid] = jail_time_var;
Then replace this line:
pawn Код:
format(string,sizeof(string),"%s(%d) Has been realesed from Los Santos Jail after %d seconds",GetName(playerid),playerid,gJailTime[playerid]);
Wait so i will need to change my Jail Time varialbe to this or i can keep them both

Can i get a simple way
Reply
#10

Quote:
Originally Posted by DarkLored
Посмотреть сообщение
Wait so i will need to change my Jail Time varialbe to this or i can keep them both

Can i get a simple way
This is the simple way

You just need to make sure your script 'remembers' the first jail time, and that is
what you are doing by adding this part (do not remove parts of your own but add these parts)

Because what you where doing before was reading a variable that was counting down to zero,
so if you would read it AFTER the countdown then offcourse it would say zero
Maybe you will see the problem after reading your own code again.

This way you will store the original time for what the player is jailed for

Only line to change would be then:
pawn Код:
format(string,sizeof(string),"%s(%d) Has been realesed from Los Santos Jail after %d seconds",GetName(playerid),playerid,gJailTime[playerid]);
The others you just need to add at the locations given by -Prodigy-
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)