SA-MP Forums Archive
Jail help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Jail help (/showthread.php?tid=456336)



Jail help - Sliceofdeath - 05.08.2013

When i try to jail someone , He is jailed..But the problem is when the jailed user get killed by someone he is spawned in spawns where i have made .. Why he is not spawned in Prison again ? Can anyone help ?


Re: Jail help - dannyk0ed - 05.08.2013

Make If statement under onplayerdeath to spawn the player in the prison when they are killed. SetPlayerPos


Re: Jail help - George_Fratelli - 05.08.2013

You need to make it so when a player dies, it checks if he's jailed. If he is it'll send him back to jail.

For example

pawn Код:
if(pInfo[playerid][pJailed] == 1)
{
      SetPlayerPos(playerid, "Jail pos");
}



Re: Jail help - Sliceofdeath - 05.08.2013

It is something like this

Quote:

dcmd_jail(playerid,params[])
{
if(AccInfo[playerid][LoggedIn] == 1)
{
if(AccInfo[playerid][Level] >= 3)
{
new Index;
new tmp[256]; tmp = strtok(params,Index);
new tmp2[256]; tmp2 = strtok(params,Index);
new tmp3[256]; tmp3 = strtok(params,Index);

if(!strlen(params)) return
SendClientMessage(playerid, LIGHTBLUE2, "Usage: /jail [PlayerID] [Minutes] [Reason]") &&
SendClientMessage(playerid, orange, "Function: Will Jailed the specified player");
new player1, playername[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], string[128];
player1 = strval(tmp);

if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && (AccInfo[player1][Level] != ServerInfo[MaxAdminLevel]))
{
if(AccInfo[player1][Jailed] == 0)
{
GetPlayerName(player1, playername, sizeof(playername));
GetPlayerName(playerid, adminname, sizeof(adminname));
new jtime = strval(tmp2);
if(jtime == 0) jtime = 9999;

SendCommandToAdmins(playerid,"Jail");
AccInfo[player1][JailTime] = jtime*1000*60;
SetTimerEx("JailPlayer",5000,0,"d",player1);
SetTimerEx("Jail1",1000,0,"d",player1);
AccInfo[player1][Jailed] = 1;

if(jtime == 9999)
{
if(!strlen(params[strlen(tmp2)+1])) format(string,sizeof(string),"|- Administrator %s has Jailed %s -|",adminname,playername);
else format(string,sizeof(string),"|- Administrator %s has Jailed %s | Reason: %s -|",adminname,playername,params[strlen(tmp)+1]);
}
else
{
if(!strlen(tmp3)) format(string,sizeof(string),"|- Administrator %s has Jailed %s for %d Minutes -|",adminname,playername, jtime);
else format(string,sizeof(string),"|- Administrator %s has Jailed %s for %d Minutes | Reason: %s -|",adminname,playername,jtime,params[strlen(tmp2)+strlen(tmp)+1]);
}
return SendClientMessageToAll(blue,string);
}
else return SendClientMessage(playerid, red, "ERROR: Player is already in jail");
}
else return SendClientMessage(playerid, red, "ERROR: Player is not connected or is the highest level admin");
}
else return ErrorMessages(playerid, 1);
}
else return SendClientMessage(playerid,red,"ERROR: You must be logged in to use this commands");
}




Re: Jail help - SKAzini - 05.08.2013

OnPlayerDeath:

pawn Код:
if(AccInfo[playerid][Jailed] == 1)
{
    //your code which teleports the player to jail.
}



Re: Jail help - Sliceofdeath - 05.08.2013

Quote:
Originally Posted by SKAzini
Посмотреть сообщение
OnPlayerDeath:

pawn Код:
if(AccInfo[playerid][Jailed] == 1)
{
    //your code which teleports the player to jail.
}
There is no OnPlayerDeath , Where to add it ?


Re: Jail help - Blast3r - 05.08.2013

Quote:
Originally Posted by Sliceofdeath
Посмотреть сообщение
There is no OnPlayerDeath , Where to add it ?
Are you sure? There should be "Public OnPlayerDeath"... Unless you deleted it.


