Timer still not work for Jail...
#1

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?


PHP код:
public OnPlayerCommandText(playeridcmdtext[])
{
    new 
cmd[256], idxtmp[256], name[MAX_PLAYER_NAME], file[256];
    new 
giveplayerid;
    
GetPlayerName(playeridnamesizeof(name));
    
format(filesizeof(file), "%s.runix"name);
    
cmd strtok(cmdtextidx);
    if(
strcmp(cmd"/arrest"true) == || strcmp(cmd"/ar"true) == 0)
    {
    new 
string[250];
    if(
IsSpawned[playerid] == 0)
    {
    
SendClientMessage(playeridCOLOR_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(cmdtextidx);
    if(!
strlen(tmp))
    {
    
SendClientMessage(playeridCOLOR_ERROR"{1E7F9A}[POLICE SUSPECT]: {FFFFFF}/ar (PlayerID)");
    return 
1;
    }
    
giveplayerid strval(tmp);
    if(!
IsNumeric(tmp))
    {
    
SendClientMessage(playeridCOLOR_ERROR"{1E7F9A}[POLICE SUSPECT]: {FFFFFF}USAGE: /ar (id) ID Must be a number");
    return 
1;
    }
    if(!
IsPlayerConnected(giveplayerid))
    {
    
format(stringsizeof(string), "{1E7F9A}[POLICE SUSPECT]: {FFFFFF}ID (%d) is not an active player"giveplayerid);
    
SendClientMessage(playeridCOLOR_ERRORstring);
    return 
1;
    }
    new 
oname[24];
    new 
pname[24];
    
GetPlayerName(playerid,oname24);
    
GetPlayerName(giveplayeridpname24);
    if(
GetPlayerWantedLevel(giveplayerid) <= 3)
    {
    
format(stringsizeof(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(stringsizeof(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(stringsizeof(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) >=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:healthcopname[MAX_PLAYER_NAME], arrested[MAX_PLAYER_NAME];
    
GetPlayerName(playeridcopnamesizeof(copname));
    
GetPlayerName(strval(tmp), arrestedsizeof(arrested));
    
GetPlayerHealth(strval(tmp), health);
    
SendClientMessage(strval(tmp), GREY"|_| San Andreas Police Dept. |_|");
    
format(stringsizeof(string), "{FF9300}[POLICE ARRESTED]: {008FFF}Offiecr %s {008FFF}has arrested you."copname);
    
SendClientMessage(strval(tmp), WHITEstring);
    
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)) >= && GetPlayerWantedLevel(strval(tmp)) <= 5)
    {
    
PrisonTime[strval(tmp)] = 60;
    
GivePlayerMoney(playerid,25000);
    
GivePlayerScore(playerid,1);
    }
    else if(
GetPlayerWantedLevel(strval(tmp)) >= && GetPlayerWantedLevel(strval(tmp)) <= 8)
    {
    
PrisonTime[strval(tmp)] = 120;
    
GivePlayerMoney(playerid,35000);
    
GivePlayerScore(playerid,1);
    }
    else if(
GetPlayerWantedLevel(strval(tmp)) >= && 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(string2sizeof(string2), "{FF9300}[POLICE ARRESTED]: {008FFF}Officer %s[ID:%d] {FFFFFF}arrested  %s(%d)."copnameplayeridarrestedstrval(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.000000);
    }
    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 
0MAX_PLAYERSi++)
    {
        if(
IsPlayerConnected(i))
        {
            new 
file[256], name[MAX_PLAYER_NAME];
            
GetPlayerName(inamesizeof(name));
            
format(filesizeof(file), "%s.runix"name);
            if(
IsPlayerJailed(i))
            {
                if(
PrisonTime[i] == 1)
                {
                    
PrisonTime[i] = 1;
                    new 
string[256];
                    
format(stringsizeof(string), "TIME LEFT: %d"PrisonTime[i]);
                    
GameTextForPlayer(istring30004);
                    
SendClientMessage(i, -1"Testiiiiiing");
                }
                if(
PrisonTime[i] == 0)
                {
                    new 
string[256];
                    
SetPlayerInterior(i3);
                    
SetPlayerPos(i231.1111146.70391003.0234);
                    
SetPlayerFacingAngle(i272.8459);
                    
SetCameraBehindPlayer(i);
                    
PD[i] = 1;
                    
SendClientMessage(iGREY"|_| San Andreas Police Dept. |_|");
                    
SendClientMessage(iWHITE"You are free to go. Just don't get into trouble.");
                    
format(stringsizeof(string), "%s[ID:%d] has been released from prison."namei);
                    
Announce(string);
                    
SetPlayerHealth(i,100);
                    
SetPlayerJailed(ifalse);
                    
SetPlayerPrisonTime(i0);
                }
            }
        }
    }
}
stock IsPlayerJailed(playerid)
{
    new 
file[256], name[MAX_PLAYER_NAME];
    
GetPlayerName(playeridnamesizeof(name));
    
format(filesizeof(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_COLORstr);
}
stock GivePlayerScore(playeridscore)
{
    
SetPlayerScore(playeridGetPlayerScore(playerid)+score);
    return 
true;
}
stock SetPlayerJailed(playeridbool)
{
    new 
file[256], name[MAX_PLAYER_NAME];
    
GetPlayerName(playeridnamesizeof(name));
    
format(filesizeof(file), "%s.runix"name);
    if(
bool == 1dini_IntSet(file"Jail"1);
    else if(
bool == 0dini_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 
0strlen(string); ji++) {
    if (
string[i] > '9' || string[i] < '0') {
return 
0;
}
}
return 
1;
}
stock SetPlayerPrisonTime(playeridptime)
{
    new 
file[256], name[MAX_PLAYER_NAME];
    
GetPlayerName(playeridnamesizeof(name));
    
format(filesizeof(file), "%s.runix"name);
    
dini_IntSet(file"PrisonTime"ptime);
    return 
true;

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?
Reply
#2

Helppp me
Reply
#3

24 hour bumps only, and you'd have almost been better bumping your original topic rather than creating a new one.

You may find it better to be using sscanf and zcmd in the future as well.
Reply
#4

Ok Can you change this to sscanf and zcmd if u can pls?
Reply
#5

What exactly is the problem?

I'm assuming this:

Код:
                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); 
                }
Nowhere in your code does the players prison time actually go down so it could never be 1 or 0.

Everytime PrisonTime equals 1, you have it set to 1. You can imagine why nothing else would work.
Reply
#6

Quote:
Originally Posted by Arthur Kane
Посмотреть сообщение
What exactly is the problem?

I'm assuming this:

Код:
                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); 
                }
Nowhere in your code does the players prison time actually go down so it could never be 1 or 0.

Everytime PrisonTime equals 1, you have it set to 1. You can imagine why nothing else would work.
What is the change in this talk? I'm set to to 1; and not work.

as you see here i have this for(new i = 0; i < MAX_PLAYERS; i++)
So sure i = 0..

and i mean for 1 . 0 for factions... 1 For jailed + timer and faction 0 for unjailed. But its not work.
Reply
#7

What do you think is the difference between this:
pawn Код:
new a = 5;
if (a == 5) {
    a = 10;
}
if (a == 10) {
    a = 5;
}
and this
pawn Код:
new a = 5;
if (a == 5) {
    a = 10;
}
else if (a == 10) {
    a = 5;
}
? That's the cause of your problem OP
Reply
#8

Quote:
Originally Posted by Misiur
Посмотреть сообщение
What do you think is the difference between this:
pawn Код:
new a = 5;
if (a == 5) {
    a = 10;
}
if (a == 10) {
    a = 5;
}
and this
pawn Код:
new a = 5;
if (a == 5) {
    a = 10;
}
else if (a == 10) {
    a = 5;
}
? That's the cause of your problem OP
So you mean i have to do that?

PHP код:
if(PrisonTime[i] == 0)
                {
                    
PrisonTime[i] = 1;
                    new 
string[256];
                    
format(stringsizeof(string), "TIME LEFT: %d"PrisonTime[i]);
                    
GameTextForPlayer(istring30004);
                    
PrisonTime[i] = 0;
                    
SpawnPlayer(i);
                    
SendClientMessage(i, -1"Testiiiiiing");
                }
                else if(
PrisonTime[i] == 0)
                {
                    new 
string[256];
                    
SetPlayerInterior(i3);
                    
SetPlayerPos(i231.1111146.70391003.0234);
                    
SetPlayerFacingAngle(i272.8459);
                    
SetCameraBehindPlayer(i);
                    
PD[i] = 1;
                    
PrisonTime[i] = 2;
                    
SpawnPlayer(i);
                    
SendClientMessage(iGREY"|_| San Andreas Police Dept. |_|");
                    
SendClientMessage(iWHITE"You are free to go. Just don't get into trouble.");
                    
format(stringsizeof(string), "%s[ID:%d] has been released from prison."namei);
                    
Announce(string);
                    
SetPlayerHealth(i,100);
                    
SetPlayerJailed(ifalse);
                    
SetPlayerPrisonTime(i0);
                } 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)