[HELP] /jail command
#5

Quote:
Originally Posted by Kingunit
Посмотреть сообщение
Are you saving the time already? Make it something like this.
pawn Код:
if(PlayerInfo[playerid][Jail] == 1)
{
    SetTimer("unjail", PlayerInfo[playerid][Time], false);
}

forward unjail();
public unjail()
{
    // Unjail function
    SendClientMessage(playerid, 0xFFFFFFFF, "Unjailed!");
}
This is what I've done:

pawn Код:
forward SetPlayerUnjail();

new unjailtimer;

unjailtimer = SetTimer("SetPlayerUnjail", 1000, 1);

if(strcmp(cmd, "/jail", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(gTeam[playerid] == 5 || gTeam[playerid] == 6)
            {
                if(!PlayerToPoint(6.0, playerid, 1529.3108,-1677.7783,5.8906))
                {
                    SendClientMessage(playerid, COLOR_GREY, "   You are not near the Jail, can't Arrest !");
                    return 1;
                }
                tmp = strtok(cmdtext, idx);
                if(!strlen(tmp))
                {
                    SendClientMessage(playerid, COLOR_GREY, "   USAGE: /jail [playerid/PartOfName] [fine] [time]");
                    return 1;
                }
                giveplayerid = ReturnUser(tmp);
                tmp = strtok(cmdtext, idx);
                if(!strlen(tmp))
                {
                    SendClientMessage(playerid, COLOR_GREY, "   USAGE: /jail [playerid/PartOfName] [fine] [time]");
                    return 1;
                }
                moneys = strval(tmp);
                tmp = strtok(cmdtext, idx);
                if(!strlen(tmp))
                {
                    SendClientMessage(playerid, COLOR_GREY, "   USAGE: /jail [playerid/PartOfName] [fine] [time]");
                    return 1;
                }
                new time = strval(tmp);
                tmp = strtok(cmdtext, idx);
                if(IsPlayerConnected(giveplayerid))
                {
                    if(GetDistanceBetweenPlayers(playerid, giveplayerid) < 5)
                    {
                        GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                        GetPlayerName(playerid, sendername, sizeof(sendername));
                        format(string, sizeof(string), "* You arrested %s !", giveplayer);
                        SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
                        GivePlayerMoney(giveplayerid, -moneys);
                        format(string, sizeof(string), "~r~Fine: $%d", moneys);
                        GameTextForPlayer(giveplayerid, string, 5000, 5);
                        SetPlayerInterior(giveplayerid, 6);
                        SetPlayerPos(giveplayerid,264.6288,77.5742,1001.0391);
                        PlayerInfo[giveplayerid][pJailTime] = time * 60;
                        PlayerInfo[giveplayerid][pJailed] = 1;
                        return 1;
                    }
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "   That player is too far away.");
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "   You are not authorized to use that command.");
            }
        }
        return 1;
    }

public SetPlayerUnjail()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(PlayerInfo[i][pJailed] > 0)
            {
                PlayerInfo[i][pJailTime] = 0;
                if(PlayerInfo[i][pJailed] == 1)
                {
                    SetPlayerInterior(i, 6);
                    SetPlayerPos(i,268.0903,77.6489,1001.0391);
                }
                else if(PlayerInfo[i][pJailed] == 2)
                {
                    SetPlayerWorldBounds(i, 20000.0000,-20000.0000,20000.0000,-20000.0000);
                    SetPlayerInterior(i, 0);
                    SetPlayerPos(i, 90.2101,1920.4854,17.9422);
                }
                PlayerInfo[i][pJailed] = 0;
            }
        }
    }
}
The only problem is that if I type for example /jail 0 1000 1 I get jailed for only 1 second, it doesn't mattar what time I put in there it just keeps relesing me after 1 second.
Reply


Messages In This Thread
[HELP] /jail command - by ChaosLad - 30.09.2011, 16:14
Re: [HELP] /jail command - by Dokins - 30.09.2011, 16:17
Re: [HELP] /jail command - by ChaosLad - 30.09.2011, 16:22
Re: [HELP] /jail command - by Kingunit - 30.09.2011, 16:30
Re: [HELP] /jail command - by ChaosLad - 30.09.2011, 16:51
Re: [HELP] /jail command - by Kingunit - 30.09.2011, 17:42
Re: [HELP] /jail command - by ChaosLad - 30.09.2011, 17:56
Re: [HELP] /jail command - by Kingunit - 30.09.2011, 18:26
Re: [HELP] /jail command - by ChaosLad - 30.09.2011, 18:27
Re: [HELP] /jail command - by ChaosLad - 30.09.2011, 20:20

Forum Jump:


Users browsing this thread: 1 Guest(s)