Portal SAMP
[Ajuda] Player nasce na prisão sem estar preso realmente. - Versão de Impressão

+- Portal SAMP (https://portalsamp.com)
+-- Fórum: SA-MP (https://portalsamp.com/forumdisplay.php?fid=5)
+--- Fórum: Área de suporte (https://portalsamp.com/forumdisplay.php?fid=6)
+--- Tópico: [Ajuda] Player nasce na prisão sem estar preso realmente. (/showthread.php?tid=2027)



Player nasce na prisão sem estar preso realmente. - fear - 09/01/2022

boa tarde. estou com um problema que tem hora que o player não foi preso por ninguem ele vai logar e diz que ele esta preso porém ele spawna normalmente.. ai o player reloga e nasce na cadeia como se tivesse sido preso mas não foi..

segue todo o codigo de prisão tanto por policial como por admin

Código PHP:
    if(IsPlayerJailed(playerid) || IsPlayerInChainAdmin(playerid))
    {

        static 
commandsAllowed[][11] = {
            
"/admins",
            
"/ranking",
            
"/afks",
            
"/presoscmd"
        
}, i;

        for(
0sizeof(commandsAllowed); i++)
        {

            if(!
isnull(cmdtext) && (strfind(cmdtextcommandsAllowed[i][0], true) != -1))
            return 
true;
        }

        
SendClientMessage(playeridCOLOR_REDTEXT_PLAYER_JAILED_CANT_USE_CMD);
        return 
false;
    }
    else if(
IsPlayerPoliceTarget(playerid))
    {

        static 
commandsForbidden[][15] = {
            
"/v",
            
"/car",
            
"/Aerolv",
            
"/Aerols",
            
"/Aerosf",
            
"/Lv",
            
"/Sf",
            
"/Ls",
            
"/Oficina",
            
"/Mappack",
            
"/Bigear",
            
"/Drift2",
            
"/Drift3",
            
"/Drift4",
            
"/Drift5",
            
"/Drift6",
            
"/Drift7",
            
"/Drift8",
            
"/Drift9",
            
"/Drift10",
            
"/DriftCity",
            
"/Twin",
            
"/Twin2",
            
"/Chilliad",
            
"/Stunt",
            
"/Circuito",
            
"/Chilliad",
            
"/Parkour",
            
"/Parkour2",
            
"/Parkour3",
            
"/Nrgparkour1",
            
"/Nrgparkour2",
            
"/Drop1",
            
"/Drop2",
            
"/Drag",
            
"/Praia",
            
"/Rdograu",
            
"/ir",
            
"/goto",
            
"/Mundo",
            
"/Jetpack",
            
"/Skin",
            
"/Veh",
            
"/Lvap",
            
"/Sfap",
            
"/Lspa",
            
"/Mp",
            
"/Kill",
            
"/Cg",
            
"/larmas",
            
"/Eagle",
            
"/DM",
            
"/Area51",
            
"/Favela",
            
"/Favela2",
            
"/Favela3",
            
"/Favelasf",
            
"/Afk",
            
"/Mundo",
            
"/cr",
            
"/irp",
            
"/r",
            
"/sp",
            
"/s",
            
"/arenapvp"
        
}, i;

        for(
0sizeof(commandsForbidden); i++)
        {

            if(!
isnull(cmdtext) && (strfind(cmdtextcommandsForbidden[i][0], true) != -1))
            {

                
SendClientMessage(playeridCOLOR_REDTEXT_PLAYER_TARGET_CANT_USE_CMD);
                return 
false;
            }
        }
        return 
true;
    }

    return 
true;


ONPLAYERCONNECT

Código PHP:
ResetPlayerChainAdmin(playerid);
ResetPlayerJail(playerid);

    if(
playerConnectedNow[playerid])
    {

        
playerConnectedNow[playerid] = false;

        
SetTimerEx("LoadPlayerChainAdmin"300false"i"playerid);

        
GetPlayerPos(playeridplayerAFKCheck[playerid][E_PLAYER_AFK_POS][0], playerAFKCheck[playerid][E_PLAYER_AFK_POS][1], playerAFKCheck[playerid][E_PLAYER_AFK_POS][2]);

        
SetTimerEx("CheckPlayerAfk"CHECK_PLAYER_AFK_TIMEtrue"i"playerid);

        
SetTimerEx("CheckPlayerWeaponHack"700false"i"playerid);
        
checkPlayerNameTimer[playerid] = SetTimerEx("CheckPlayerNameAltered"1000true"i"playerid);

        
ContaPlayer[playerid][Score] = GetPlayerScore(playerid);
        
        if(
MundoDM[playerid])
        {

            new 
weapons[13][2], i;

            for (
0<= 12i++)
            
GetPlayerWeaponData(playeridiweapons[i][0], weapons[i][1]);

            
ResetPlayerWeapons(playerid);

            for(
0<= 12i++)
            {

                if(
weapons[i][0] == 46 || weapons[i][0] == 43)
                
GivePlayerWeapon(playeridweapons[i][0], weapons[i][1]);
            }
        }
    } 

SISTEMA DE CADEIA ADMIN
Código PHP:
IsPlayerInChainAdmin(playerid)
        return 
playerChainAdmin[playerid][E_PLAYER_IN_CHAIN];

        static 
PutPlayerInChainAdmin(playeridtime)
        {
            
time gettime() + time;//(60 * time);

            
playerChainAdmin[playerid][E_PLAYER_IN_CHAIN] = true;
            
playerChainAdmin[playerid][E_PLAYER_CHAIN_TIME] = time;

            
SetPlayerWantedLevel(playerid0);

            if(
IsPlayerCuffed(playerid))
            
UnshacklePlayer(playeridREASON_NONE);

            if(
IsPlayerArrasted(playerid))
            
ChangePlayerArrestedState(playeridGetPlayerArrastedMe(playerid), REASON_ADMIN);

            if(
IsPlayerApproached(playerid))
            
ChangePlayerApproachedState(playeridGetPlayerApproachedMe(playerid), REASON_ADMIN);

            
TogglePlayerControllable(playeridtrue);

            
SetPlayerTeam(playeridTEAM_JAIL);
            
SetPlayerClass(playeridPLAYER_CLASS_CIVIL);

            
SetPlayerVirtualWorld(playerid6666);
            
SetPlayerInterior(playerid6);
            
ResetPlayerWeapons(playerid);
            
SetPlayerPos(playeridprisionPosition[0], prisionPosition[1], prisionPosition[2]);
            
SetPlayerFacingAngle(playeridprisionPosition[3]);
            
SetPlayerHealth(playerid99999);
            
SetCameraBehindPlayer(playerid);

            
SetTimerEx("ShowPlayerPrisionTime"900false"iii"playeridtime1);

        }

        static 
RemovePlayerFromChainAdmin(playerid)
        {
            
SetPlayerClass(playeridPLAYER_CLASS_CIVIL);

            
SetPlayerInterior(playerid0);

            
ResetPlayerChainAdmin(playerid);

            
SavePlayerChainAdmin(playerid);

            
SpawnPlayer(playerid);

            
SetPlayerHealth(playerid100.0);

            
GameTextForPlayer(playerid"Livre"13);
        }

        
ResetPlayerChainAdmin(playerid)
        {
            
playerChainAdmin[playerid][E_PLAYER_IN_CHAIN] = false;
            
playerChainAdmin[playerid][E_PLAYER_CHAIN_TIME] = 0;
        }




        
call:LoadPlayerChainAdmin(playerid)
        {
            if(!
IsPlayerConnected(playerid))
            return;

            if(
dir_exists(DIRECTORY_CHAIN_ADMIN))
            {

                new 
file[MAX_PLAYER_NAME 1];

                
format(filesizeof(file), PLAYER_FILE_CHAIN_ADMIN_CFGNome(playerid));

                if(
DOF2_FileExists(file))
                {

                    
playerChainAdmin[playerid][E_PLAYER_IN_CHAIN] = DOF2_GetBool(file"inChainAdmin");
                    
playerChainAdmin[playerid][E_PLAYER_CHAIN_TIME] = DOF2_GetInt(file"chainTime");/* + gettime();*/

                    
if(playerChainAdmin[playerid][E_PLAYER_IN_CHAIN] && playerChainAdmin[playerid][E_PLAYER_CHAIN_TIME] > 0)
                    {

                        
SendClientMessage(playeridCOLOR_YELLOWTEXT_PLAYER_JAIL_INCOMPLETE);
                        
PutPlayerInChainAdmin(playeridplayerChainAdmin[playerid][E_PLAYER_CHAIN_TIME]);
                    }
                    else
                    {

                        
ResetPlayerChainAdmin(playerid);
                        
DOF2_RemoveFile(file);
                        
DOF2_SaveFile();
                    }
                }
            }
        }

        static 
SavePlayerChainAdmin(playerid)
        {
            new 
file[MAX_PLAYER_NAME 1];

            
format(filesizeof(file), PLAYER_FILE_CHAIN_ADMIN_CFGNome(playerid));

            if(!(
playerChainAdmin[playerid][E_PLAYER_IN_CHAIN] && GetPlayerChainAdminTime(playerid) > 0))
            {

                if(
DOF2_FileExists(file))
                {

                    
DOF2_RemoveFile(file);
                    
DOF2_SaveFile();
                }

                return;
            }

            if(!
DOF2_FileExists(file))
            
DOF2_CreateFile(file);

            
DOF2_SetBool(file"inChainAdmin"playerChainAdmin[playerid][E_PLAYER_IN_CHAIN]);
            
DOF2_SetInt(file"chainTime"GetPlayerChainAdminTime(playerid));
            
DOF2_SaveFile();
        }

        static 
GetPlayerChainAdminTime(playerid)
        {
            new 
time gettime();
            return (
playerChainAdmin[playerid][E_PLAYER_CHAIN_TIME] < time) ? (0) : (playerChainAdmin[playerid][E_PLAYER_CHAIN_TIME] - time);
        } 

SISTEMA DE CADEIA POLICIAL
Código PHP:
call:ShowPlayerPrisionTime(playeridtimeArrestedtype)//0 - Jail | 1 - Chain Admin
{
    if(!
IsPlayerConnected(playerid))
    return;

    if(!
type)
    {
        
        if(!
playerJail[playerid][E_PLAYER_JAILED])
        return;
    }
    else
    {
        
        if(!
IsPlayerInChainAdmin(playerid))
        return;
    }

    if(
gettime() >= timeArrested)
    {
        
        
SetPlayerTeam(playeridGetTeamOfPlayer(playerid));

        
SetPlayerInterior(playerid,0);

        
SetPlayerWorld(playerid0);

        
SpawnPlayer(playerid);
        
ResetPlayerJail(playerid);
        
ResetPlayerChainAdmin(playerid);
        
SavePlayerJail(playerid);

        
GameTextForPlayer(playerid""13);
        return;
    }
    new 
time[16 12 1];

    
format(timesizeof(time), TEXT_TIME_PRISIONTimeConvert(timeArrested));
    
GameTextForPlayer(playeridtime13003);

    
SetTimerEx("ShowPlayerPrisionTime"900false"iii"playeridtimeArrestedtype);
}

call:LoadPlayerJail(playerid)
{
    if(!
IsPlayerConnected(playerid))
    return;

    if(
dir_exists(DIRECTORY_JAIL))
    {
        
        new 
file[MAX_PLAYER_NAME 1];

        
format(filesizeof(file), PLAYER_FILE_JAIL_CFGGetNameOfPlayer(playerid));

        if(
DOF2_FileExists(file))
        {
            
            
playerJail[playerid][E_PLAYER_JAILED] = DOF2_GetBool(file"jailed");
            
playerJail[playerid][E_PLAYER_JAIL_TIME] = DOF2_GetInt(file"jailTime") + gettime();

            if(
playerJail[playerid][E_PLAYER_JAILED] && playerJail[playerid][E_PLAYER_JAIL_TIME] > 0)
            {
                
                
SendClientMessage(playeridCOLOR_YELLOWTEXT_PLAYER_JAIL_INCOMPLETE);
                
PutPlayerInPrision(playerid, -1, -1);
                return;
            }
            else
            {
                
                
ResetPlayerJail(playerid);
                
DOF2_RemoveFile(file);
                
DOF2_SaveFile();
            }
        }
    }
    
CheckPlayerState(playerid);


O SISTEMA DE CADEIA POLICIAL ESTA EM INCLUDE E O SISTEMA DE PRISÃO ADM ESTA NO GAMEMODE.. MAS OS DOIS ESTÃO VERIFICANDO CERTO PELO QUE EU OLHEI.. ALGUEM PODE ME AJUDAR A DESCOBRIR PORQUE DESSE BUG INTERMITENTE.