SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 13/06/2013, 06:45 PM   #1
Isolated
Gangsta
 
Isolated's Avatar
 
Join Date: Mar 2013
Location: United Kingdom
Posts: 802
Reputation: 155
Default Jail command.

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 Code:
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 Code:
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.
Isolated is offline   Reply With Quote
Old 13/06/2013, 08:03 PM   #2
LilBob
Big Clucker
 
Join Date: Mar 2013
Posts: 123
Reputation: 1
Default Re: Jail command.

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

pawn Code:
if(PlayerInfo[playerid][pJailed] == 1)
        {
            SendPlayerToJail(playerid,1);
                    return 1;
        }
LilBob is offline   Reply With Quote
Old 13/06/2013, 08:12 PM   #3
Isolated
Gangsta
 
Isolated's Avatar
 
Join Date: Mar 2013
Location: United Kingdom
Posts: 802
Reputation: 155
Default Re: Jail command.

Can you re-phrase that please?
Isolated is offline   Reply With Quote
Old 13/06/2013, 08:17 PM   #4
Juanxz
Big Clucker
 
Join Date: Jan 2010
Posts: 121
Reputation: 1
Default Re: Jail command.

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.
Juanxz is offline   Reply With Quote
Old 13/06/2013, 08:18 PM   #5
LilBob
Big Clucker
 
Join Date: Mar 2013
Posts: 123
Reputation: 1
Default Re: Jail command.

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).
LilBob is offline   Reply With Quote
Old 13/06/2013, 08:32 PM   #6
Isolated
Gangsta
 
Isolated's Avatar
 
Join Date: Mar 2013
Location: United Kingdom
Posts: 802
Reputation: 155
Default Re: Jail command.

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.
Isolated is offline   Reply With Quote
Old 13/06/2013, 08:42 PM   #7
LilBob
Big Clucker
 
Join Date: Mar 2013
Posts: 123
Reputation: 1
Default Re: Jail command.

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

pawn Code:
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
LilBob is offline   Reply With Quote
Old 13/06/2013, 09:38 PM   #8
Isolated
Gangsta
 
Isolated's Avatar
 
Join Date: Mar 2013
Location: United Kingdom
Posts: 802
Reputation: 155
Default Re: Jail command.

how do you update that ?
Isolated is offline   Reply With Quote
Old 14/06/2013, 12:33 PM   #9
Isolated
Gangsta
 
Isolated's Avatar
 
Join Date: Mar 2013
Location: United Kingdom
Posts: 802
Reputation: 155
Default Re: Jail command.

bump
Isolated is offline   Reply With Quote
Old 15/06/2013, 07:22 PM   #10
Isolated
Gangsta
 
Isolated's Avatar
 
Join Date: Mar 2013
Location: United Kingdom
Posts: 802
Reputation: 155
Default Re: Jail command.

bump
Isolated is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Please help me with this jail command zack3021 Help Archive 3 09/09/2010 01:16 AM
/jail command help :-/ DarkPower Help Archive 4 29/08/2010 12:45 PM
I need a jail command! Dwsss Help Archive 5 01/01/2010 01:43 PM
[FilterScript] [FS] Jail area and Jail command PinkFloydLover Filterscripts 13 05/08/2009 07:11 AM
help /jail command Rikmer Help Archive 2 04/08/2009 06:20 PM


All times are GMT. The time now is 08:13 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.