Re: Jail help - Sliceofdeath - 05.08.2013

Quote:
Originally Posted by Blast3r
Посмотреть сообщение
Are you sure? There should be "Public OnPlayerDeath"... Unless you deleted it.
Yeh i already posted my jail script.

Quote:

dcmd_jail(playerid,params[])
{
if(AccInfo[playerid][LoggedIn] == 1)
{
if(AccInfo[playerid][Level] >= 3)
{
new Index;
new tmp[256]; tmp = strtok(params,Index);
new tmp2[256]; tmp2 = strtok(params,Index);
new tmp3[256]; tmp3 = strtok(params,Index);

if(!strlen(params)) return
SendClientMessage(playerid, LIGHTBLUE2, "Usage: /jail [PlayerID] [Minutes] [Reason]") &&
SendClientMessage(playerid, orange, "Function: Will Jailed the specified player");
new player1, playername[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], string[128];
player1 = strval(tmp);

if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && (AccInfo[player1][Level] != ServerInfo[MaxAdminLevel]))
{
if(AccInfo[player1][Jailed] == 0)
{
GetPlayerName(player1, playername, sizeof(playername));
GetPlayerName(playerid, adminname, sizeof(adminname));
new jtime = strval(tmp2);
if(jtime == 0) jtime = 9999;

SendCommandToAdmins(playerid,"Jail");
AccInfo[player1][JailTime] = jtime*1000*60;
SetTimerEx("JailPlayer",5000,0,"d",player1);
SetTimerEx("Jail1",1000,0,"d",player1);
AccInfo[player1][Jailed] = 1;

if(jtime == 9999)
{
if(!strlen(params[strlen(tmp2)+1])) format(string,sizeof(string),"|- Administrator %s has Jailed %s -|",adminname,playername);
else format(string,sizeof(string),"|- Administrator %s has Jailed %s | Reason: %s -|",adminname,playername,params[strlen(tmp)+1]);
}
else
{
if(!strlen(tmp3)) format(string,sizeof(string),"|- Administrator %s has Jailed %s for %d Minutes -|",adminname,playername, jtime);
else format(string,sizeof(string),"|- Administrator %s has Jailed %s for %d Minutes | Reason: %s -|",adminname,playername,jtime,params[strlen(tmp2)+strlen(tmp)+1]);
}
return SendClientMessageToAll(blue,string);
}
else return SendClientMessage(playerid, red, "ERROR: Player is already in jail");
}
else return SendClientMessage(playerid, red, "ERROR: Player is not connected or is the highest level admin");
}
else return ErrorMessages(playerid, 1);
}
else return SendClientMessage(playerid,red,"ERROR: You must be logged in to use this commands");
}




Re: Jail help - Blast3r - 05.08.2013

Quote:
Originally Posted by Sliceofdeath
Посмотреть сообщение
Yeh i already posted my jail script.
No the OnPlayerDeath isn't located on the script, it's located into the gamemode, use CTRL+F and then try to find it.

EDIT: Yeah, my bad, use "OnPlayerSpawn" not "OnPlayerDeath"


Re : Jail help - Matnix - 05.08.2013

Or you can simply,
pawn Код:
public OnPlayerSpawn(playerid)
{
    if(AccInfo[playerid][Jailed] == 1)
    {
        SetPlayerPos(playerid, X,Y,Z) // your jail spawn
    }
    return 1;
}



Re: Jail help - Konstantinos - 05.08.2013

You cannot set players' position when they die. Use OnPlayerSpawn instead; check if they're jailed and spawn them back to the jail.


Re: Jail help - Sliceofdeath - 05.08.2013

Bump..


Re: Jail help - Sliceofdeath - 05.08.2013

Can you help me in making these things in my jail system ?

If he/she is jailed she can't use any command like /kill /goto player or teleport command.

or can you add HP to unlimited , That he/she never dies.

here is my script

