[APS] Core

reapi core gmx [APS] Core 0.1.84-alpha

Нет прав для скачивания
Установка
  1. Скопируйте файлы согласно директориям
  2. Откройте aps_core.sma и скомпилируйте плагин (инструкция).
  3. Скопируйте скомпилированный aps_core.amxx в директорию "addons/amxmodx/plugins".
  4. Раскомментируйте aps_core.amxx в /amxmodx/configs/plugins-aps.ini
Настройки
Отсутствуют
API
Код:
#if defined _aps_included
    #endinput
#endif

#define _aps_included

#include <reapi>
#include <gmx>
#include <aps_consts>
#include <aps_stocks>
#include <aps_version>

enum APS_Type {
    APS_InvalidType = -1,
};

forward APS_Initing();
forward APS_Inited();
forward APS_PlayerPunishing(const id, const APS_Type:type);
forward APS_PlayerPunished(const id, const APS_Type:type);
forward APS_PlayerAmnestying(const id, const APS_Type:type);
forward APS_PlayerAmnestied(const id, const APS_Type:type);
forward APS_PlayerChecking(const id);
forward APS_PlayerChecked(const id);

native APS_Type:APS_RegisterType(const name[]);
native bool:APS_IsValidType(const APS_Type:type);
native APS_GetTypesNum();
native APS_Type:APS_GetTypeIndex(const name[]);
native APS_GetTypeName(const APS_Type:index, value[], len);
native bool:APS_PunishPlayer(const player, const APS_Type:type, const time, const reason[], const details[] = "", const punisherId = 0, const extra = 0);
native bool:APS_AmnestyPlayer(const player, const APS_Type:type);
native bool:APS_GetPlayerPunishment(const player, const APS_Type:type);
native APS_GetId();
native APS_GetExtra();
native APS_SetExtra(const value);
native APS_GetTime();
native APS_SetTime(const value);
native APS_GetCreated();
native APS_SetCreated(const value);
native APS_GetExpired();
native APS_SetExpired(const value);
native APS_GetReason(value[], const len);
native APS_SetReason(const value[]);
native APS_GetDetails(value[], const len);
native APS_SetDetails(const value[]);
native APS_PunisherType:APS_GetPunisherType();
native APS_SetPunisherType(const APS_PunisherType:value);
native APS_GetPunisherId();
native APS_SetPunisherId(const value);
/*
* This is callback from APS Core that gives major/minor versions for verifying compatibility for APS versions.
* Do not modify this!
*/
public __aps_version_check(const majorVersion, const minorVersion) {
    if(majorVersion != APS_MAJOR_VERSION) {
        set_fail_state("Api major version mismatch; expected %d, real %d", APS_MAJOR_VERSION, majorVersion);
        return;
    }

    if(minorVersion < APS_MINOR_VERSION){
        set_fail_state("Api minor version mismatch; expected at least %d, real %d", APS_MINOR_VERSION, minorVersion);
        return;
    }
}
Код:
#if defined _aps_consts_included
    #endinput
#endif
#define _aps_consts_included

#define APS_MAX_TYPE_LENGTH 32
#define APS_MAX_REASON_LENGTH 64
#define APS_MAX_DETAILS_LENGTH 64

const MAX_PUNISH_DESC_LENGTH = 64;

enum APS_PunisherType {
    APS_PunisherTypePlayer,
    APS_PunisherTypeUser,
    APS_PunisherTypeServer
};

enum APS_PunishmentStatus {
    APS_PunishmentStatusActive,
    APS_PunishmentStatusExpired,
    APS_PunishmentStatusAmnestied
};

enum (<<=1) {
    APS_CheckAccess = 1 << 0,
    APS_CheckImmunityLevel
};
Код:
#if defined _aps_stocks_included
    #endinput
#endif

#define _aps_stocks_included

#define CHECK_NATIVE_ARGS_NUM(%1,%2,%3) \
    if (%1 < %2) { \
        log_error(AMX_ERR_NATIVE, "Invalid num of arguments %d. Expected %d", %1, %2); \
        return %3; \
    }

#define CHECK_NATIVE_PLAYER(%1,%2) \
    if (!is_user_connected(%1)) { \
        log_error(AMX_ERR_NATIVE, "Invalid player %d", %1); \
        return %2; \
    }

stock APS_FindPlayerByTarget(const buffer[]) {
    if (buffer[0] == '#' && buffer[1]) {
        return find_player_ex(FindPlayer_MatchUserId, str_to_num(buffer[1]));
    }

    new result = find_player_ex(FindPlayer_MatchAuthId, buffer);
    if (!result) {
        result = find_player_ex(FindPlayer_MatchIP, buffer);
    }

    if (!result) {
        result = find_player_ex(FindPlayer_MatchNameSubstring | FindPlayer_CaseInsensitive|  FindPlayer_LastMatched, buffer);
    }

    return result;
}

stock bool:APS_CanUserPunish(const index, target = 0, access = 0, checks = 0) {
    new bitsum;
    if (access && (checks & APS_CheckAccess)) {
        if ((get_user_flags(index) & access) == access) {
            bitsum |= APS_CheckAccess;       
        }
    }

    if (target && (checks & APS_CheckImmunityLevel)) {
        if (GMX_PlayerGetImmunity(index) > GMX_PlayerGetImmunity(target)) {
            bitsum |= APS_CheckImmunityLevel;
        }
    }
  
    return bool:((bitsum & checks) == checks);
}
Код:
#if defined _aps_version_included
    #endinput
#endif

#define _aps_version_included

#define APS_MAJOR_VERSION       0
#define APS_MINOR_VERSION       1
#define APS_MAINTENANCE_VERSION 83
#define APS_VERSION_STR         "0.1.83-alpha"
Сверху Снизу