/arrest function not working properly
#1

Ok, so the problem lays within the fact that when an officer arrests a suspect and that suspect is sent to jail, the time that they was arrested for is not properly set and it won't unjail them right either. Let'sa say I jailed a guy for two minutes. The guys can stand in jail and keep doing /time, the /time shows some time but its not accurate. Along with the fact that after two minutes the player is still in jail. Please help. Here is my code:


pawn Код:
public SetPlayerUnjail()
{
    new string[256];
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            new newcar = GetPlayerVehicleID(i);
            new level = PlayerInfo[i][pLevel];
            if(level >= 0 && level <= 2) { PlayerInfo[i][pPayCheck] += 1; }
            else if(level >= 3 && level <= 4) { PlayerInfo[i][pPayCheck] += 2; }
            else if(level >= 5 && level <= 6) { PlayerInfo[i][pPayCheck] += 3; }
            else if(level >= 7 && level <= 8) { PlayerInfo[i][pPayCheck] += 4; }
            else if(level >= 9 && level <= 10) { PlayerInfo[i][pPayCheck] += 5; }
            else if(level >= 11 && level <= 12) { PlayerInfo[i][pPayCheck] += 6; }
            else if(level >= 13 && level <= 14) { PlayerInfo[i][pPayCheck] += 7; }
            else if(level >= 15 && level <= 16) { PlayerInfo[i][pPayCheck] += 8; }
            else if(level >= 17 && level <= 18) { PlayerInfo[i][pPayCheck] += 9; }
            else if(level >= 19 && level <= 20) { PlayerInfo[i][pPayCheck] += 10; }
            else if(level >= 21) { PlayerInfo[i][pPayCheck] += 11; }
            if(PlayerInfo[i][pJailed] > 0)
            {
                if(PlayerInfo[i][pJailTime] > 0 && WantLawyer[i] == 0)
                {
                    PlayerInfo[i][pJailTime]--;
                }
                if(PlayerInfo[i][pJailTime] <= 0 && WantLawyer[i] == 0)
                {
                    PlayerInfo[i][pJailTime] = 0;
                    if(PlayerInfo[i][pJailed] == 1)
                    {
                        PlayerInfo[i][pInt] = 6;
                        PlayerInfo[i][pLocal] = 6;
                        SetPlayerInterior(i, 6);
                        SetPlayerVirtualWorld(i, 2);
                        SetPlayerPos(i,268.0903,77.6489,1001.0391);
                    }
                    else if(PlayerInfo[i][pJailed] == 2)
                    {
                        PlayerInfo[i][pInt] = 9999;
                        PlayerInfo[i][pLocal] = 0;
                        SetPlayerWorldBounds(i,20000.0000,-20000.0000,20000.0000,-20000.0000); // Reset world to player
                        SetPlayerInterior(i, 0);
                        SetPlayerPos(i, 90.2101,1920.4854,17.9422);
                    }
                    else if(PlayerInfo[i][pJailed] == 4)
                    {
                        PlayerInfo[i][pInt] = 10;
                        PlayerInfo[i][pLocal] = 8;
                        SetPlayerInterior(i, 10);
                        SetPlayerVirtualWorld(i, 3);
                        SetPlayerPos(i,227.4131,114.8236,999.0156);
                    }
                    else if(PlayerInfo[i][pJailed] == 5)
                    {
                        PlayerInfo[i][pInt] = 3;
                        PlayerInfo[i][pLocal] = 10;
                        SetPlayerInterior(i, 3);
                        SetPlayerVirtualWorld(i, 4);
                        SetPlayerPos(i,198.0560,179.4158,1003.0306);
                    }
                    else if(PlayerInfo[i][pJailed] == 6)
                    {
                        PlayerInfo[i][pInt] = 6;
                        PlayerInfo[i][pLocal] = 12;
                        SetPlayerInterior(i, 6);
                        SetPlayerVirtualWorld(i, 2);
                        SetPlayerPos(i,268.0903,77.6489,1001.0391);
                    }
                    PlayerInfo[i][pJailed] = 0;
                    SendClientMessage(i, COLOR_GRAD1,"   You have paid your debt to society.");
                    format(string, sizeof(string), "~g~Freedom~n~~w~Try to be a better citizen");
                    GameTextForPlayer(i, string, 5000, 1);
                    if(gTeam[i] == 4) { gTeam[i] = 3; }
                    ClearCrime(i);
                    SetPlayerToTeamColor(i);
                    if(IsALawEnforcer(i) && OnDuty[i] == 0)
                    {
                        SetPlayerColor(i, COLOR_WHITE);
                        OnDuty[i] = 0;
                    }
                }
            }
            if(ConsumingMoney[i] == 1)
            {
                if(PlumCash[i] != 98464983211651)
                {
                    new dropCash = GetPlayerMoney(i);
                    if(PlumCash[i] > dropCash)
                    {
                        PlumCash[i] = GetPlayerMoney(i);
                    }
                    if(PlumCash[i] == dropCash)
                    {
                        ConsumingMoney[i] = 0;
                        PlumCash[i] = 98464983211651;
                    }
                }
                else
                {
                    PlumCash[i] = GetPlayerMoney(i);
                }
            }
/*          else
            {
                new chaching = GetPlayerMoney(i);
                if(chaching != PlayerInfo[i][pCash] && !InCasino(i))
                {
                    cock(i);
                }
            }*/

            if(CarSystem[newcar][cVehicleType] == 1 && IsALawEnforcer(i) || CarSystem[newcar][cVehicleType] == 2 && IsALawEnforcer(i) || CarSystem[newcar][cVehicleType] == 3 && IsALawEnforcer(i))
            {
                new Float:copArmor;
                GetPlayerArmour(i, copArmor);
                if(copArmor < 100)
                {
                    copArmor += 1;
                    SetPlayerArmour(i, copArmor);
                }
            }
            if((PlayerCuffed[i] == 1 || PlayerCuffed[i] == 2) && PlayerInfo[i][pAdmin] < 2)
            {
                if(!IsPlayerInRangeOfPoint(i, 1.0, PlayerXbust[i], PlayerYbust[i], PlayerZbust[i]))
                {
                    SetPlayerPos(i, PlayerXbust[i], PlayerYbust[i], PlayerZbust[i]);
                    TogglePlayerControllable(i, 0);
                    PlayerCuffedTime[i] = 180;
                    new PName[MAX_PLAYER_NAME];
                    GetPlayerName(i,PName,sizeof(PName));

                    if(PlayerInfo[i][pSex] == 1) format(string, sizeof(string), "You notice %s attempting to wiggle out of his cuffs.", PName);
                    if(PlayerInfo[i][pSex] == 2) format(string, sizeof(string), "You notice %s attempting to wiggle out of her cuffs.", PName);
                    ProxDetector(10.0, i, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    SendClientMessage(i, COLOR_GRAD1,"You attempt to wiggle out of your cuffs but all you do is hurt yourself and start crying");
                    if(PlayerInfo[i][pSex] == 1) format(string, sizeof(string), "%s doesn't get very far before he starts crying.", PName);
                    if(PlayerInfo[i][pSex] == 2) format(string, sizeof(string), "%s doesn't get very far before she starts crying.", PName);
                    ProxDetector(5.0, i, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                }
            }
            if(PlayerCuffed[i] == 3)
            {
                if(!IsPlayerInVehicle(i, PlayerCarbust[i]))
                {
                    new PName[MAX_PLAYER_NAME];
                    GetPlayerName(i,PName,sizeof(PName));
                    if(PlayerInfo[i][pSex] == 1) format(string, sizeof(string), "You notice %s pissing himself in fear.", PName);
                    if(PlayerInfo[i][pSex] == 2) format(string, sizeof(string), "You notice %s pissing herself in fear.", PName);
                    SendClientMessage(i, COLOR_GRAD1,"You attempt to exit the vehicle but instead you just wet your pants.");
                    ProxDetector(10.0, i, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    PutPlayerInVehicle(i, PlayerCarbust[i], 4);
                    TogglePlayerControllable(i, 0);
                    PlayerCuffed[i] = 3;
                    PlayerCuffedTime[i] = 300;
                    PlayerInfo[i][pJailed] = 3;
                    PlayerInfo[i][pJailTime] = 1800;
                }
            }
            if(UsedFind[i] >= 1)
            {
                UsedFind[i] += 1;
                if(UsedFind[i] >= 120)
                {
                    UsedFind[i] = 0;
                }
            }
            if(PlayerDruggie[i] >= 1)
            {
                PlayerDruggie[i] += 1;
                if(PlayerDruggie[i] >= 10 && PlayerInfo[i][pDrugPerk] > 0)
                {
                    PlayerDruggie[i] = 0;
                }
                if(PlayerDruggie[i] >= 20)
                {
                    PlayerDruggie[i] = 0;
                }
            }
            if(TazerReload[i] >= 1)
            {
                TazerReload[i] += 1;
                if(TazerReload[i] >= 10)
                {
                    SendClientMessage(i, COLOR_GRAD1," Your tazer has fully recharged.");
                    PlayerPlaySound(i, 1052, 0.0, 0.0, 0.0);
                    TazerReload[i] = 0;
                }
            }
pawn Код:
if(strcmp(cmd, "/arrest", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(IsALawEnforcer(playerid))
            {
                if(OnDuty[playerid] != 1)
                {
                    SendClientMessage(playerid, COLOR_GREY, "   You are not on Duty!");
                    return 1;
                }
                if(IsAtArrestPoint(playerid) > 0)
                {
                    tmp = strtok(cmdtext, idx);
                    if(!strlen(tmp))
                    {
                        SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /arrest [price] [time (minutes)] [bail (0=no 1=yes)] [bailprice]");
                        return 1;
                    }
                    moneys = strval(tmp);
                    if(moneys < 1 || moneys > 99999) { SendClientMessage(playerid, COLOR_GREY, "   Jail Price can't be below $1 or above $99,999 !"); return 1; }
                    tmp = strtok(cmdtext, idx);
                    if(!strlen(tmp))
                    {
                        SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /arrest [price] [time (minutes)] [bail (0=no 1=yes)] [bailprice]");
                        return 1;
                    }
                    new time = strval(tmp);
                    if(time < 1 || time > 20) { SendClientMessage(playerid, COLOR_GREY, "   Jail Time Minutes can't be below 1 or above 20 (Take the person to prison then) !"); return 1; }
                    tmp = strtok(cmdtext, idx);
                    if(!strlen(tmp))
                    {
                        SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /arrest [price] [time (minutes)] [bail (0=no 1=yes)] [bailprice]");
                        return 1;
                    }
                    new bail = strval(tmp);
                    if(bail < 0 || bail > 1) { SendClientMessage(playerid, COLOR_GREY, "   Jail Bailing can't be below 0 or above 1 !"); return 1; }
                    tmp = strtok(cmdtext, idx);
                    if(!strlen(tmp))
                    {
                        SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /arrest [price] [time (minutes)] [bail (0=no 1=yes)] [bailprice]");
                        return 1;
                    }
                    new bailprice = strval(tmp);
                    if(bailprice < 0 || bailprice > 3000000) { SendClientMessage(playerid, COLOR_GREY, "   Jail Bailing can't be below $0 or above $3,000,000 !"); return 1; }
                    new suspect = GetClosestPlayer(playerid);
                    if(IsPlayerConnected(suspect))
                    {
                        if(GetDistanceBetweenPlayers(playerid,suspect) < 5)
                        {
                            if(IsPlayerNPC(suspect))
                            {
                                SendClientMessage(playerid, COLOR_GREY, "This command is disabled for usage against a NPC.");
                                return 1;
                            }
                            GetPlayerName(suspect, giveplayer, sizeof(giveplayer));
                            GetPlayerName(playerid, sendername, sizeof(sendername));
                            if(WantedLevel[suspect] < 1)
                            {
                                SendClientMessage(playerid, COLOR_GREY, "   Player must be at least Wanted Level 1 !");
                                return 1;
                            }
                            format(string, sizeof(string), "* You arrested %s !", giveplayer);
                            SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
                            ConsumingMoney[suspect] = 1;
                            GivePlayerMoney(suspect, -moneys);
                            PlayerInfo[suspect][pCash] -= moneys;
                            format(string, sizeof(string), "arrested by %s ~n~    for %s", sendername, ConvertToMoney(moneys));
                            GameTextForPlayer(suspect, string, 5000, 5);
                            ResetPlayerWeapons(suspect);
                            new price = WantedLevel[suspect] * 2000;
                            format(string, sizeof(string), "~w~Running Suspect~r~~n~Captured~n~Bonus~g~%s", ConvertToMoney(price));
                            GameTextForPlayer(playerid, string, 5000, 1);
                            ConsumingMoney[playerid] = 1;
                            GivePlayerMoney(playerid, price / 2);
                            PlayerInfo[playerid][pCash] += price / 2;
                            PlayerPlaySound(playerid, 1058, 0.0, 0.0, 0.0);
                            PlayerXbust[suspect] = 0;
                            PlayerYbust[suspect] = 0;
                            PlayerZbust[suspect] = 0;
                            PlayerCarbust[suspect] = 0;
                            PlayerCuffed[suspect] = 0;
                            TogglePlayerControllable(suspect, 1);
                            if(PlayerInfo[playerid][pMember]==1||PlayerInfo[playerid][pLeader]==1)
                            {
                                format(string, sizeof(string), "<< Officer %s arrested suspect %s >>", sendername, giveplayer);
                                OOCNews(COLOR_LIGHTRED, string);
                            }
                            else if(PlayerInfo[playerid][pMember]==2||PlayerInfo[playerid][pLeader]==2)
                            {
                                format(string, sizeof(string), "<< FBI Agent %s arrested suspect %s >>", sendername, giveplayer);
                                OOCNews(COLOR_LIGHTRED, string);
                            }
                            else if(PlayerInfo[playerid][pMember]==3||PlayerInfo[playerid][pLeader]==3)
                            {
                                format(string, sizeof(string), "<< Soldier %s arrested suspect %s >>", sendername, giveplayer);
                                OOCNews(COLOR_LIGHTRED, string);
                            }

                            if(IsAtArrestPoint(playerid) == 1) // LSPD Jail
                            {
                                PlayerInfo[suspect][pJailed] = 1;
                                SetPlayerInterior(suspect, 6);
                                SetPlayerVirtualWorld(suspect, 2);
                                PlayerInfo[suspect][pInt] = 6;
                                PlayerInfo[suspect][pLocal] = 6
                                SetPlayerPos(suspect,264.1950,77.5579,1001.0391);
                                PlayerInfo[suspect][pJailTime] = time * 60;
                            }
                            if(IsAtArrestPoint(playerid) == 2) // SFPD Jail
                            {
                                PlayerInfo[suspect][pJailed] = 4;
                                SetPlayerInterior(suspect, 10);
                                SetPlayerVirtualWorld(suspect, 3);
                                PlayerInfo[suspect][pInt] = 10;
                                PlayerInfo[suspect][pLocal] = 8;
                                SetPlayerPos(suspect,227.0627,110.6248,999.0156);
                                PlayerInfo[suspect][pJailTime] = time * 60;
                            }
                            if(IsAtArrestPoint(playerid) == 3) // LVPD Jail
                            {
                                PlayerInfo[suspect][pJailed] = 5;
                                SetPlayerInterior(suspect, 3);
                                SetPlayerVirtualWorld(suspect, 4);
                                PlayerInfo[suspect][pInt] = 3;
                                PlayerInfo[suspect][pLocal] = 10;
                                SetPlayerPos(suspect,197.2974,174.8074,1003.0234);
                                PlayerInfo[suspect][pJailTime] = time * 60;
                            }
                            if(IsAtArrestPoint(playerid) == 4) // FBI Jail
                            {
                                PlayerInfo[suspect][pJailed] = 6;
                                SetPlayerInterior(suspect, 6);
                                SetPlayerVirtualWorld(suspect, 2);
                                PlayerInfo[suspect][pInt] = 6;
                                PlayerInfo[suspect][pLocal] = 12;
                                SetPlayerPos(suspect,264.6288,77.5742,1001.0391);
                                PlayerInfo[suspect][pJailTime] = time * 60;
                            }
                            else
                            {
                                PlayerInfo[suspect][pJailed] = 1;
                                SetPlayerInterior(suspect, 6);
                                SetPlayerVirtualWorld(suspect, 2);
                                PlayerInfo[suspect][pInt] = 6;
                                PlayerInfo[suspect][pLocal] = 6;
                                SetPlayerPos(suspect,264.1950,77.5579,1001.0391);
                                PlayerInfo[suspect][pJailTime] = time * 60;
                            }
                            if(bail == 1)
                            {
                                JailPrice[suspect] = bailprice;
                                format(string, sizeof(string), "You are jailed for %d seconds.   Bail: %s.", PlayerInfo[suspect][pJailTime], ConvertToMoney(JailPrice[suspect]));
                                SendClientMessage(suspect, COLOR_LIGHTBLUE, string);
                            }
                            else
                            {
                                JailPrice[suspect] = 0;
                                format(string, sizeof(string), "You are jailed for %d seconds.   Bail: Unable.", PlayerInfo[suspect][pJailTime]);
                                SendClientMessage(suspect, COLOR_LIGHTBLUE, string);
                            }
                            PlayerInfo[suspect][pArrested] += 1;
                            SetPlayerFree(suspect,playerid, "Got Arrested");
                            WantedPoints[suspect] = 0;
                            WantedLevel[suspect] = 0;
                            WantLawyer[suspect] = 1;
                        }
                    }
                    else
                    {
                        SendClientMessage(playerid, COLOR_GREY, "   No-one close enough to arrest.");
                        return 1;
                    }
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "   You not at a arrest station !");
                    return 1;
                }
            }
        }
        return 1;
    }
Reply
#2

I still have the same problem with this , I haven't found a solution yet so I am curious to know what
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)