pawn Code:
dcmd_jail(playerid,params[])
{
    if(AccInfo[playerid][LoggedIn] == 1)
    {
        if(AccInfo[playerid][Level] >= 3)
        {
            new Index;
            new tmp[256];  tmp  = strtok(params,Index);
            new tmp2[256]; tmp2 = strtok(params,Index);
            new tmp3[256]; tmp3 = strtok(params,Index);

            if(!strlen(params)) return
            SendClientMessage(playerid, LIGHTBLUE2, "Usage: /jail [PlayerID] [Minutes] [Reason]") &&
            SendClientMessage(playerid, orange, "Function: Will Jailed the specified player");
            new player1, playername[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], string[128];
            player1 = strval(tmp);

            if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && (AccInfo[player1][Level] != ServerInfo[MaxAdminLevel]))
             {
                if(AccInfo[player1][Jailed] == 0)
                {
                    GetPlayerName(player1, playername, sizeof(playername));
                    GetPlayerName(playerid, adminname, sizeof(adminname));
                    new jtime = strval(tmp2);
                    if(jtime == 0) jtime = 9999;

                    SendCommandToAdmins(playerid,"Jail");
                    AccInfo[player1][JailTime] = jtime*1000*60;
                    SetTimerEx("JailPlayer",5000,0,"d",player1);
                    SetTimerEx("Jail1",1000,0,"d",player1);
                    AccInfo[player1][Jailed] = 1;

                    if(jtime == 9999)
                    {
                    if(!strlen(params[strlen(tmp2)+1])) format(string,sizeof(string),"|- Administrator %s has Jailed %s -|",adminname,playername);
                    else format(string,sizeof(string),"|- Administrator %s has Jailed %s | Reason: %s -|",adminname,playername,params[strlen(tmp)+1]);
                    }
                    else
                    {
                    if(!strlen(tmp3)) format(string,sizeof(string),"|- Administrator %s has Jailed %s for %d Minutes -|",adminname,playername, jtime);
                    else format(string,sizeof(string),"|- Administrator %s has Jailed %s for %d Minutes | Reason: %s -|",adminname,playername,jtime,params[strlen(tmp2)+strlen(tmp)+1]);
                    }
                    return SendClientMessageToAll(blue,string);
                }
                else return SendClientMessage(playerid, red, "ERROR: Player is already in jail");
            }
            else return SendClientMessage(playerid, red, "ERROR: Player is not connected or is the highest level admin");
        }
        else return ErrorMessages(playerid, 1);
    }
    else return SendClientMessage(playerid,red,"ERROR: You must be logged in to use this commands");
}

dcmd_unjail(playerid,params[])
{
    if(AccInfo[playerid][LoggedIn] == 1)
    {
        if(AccInfo[playerid][Level] >= 3)
        {
            new tmp[256];
            new Index;
            tmp = strtok(params,Index);
           
            if(!strlen(params)) return
            SendClientMessage(playerid, LIGHTBLUE2, "Usage: /unjail [PlayerID]") &&
            SendClientMessage(playerid, orange, "Function: Will Unjailed the specified player");
            new player1;
            new string[128];
            new playername[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME];
            player1 = strval(tmp);

            if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && (AccInfo[player1][Level] != ServerInfo[MaxAdminLevel]))
             {
                if(AccInfo[player1][Jailed] == 1)
                {
                    GetPlayerName(player1, playername, sizeof(playername));
                    GetPlayerName(playerid, adminname, sizeof(adminname));
                    format(string,sizeof(string),"|- Administrator %s has Unjailed you -|",adminname);
                    SendClientMessage(player1,blue,string);
                    format(string,sizeof(string),"|- Administrator %s has Unjailed %s -|",adminname, playername);
                    UnjailPlayer(player1);
                    return SendClientMessageToAll(blue,string);
                }
                else return SendClientMessage(playerid, red, "ERROR: Player is not in jail");
            }
            else return SendClientMessage(playerid, red, "ERROR: Player is not connected or is the highest level admin");
        }
        else return ErrorMessages(playerid, 1);
    }
    else return SendClientMessage(playerid,red,"ERROR: You must be logged in to use this commands");
}
Thank you.


Re: Jail help - Sliceofdeath - 05.08.2013

OMG c'mon help me guys

Atleast by telling how to set player's health unlimited and commands will not work like /kill /goto etc..