Automatic Jail
#1

so yeah i made jail and unjail command for some reasons i'm making when player disconnects
and join again with Jailed = 1 he/she will get jailed but the problem is when he/she spawn
OnPlayerRequestClass the jail time is ended. so thats the problem...

Code:

pawn Код:
public OnPlayerRequestSpawn(playerid)
{
    if(PlayerInfo[playerid][pJail] == 0)
    {
       new str[128];
       new pname[MAX_PLAYER_NAME],time;
       GetPlayerName(playerid, pname,MAX_PLAYER_NAME);
       format(str, sizeof(str), "%s has been autojailed <Reason: Jailed Evading>",pname);
       SendClientMessageToAll(COLOR_RED, str);
       SendClientMessage(playerid,COLOR_RED,"You cannot evade escaping from Jailed. You have been automatic jailed");
       SetPlayerInterior(playerid, 3);
       SetPlayerPos(playerid, 198.5319,162.3093,1003.0300);
       SetTimerEx("UnjailTime", time*1000, 0, "%d", playerid);
    }
    return 1;
}
pawn Код:
public UnjailTime(playerid)
{
    new string[256];
    new playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playername, sizeof(playername));
    if(IsPlayerConnected(playerid))
    SetPlayerInterior(playerid, 0);
    SpawnPlayer(playerid);
    PlayerInfo[playerid][pJail] = 0;
    format(string, sizeof(string), "%s has been unjailed <Reason: Time Ended>", playername);
    SendClientMessageToAll(COLOR_GREEN, string);
    return 1;
}
pawn Код:
CMD:jail(playerid, params[])
{
    new pid, time;
    new adminname[MAX_PLAYER_NAME], playername[MAX_PLAYER_NAME];
    GetPlayerName(pid, playername, sizeof(playername));
    GetPlayerName(playerid, adminname, sizeof(adminname));
    if(PlayerInfo[playerid][pAdmin] >= 2)
    {
        if(sscanf(params, "udz", pid, time, params[2])) return SendClientMessage(playerid,COLOR_RED, "USAGE: /jail <playername/id> <time> <reason>");
        if(PlayerInfo[playerid][pAdmin] < PlayerInfo[pid][pAdmin]) return SendClientMessage(playerid,COLOR_RED, "ERROR: You cant jail higher rank administrators");
        if(pid == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_RED, "ERROR: Player is not connected!");
        if(PlayerInfo[pid][pJail] == 0)
        {
           new string[128];
           format(string, sizeof(string), "Administator %s has jailed %s for %d seconds <Reason: %s>", adminname,playername,time,params[2]);
           SendClientMessageToAll(COLOR_RED, string);
           format(string, sizeof(string), "Administator %s has jailed you for %d seconds <Reason: %s>", adminname,time,params[2]);
           SendClientMessage(pid,COLOR_RED, string);
           format(string, sizeof(string), "You jailed %s for %d seconds <Reason: %s>",playername, time, params[2]);
           SendClientMessage(playerid,COLOR_RED, string);
           TogglePlayerControllable(pid, 1);
           SetPlayerInterior(pid, 3);
           SetPlayerPos(pid, 198.5319,162.3093,1003.0300);
           SetTimerEx("UnjailTime", time*1000, 0, "%d", pid);
           PlayerInfo[pid][pJail] = 1;
        }
        else return SendClientMessage(playerid,COLOR_RED, "ERROR: Player is already jailed!");
    }
    else return SendClientMessage(playerid,COLOR_RED, "ERROR: You must be Administrar Level 2 to use this command");
    return 1;
}

CMD:unjail(playerid, params[])
{
    new pid,reason[128];
    new adminname[MAX_PLAYER_NAME];
    new pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid,adminname,MAX_PLAYER_NAME);
    GetPlayerName(pid,pname,MAX_PLAYER_NAME);
    if(PlayerInfo[playerid][pAdmin] >= 2)
    {
        if(sscanf(params, "uz", pid, reason)) return SendClientMessage(playerid,COLOR_RED, "USAGE: /unjail <playername/id> <reason>");
        if(PlayerInfo[playerid][pAdmin] < PlayerInfo[pid][pAdmin]) return SendClientMessage(playerid,COLOR_RED, "ERROR: You cant unjail higher rank administrators");
        if(pid == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_RED, "ERROR: Player is not connected!");
        if(PlayerInfo[pid][pJail] == 1)
        {
           new string[128];
           format(string, sizeof(string), "Administator %s has unjail %s <Reason: %s>", adminname,pname,reason[2]);
           SendClientMessageToAll(COLOR_RED, string);
           format(string, sizeof(string), "Administator %s has unjail you <Reason: %s>", adminname,reason);
           SendClientMessage(pid,COLOR_GREEN, string);
           format(string, sizeof(string), "You unjail %s <Reason: %s>",pname,reason[2]);
           SendClientMessage(playerid,COLOR_GREEN, string);
           TogglePlayerControllable(pid, 1);
           SetPlayerInterior(pid, 0);
           SpawnPlayer(pid);
           PlayerInfo[pid][pJail] = 0;
        }
        else return SendClientMessage(playerid,COLOR_RED,"ERROR: This Player is already unjail");
    }
    else return SendClientMessage(playerid,COLOR_RED,"ERROR: You must be Administrator Level 2 to use this command");
    return 1;
}
Please help

