samp.directory
← Scripts et bibliothèques

DevD4v3/system-jail-include

Provides an easy-to-use jail system that automatically handles player positions, interiors, and weapons

Bibliothèque★ 4mis à jour sept. 2025MITPawnArchivé
Ouvrir sur GitHub

L’auteur a archivé ce dépôt, il n’est donc plus maintenu.

L’essayer dans le compilateur Pawn →

Ajoute ses fichiers include, avec les bibliothèques dont il dépend, au compilateur Pawn de ton navigateur, prêts à être inclus dans un script.

README.md

system-jail-include

system-jail-include allows you to implement a jail system in a simple and efficient way.

This include automatically:

  • Assigns the player a default (x, y, z) position and interior.
  • Resets the player’s weapons.
  • Assigns each jailed player an independent virtual world, avoiding conflicts if multiple players are in jail at the same time.

If you don’t want to use the default jail location, you can customize it using the OnPlayerEnterJail callback.

Examples use:


Installation

  1. Copy system_jail.inc to your /pawno/include folder.
  2. Include it in your gamemode:
#include <system_jail>
  1. Make sure you have YSI-Includes in your include folder so the gamemode compiles correctly.

You can set a maximum number of jailed players (default is 10) by defining MAX_JAILED after including the library:

#include <system_jail>
#undef MAX_JAILED
#define MAX_JAILED (5)

Callbacks

  • OnPlayerEnterJail(playerid, const minutes) – called when a player enters jail.

Example:

public OnPlayerEnterJail(playerid, const minutes)
{
    printf("Player ID: %d entered jail.", playerid);
    printf("They will be released in %d minutes.", minutes);
    return 1;
}

You can detect if a player has an indefinite jail time:

public OnPlayerEnterJail(playerid, const minutes)
{
    if(minutes == NO_TIME)
    {
        printf("You have been jailed indefinitely.");
        return 1;
    }
    printf("Player ID: %d entered jail.", playerid);
    printf("They will be released in %d minutes.", minutes);
    return 1;
}

You can also set a custom jail position for a player:

public OnPlayerEnterJail(playerid, const minutes)
{
    SetPlayerPos(playerid, 2125.4805, 1584.6116, 20.3906);
    SetPlayerInterior(playerid, 0);

    if(minutes == NO_TIME)
    {
        printf("You have been jailed indefinitely.");
        return 1;
    }

    printf("Player ID: %d entered jail.", playerid);
    printf("They will be released in %d minutes.", minutes);
    return 1;
}

The player’s virtual world is automatically handled by the include.

  • OnPlayerLeaveJail(playerid) – called when a player leaves jail.

Example:

public OnPlayerLeaveJail(playerid)
{
    printf("Player ID: %d has been released from jail.", playerid);
    return 1;
}
  • OnPlayerComplyOneMinute(playerid, const minutes) – called every time a player completes one minute in jail.

Example:

public OnPlayerComplyOneMinute(playerid, const minutes)
{
    printf("Player ID: %d has %d minutes left in jail.", playerid, minutes);
    return 1;
}

Macros

  • IsPlayerInJail(playerid) – checks if a player is currently in jail.

Example:

public OnPlayerCommandReceived(playerid, cmd[], params[], flags)
{
    if(IsPlayerInJail(playerid))
    {
        printf("Player ID: %d cannot use commands.", playerid);
        return 0;
    }
    return 1;
}
  • GetUsersInJail() – returns the number of players currently in jail.

Example:

cmd:totaljail(playerid)
{
    printf("Total players in jail: %d", GetUsersInJail());
    return 1;
}
  • GetPlayerPositionInJail(playerid) – gets the position of the player in the jail queue.

Example:

cmd:position(playerid)
{
    GetPlayerPositionInJail(playerid);
    printf("Player ID: %d is at position: %d", playerid, position + 1);
    return 1;
}

The variable position is automatically declared.


Functions

  • GetPlayerTimeInJail(playerid) – returns the remaining time in seconds for the player to be released. You can also get minutes and seconds separately.

Example 1:

cmd:time(playerid)
{
    printf("You have %d seconds left in jail.", GetPlayerTimeInJail(playerid));
    return 1;
}

Example 2:

cmd:time(playerid)
{
    new minutes, seconds;
    GetPlayerTimeInJail(playerid, minutes, seconds);
    printf("Time left: %02d:%02d", minutes, seconds);
    return 1;
}
  • PutPlayerInJail(playerid, minutes = NO_TIME) – sends a player to jail. If minutes is omitted, the jail time is unlimited.

Example:

cmd:jail(playerid)
{
    PutPlayerInJail(playerid, 3); // 3 minutes
    return 1;
}

Indefinite jail:

cmd:jail(playerid)
{
    PutPlayerInJail(playerid);
    return 1;
}
  • RemovePlayerJail(playerid) – removes a player from jail.

Example:

cmd:unjail(playerid)
{
    RemovePlayerJail(playerid);
    return 1;
}
  • ShowPlayersInJail(playerid) – displays a menu with all jailed players.

Example:

cmd:encarcelados(playerid)
{
    ShowPlayersInJail(playerid);
    return 1;
}

Usage Example

#include <a_samp>
#include <Pawn.CMD>
#include <sscanf>
#include <system_jail>

public OnPlayerCommandReceived(playerid, cmd[], params[], flags)
{
    if(IsPlayerInJail(playerid))
    {
        new minutes, seconds, string[77];
        GetPlayerTimeInJail(playerid, minutes, seconds);

        if(minutes != 0)
            format(string, sizeof(string), "[Jail]: %d minutes and %d seconds left.", minutes, seconds);
        else
            format(string, sizeof(string), "[Jail]: %d seconds left.", seconds);

        SendClientMessage(playerid, -1, string);
        return 0;
    }
    return 1;
}

public OnPlayerComplyOneMinute(playerid, const minutes)
{
    new string[46];
    format(string, sizeof(string), "[Jail]: %d minutes left.", minutes);
    SendClientMessage(playerid, -1, string);
    return 1;
}

public OnPlayerEnterJail(playerid, const minutes)
{
    new string[45];
    format(string, sizeof(string), "[Jail]: You will be released in %d minutes.", minutes);
    SendClientMessage(playerid, -1, string);
    return 1;
}

public OnPlayerLeaveJail(playerid)
{
    SendClientMessage(playerid, -1, "[Jail]: You are free!");
    SpawnPlayer(playerid);
    return 1;
}

Images


Credits

  • DevD4v3 – Main developer
  • Y_Less (for y_timers, y_hooks)
  • SA-MP Team

grandgrand-theft-autogtaincludepawnsa-mpsa-mp-developmentsan-andreas-multiplayer

Cette page est construite à partir de ce que GitHub publie sur le dépôt. samp.directory n’héberge pas le code. Signaler un problème avec cette fiche

DevD4v3/system-jail-include : Bibliothèque SA-MP | samp.directory