22.08.2017, 00:44 
	
	
	
		There is a problem !! I added a specific time to jail but did not work how to fix me? Or can I do a new one?
And now I have added the code to you. How do I know that I have added time but the problem is that it did not work? How can I fix it? Or have you added a new time? I prefer to try textdraws or wait for the moment we do not want.
# Solve it?
And here i've added a timer In OnGameModeInit but not work... SetTimer("Unjail", 1000, true);
i know i've added topic before for this problem but none help me can you help me now pls?
	
	
	
PHP код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[256], idx, tmp[256], name[MAX_PLAYER_NAME], file[256];
    new giveplayerid;
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), "%s.runix", name);
    cmd = strtok(cmdtext, idx);
    if(strcmp(cmd, "/arrest", true) == 0 || strcmp(cmd, "/ar", true) == 0)
    {
    new string[250];
    if(IsSpawned[playerid] == 0)
    {
    SendClientMessage(playerid, COLOR_ERROR, "[DEAD]: You are dead. You cannot use this command");
    return 1;
    }
    new pskin = GetPlayerSkin(playerid);
    if(pskin == 265 || pskin == 266 || pskin == 267 || pskin == 280 || pskin == 281 || pskin == 284 || pskin == 285 || pskin == 286 || pskin == 287 || pskin == 288)
    {
    SendClientMessage(playerid,COLOR_ERROR,"{1E7F9A}[POLICE]: {FFFFFF}You are not a Law Enforcement officer ");
    return 1;
    }
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
    {
    SendClientMessage(playerid, COLOR_ERROR, "{1E7F9A}[POLICE SUSPECT]: {FFFFFF}/ar (PlayerID)");
    return 1;
    }
    giveplayerid = strval(tmp);
    if(!IsNumeric(tmp))
    {
    SendClientMessage(playerid, COLOR_ERROR, "{1E7F9A}[POLICE SUSPECT]: {FFFFFF}USAGE: /ar (id) ID Must be a number");
    return 1;
    }
    if(!IsPlayerConnected(giveplayerid))
    {
    format(string, sizeof(string), "{1E7F9A}[POLICE SUSPECT]: {FFFFFF}ID (%d) is not an active player", giveplayerid);
    SendClientMessage(playerid, COLOR_ERROR, string);
    return 1;
    }
    new oname[24];
    new pname[24];
    GetPlayerName(playerid,oname, 24);
    GetPlayerName(giveplayerid, pname, 24);
    if(GetPlayerWantedLevel(giveplayerid) <= 3)
    {
    format(string, sizeof(string), "{1E7F9A}[POLICE SUSPECT]: {FFFFFF}%s(%d) Does not have a warrant. You cannot arrest a player without a warrant",pname,giveplayerid);
    SendClientMessage(playerid,COLOR_ERROR,string);
    return 1;
    }
    if(IsPlayerInAnyVehicle(playerid))
    {
    SendClientMessage(playerid,COLOR_ERROR,"{1E7F9A}[POLICE SUSPECT]: {FFFFFF}You cannot arrest a suspect if you are in a car");
    return 1;
    }
    if(IsPlayerInAnyVehicle(giveplayerid))
    {
    SendClientMessage(playerid,COLOR_ERROR,"{1E7F9A}[POLICE SUSPECT]: {FFFFFF}You cannot arrest this player while he in vehicle.");
    return 1;
    }
    if(GetDistanceBetweenPlayers(playerid,giveplayerid) > 10)
    {
    format(string, sizeof(string), "{1E7F9A}[POLICE SUSPECT]: {FFFFFF}%s(%d) Is too far away. You cannot arrest that player",pname,giveplayerid);
    SendClientMessage(playerid,COLOR_ERROR,string);
    return 1;
    }
    if(IsSpawned[giveplayerid] == 0)
    {
    format(string, sizeof(string), "{1E7F9A}[POLICE SUSPECT]: {FFFFFF}%s(%d) Is dead. You cannot arrest a dead body",pname,giveplayerid);
    SendClientMessage(playerid,COLOR_ERROR,string);
    return 1;
    }
    SetPlayerVirtualWorld(giveplayerid,0);
    if(GetPlayerWantedLevel(playerid) >=1 & 3)
    {
    SendClientMessage(playerid,COLOR_ERROR,"{1E7F9A}[POLICE SUSPECT]: {FFFFFF}You cannot arrest yourself.");
    return 1;
    }
    if(giveplayerid == playerid)
    {
    SendClientMessage(playerid,COLOR_ERROR,"You cannot arrest yourself.");
    return 1;
    }
    new spawn = random(sizeof(PrisonSpawn)), string2[250], Float:health, copname[MAX_PLAYER_NAME], arrested[MAX_PLAYER_NAME];
    GetPlayerName(playerid, copname, sizeof(copname));
    GetPlayerName(strval(tmp), arrested, sizeof(arrested));
    GetPlayerHealth(strval(tmp), health);
    SendClientMessage(strval(tmp), GREY, "|_| San Andreas Police Dept. |_|");
    format(string, sizeof(string), "{FF9300}[POLICE ARRESTED]: {008FFF}Offiecr %s {008FFF}has arrested you.", copname);
    SendClientMessage(strval(tmp), WHITE, string);
    ResetPlayerWeapons(strval(tmp));
    SetPlayerPos(strval(tmp), PrisonSpawn[spawn][0], PrisonSpawn[spawn][1], PrisonSpawn[spawn][2]);
    SetPlayerFacingAngle(strval(tmp), PrisonSpawn[spawn][3]);
    SetCameraBehindPlayer(strval(tmp));
    if(GetPlayerWantedLevel(strval(tmp)) >= 4 && GetPlayerWantedLevel(strval(tmp)) <= 5)
    {
    PrisonTime[strval(tmp)] = 60;
    GivePlayerMoney(playerid,25000);
    GivePlayerScore(playerid,1);
    }
    else if(GetPlayerWantedLevel(strval(tmp)) >= 6 && GetPlayerWantedLevel(strval(tmp)) <= 8)
    {
    PrisonTime[strval(tmp)] = 120;
    GivePlayerMoney(playerid,35000);
    GivePlayerScore(playerid,1);
    }
    else if(GetPlayerWantedLevel(strval(tmp)) >= 9 && GetPlayerWantedLevel(playerid) <= 11)
    {
    PrisonTime[strval(tmp)] = 180;
    GivePlayerMoney(playerid,45000);
    GivePlayerScore(playerid,2);
    }
    else if(GetPlayerWantedLevel(strval(tmp)) >= 12 && GetPlayerWantedLevel(strval(tmp)) <= 14)
    {
    PrisonTime[strval(tmp)] = 240;
    GivePlayerMoney(playerid,55000);
    GivePlayerScore(playerid,2);
    }
    else if(GetPlayerWantedLevel(strval(tmp)) >= 15)
    {
    PrisonTime[strval(tmp)] = 300;
    GivePlayerMoney(playerid,65000);
    GivePlayerScore(playerid,3);
    }
    SetPlayerWantedLevel(strval(tmp), 0);
    SetPlayerInterior(strval(tmp),3);
    SetPlayerHealth(strval(tmp),99999);
    GivePlayerScore(giveplayerid, -1);
    TogglePlayerControllable(strval(tmp), true);
    SetPlayerJailed(strval(tmp), true);
    format(string2, sizeof(string2), "{FF9300}[POLICE ARRESTED]: {008FFF}Officer %s[ID:%d] {FFFFFF}arrested  %s(%d).", copname, playerid, arrested, strval(tmp));
    Announce(string2);
    PrisonTime[giveplayerid] =1;
    if(health <= 90)
    {
    SendClientMessage(strval(tmp), GREY, "|_| San Andreas Police Dept. |_|");
    SendClientMessage(strval(tmp), WHITE, "SAPD has given you some food.");
    SetPlayerHealth(strval(tmp), health+10);
    ApplyAnimation(strval(tmp), "FOOD", "EAT_Burger", 4.0, 0, 0, 0, 0, 0);
    }
    return 1;
    }
      return 0;
} 
And now I have added the code to you. How do I know that I have added time but the problem is that it did not work? How can I fix it? Or have you added a new time? I prefer to try textdraws or wait for the moment we do not want.
# Solve it?
PHP код:
public Unjail()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            new file[256], name[MAX_PLAYER_NAME];
            GetPlayerName(i, name, sizeof(name));
            format(file, sizeof(file), "%s.runix", name);
            if(IsPlayerJailed(i))
            {
                if(PrisonTime[i] == 1)
                {
                    PrisonTime[i] = 1;
                    new string[256];
                    format(string, sizeof(string), "TIME LEFT: %d", PrisonTime[i]);
                    GameTextForPlayer(i, string, 3000, 4);
                    SendClientMessage(i, -1, "Testiiiiiing");
                }
                if(PrisonTime[i] == 0)
                {
                    new string[256];
                    SetPlayerInterior(i, 3);
                    SetPlayerPos(i, 231.1111, 146.7039, 1003.0234);
                    SetPlayerFacingAngle(i, 272.8459);
                    SetCameraBehindPlayer(i);
                    PD[i] = 1;
                    SendClientMessage(i, GREY, "|_| San Andreas Police Dept. |_|");
                    SendClientMessage(i, WHITE, "You are free to go. Just don't get into trouble.");
                    format(string, sizeof(string), "%s[ID:%d] has been released from prison.", name, i);
                    Announce(string);
                    SetPlayerHealth(i,100);
                    SetPlayerJailed(i, false);
                    SetPlayerPrisonTime(i, 0);
                }
            }
        }
    }
}
stock IsPlayerJailed(playerid)
{
    new file[256], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), "%s.runix", name);
    if(dini_Int(file, "Jail") == 1)
    {
        return true;
    }
    else if(dini_Int(file, "Jail") == 0)
    {
        return false;
    }
    return true;
}
stock Announce(const str[])
{
    return SendClientMessageToAll(SERVER_COLOR, str);
}
stock GivePlayerScore(playerid, score)
{
    SetPlayerScore(playerid, GetPlayerScore(playerid)+score);
    return true;
}
stock SetPlayerJailed(playerid, bool)
{
    new file[256], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), "%s.runix", name);
    if(bool == 1) dini_IntSet(file, "Jail", 1);
    else if(bool == 0) dini_IntSet(file, "Jail", 0);
    return true;
}
strtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }
    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}
IsNumeric(const string[])
{
for (new i = 0, j = strlen(string); i < j; i++) {
    if (string[i] > '9' || string[i] < '0') {
return 0;
}
}
return 1;
}
stock SetPlayerPrisonTime(playerid, ptime)
{
    new file[256], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), "%s.runix", name);
    dini_IntSet(file, "PrisonTime", ptime);
    return true;
} 
i know i've added topic before for this problem but none help me can you help me now pls?