UPDATE: even i turn it to the right value it still the same. and also i want to add that Jail Time = %s for the Jailed = 1 so if i edit the scriptfiles of players and turn it to 1 and the timer the player would not be buggy. but whats the problem?
Reply
#2

Код:
public OnPlayerRequestSpawn(playerid)
{
    if(PlayerInfo[playerid][pJail] == 1)   <--------- not 0 but 1 !!!
     {
       new str[128];
       new pname[MAX_PLAYER_NAME],time;
       GetPlayerName(playerid, pname,MAX_PLAYER_NAME);
       format(str, sizeof(str), "%s has been autojailed <Reason: Jailed Evading>",pname);
       SendClientMessageToAll(COLOR_RED, str);
       SendClientMessage(playerid,COLOR_RED,"You cannot evade escaping from Jailed. You have been automatic jailed");
       SetPlayerInterior(playerid, 3);
       SetPlayerPos(playerid, 198.5319,162.3093,1003.0300);
       SetTimerEx("UnjailTime", time*1000, 0, "%d", playerid);
       PlayerInfo[pid][pJail] = 1;  <--------------- ADD THIS
    }
    return 1;
}
Reply
#3

Didnt work
Reply
#4

oh i see the problem...


change public OnPlayerRequestSpawn(playerid)
{

to

public OnPlayerSpawn(playerid)
{
Reply
#5

Nice try hot shot but it gives me forever jail
Reply
#6

pawn Код:
if(PlayerInfo[playerid][pJail] == 1)
0 will just jail innocent people.
Reply
#7

Quote:
Originally Posted by GAMER_PS2
Посмотреть сообщение
Nice try hot shot but it gives me forever jail
What? Wtf are you talking about ?


public OnPlayerRequestSpawn(playerid)
{

will not do anything.... it will not put the person in jail


public OnPlayerSpawn(playerid)
{

will
Reply
#8

OMG it works but the problem now is the unjail i set the jail time to 50 but when i restart it again and spawn the unjail system say "%s has unjail <Reason: Time Ended" WTF
Reply
#9

We don't have the fucking spawn code, what are we mind readers? Post the callback.
Reply
#10

i'm using admin system

my gamemode code:

pawn Код:
public OnPlayerSpawn(playerid)
{
   GangZoneShowForPlayer(playerid, BallasZone, -2147418167);
   GangZoneShowForPlayer(playerid, BallasZone2, -2147418167);
   GangZoneShowForPlayer(playerid, GroveZone, 16711888);
   GangZoneShowForPlayer(playerid, GroveZone2, 16711888);
   GangZoneShowForPlayer(playerid, VagosZone, -65332);
   GangZoneShowForPlayer(playerid, VagosZone2, -65332);
   GangZoneShowForPlayer(playerid, VagosZone3, -65332);
   GangZoneShowForPlayer(playerid, AztecasZone, 1538909898);

//============================================================================//

   TextDrawHideForPlayer(playerid, BallasTittle);
   TextDrawHideForPlayer(playerid, BallasWeap1);
   TextDrawHideForPlayer(playerid, BallasWeap2);
   TextDrawHideForPlayer(playerid, BallasWeap3);
   TextDrawHideForPlayer(playerid, BallasWeap4);
   TextDrawHideForPlayer(playerid, GroveTittle);
   TextDrawHideForPlayer(playerid, GroveWeap1);
   TextDrawHideForPlayer(playerid, GroveWeap2);
   TextDrawHideForPlayer(playerid, GroveWeap3);
   TextDrawHideForPlayer(playerid, GroveWeap4);
   TextDrawHideForPlayer(playerid, VagosTittle);
   TextDrawHideForPlayer(playerid, VagosWeap1);
   TextDrawHideForPlayer(playerid, VagosWeap2);
   TextDrawHideForPlayer(playerid, VagosWeap3);
   TextDrawHideForPlayer(playerid, VagosWeap4);
   
//============================================================================//
   
   SetPlayerMapIcon(playerid,0,1914.0652,-1731.5297,13.4226,19,1,MAPICON_LOCAL); //Ballas Mapicon

//============================================================================//

   SetPlayerArmour(playerid, 100);
   SetPlayerHealth(playerid, 100);
   SetCameraBehindPlayer(playerid);
   GivePlayerWeapon(playerid, 5,1);
   SetPVarInt(playerid, "AFK", 0);
   SetPlayerVirtualWorld(playerid,0);
   PlayerPlaySound(playerid, 1186,-119.9460,23.1096,12.2238);
   return 1;
}
and the code of my admin system spawn

pawn Код:
public OnPlayerRequestSpawn(playerid)
{
    if(PlayerInfo[playerid][pJail] == 1)
    {
       new str[128];
       new pname[MAX_PLAYER_NAME],time;
       GetPlayerName(playerid, pname,MAX_PLAYER_NAME);
       format(str, sizeof(str), "%s has been autojailed <Reason: Jailed Evading>",pname);
       SendClientMessageToAll(COLOR_RED, str);
       SendClientMessage(playerid,COLOR_RED,"You cannot evade escaping from Jailed. You have been automatic jailed");
       SetPlayerInterior(playerid, 3);
       SetPlayerPos(playerid, 198.5319,162.3093,1003.0300);
       SetTimerEx("UnjailTime", time*1000, 0, "%d", playerid);
       PlayerInfo[playerid][pJail] = 1;
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)