SA-MP Forums Archive
Health in jail - 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: Health in jail (/showthread.php?tid=456509)



Health in jail - Sliceofdeath - 06.08.2013

I just edited the SetPlayerHealth , That player don't die while he is in jail.But it is not working , Player is die'in.

Here is script
+ can you help one more thing ? When player get jailed he will lost his weapons , Can you ?

pawn Код:
dcmd_jail(playerid,params[])
{
    SetPlayerHealth(playerid, 9999999);
    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[])
{
    SetPlayerHealth(playerid, 100);
    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");
}



Re: Health in jail - Konstantinos - 06.08.2013

You code above can be abusive by typing /jail and the player who typed the command will get 9999999 as health even if he's not logged in.

Use:
pawn Код:
SetPlayerHealth(player1, 9999999);
before you set the timer and:
pawn Код:
ResetPlayerWeapons(player1);



Re: Health in jail - Sliceofdeath - 06.08.2013

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
You code above can be abusive by typing /jail and the player who typed the command will get 9999999 as health even if he's not logged in.

Use:
pawn Код:
SetPlayerHealth(player1, 9999999);
before you set the timer and:
pawn Код:
ResetPlayerWeapons(player1);
So it mean i cannot set health ?


Re: Health in jail - Sliceofdeath - 06.08.2013

And it say UNDEFINED SYMBOL Reset----- and so on


Re: Health in jail - Konstantinos - 06.08.2013

Of course you can. You just set the health on the player who typed the command and before check if he's logged in, the correct level and so on.


Re: Health in jail - TheCrescendo - 06.08.2013

Quote:
Originally Posted by Sliceofdeath
Посмотреть сообщение
So it mean i cannot set health ?
You can set health, but what you did here is, you made the player who types /jail get infinite hp, try to do it with player1/targetid, so the targeted player gets it. x)


Re: Health in jail - TheCrescendo - 06.08.2013

Just place SetPlayerHealth(player1, 9999999); under the line where it jails him. :3 Not on the top.


Re: Health in jail - Sliceofdeath - 06.08.2013

Can u help me guys ?

I am newbie in it


Re: Health in jail - Sliceofdeath - 06.08.2013

Anyone ?