Jail command.
#1

Hey,

I was wondering, I've created a small jail system, and was wondering how I would record players spent minutes/seconds.

Below is the code of the system so far.

pawn Код:
public SendPlayerToJail(playerid, minutes, seconds)
{
    if(IsJailed[playerid]) return 0;
    else
    {
        new rand = random(3);
        SetPlayerInterior(playerid, 6);
        switch(rand)
        {
            case 0: SetPlayerPos(playerid, 262.9825,77.4500,1001.0391);
            case 1: SetPlayerPos(playerid, 193.6294,161.8236,1003.2417);
            case 2: SetPlayerPos(playerid, 190.8504,161.0375,1003.2417);
        }
        GameTextForPlayer(playerid, "~r~JAILED", 3000, 6);
        SetTimerEx("JailTimer", Minute(minutes) + Second(seconds), false, "d", playerid);
        new String[70];
        format(String, sizeof(String), "%s (ID: %d) has been jailed.", ReturnPlayerName(playerid), playerid);
        SendClientMessageToAll(COLOR_YELLOW, String);
    }
    return 1;
}
pawn Код:
public JailTimer(playerid)
{
    GameTextForPlayer(playerid, "~g~FREEDOM", 3000, 6);
    SpawnPlayer(playerid);
    new String[70];
    format(String, sizeof(String), "%s (ID: %d) has been released from jail.", ReturnPlayerName(playerid), playerid);
    SendClientMessageToAll(COLOR_YELLOW, String);
    return 1;
}
But, however if a player quits then reconnects they'd be free again.

Thanks,

-Mike.
Reply
#2

Where is your player variable ? Like [pJailed] ?
After you should put on the public Setplayerspawn

pawn Код:
if(PlayerInfo[playerid][pJailed] == 1)
        {
            SendPlayerToJail(playerid,1);
                    return 1;
        }
Reply
#3

Can you re-phrase that please?
Reply
#4

I think he means that it will be set on a save file that the person if jailed...so on spawn if the server sees that that person is supposed to be in jail, he will be sent straight to jail.
Reply
#5

Put in pInfo: pJailed.

In your code add PlayerInfo[playerid][pJailed]=1;

After for fixing your bug while reconnect on server, put my code in SetplayerSpawn (the public).
Reply
#6

It's not a bug. I'm looking for an answer so if the player logs out then reconnects, instead of being jailed for an infinate time, he will have minutes and seconds, which were the minutes and seconds that he disconnected with. Instead of reseting the clock.
Reply
#7

I wrote that code in my gm (i have also a pJailTime in pInfo)

pawn Код:
if(PlayerInfo[playerid][pJailTime] > 0 && PlayerInfo[playerid][pJailed] != 0)
    {
        PlayerInfo[playerid][pJailTime]-=2;
        if(PlayerInfo[playerid][pJailTime] <= 0)
            {unjail_player(playerid);}
    }
Maybe could this help you
Reply
#8

how do you update that ?
Reply
#9

bump
Reply
#10

bump
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)