Death Gift

amxx Death Gift 2.1.1

Нет прав для скачивания
Установка
  1. Скопируйте файлы .inc в директорию: amxmodx/scripting/include/
  2. Скомпилируйте плагины (инструкция).
  3. Скопируйте скомпилированные файлы .amxx в директорию: amxmodx/plugins/
  4. Скопируйте словарь плагина .ini в директорию amxmodx/data/lang/
  5. Скопируйте файл настроек .cfg и .ini в директорию /amxmodx/configs
  6. Раскомментируйте нужные плагины в amxmodx/configs/plugins-dgift.ini
Настройки
Квары
Файл amxmodx/configs/plugins/DeathGift/Main.cfg.

DG_DropRarity
  • Шанс выпадения подарка при смерти
  • По умолчанию: 0.1
DG_LifeTime
  • Время "жизни" подарка
  • По умолчанию: 15
DG_Money_Min
  • Минимальное кол-во денег, которое может выпасть из подарка
  • По умолчанию: 500
DG_Money_Max
  • Максимальное кол-во денег, которое может выпасть из подарка
  • По умолчанию: 5000
DG_SoundVolume
  • Громкость звука подбирания подарка
  • По умолчанию: 0.8

Настройка содержимого

Для более гибкой настройки содержимого подарков, надо включить плагин DG_MoreBonuses.amxx.
Также, для добавления некоторых бонусов, нужен плагин DG_MoreFuncs.amxx, либо Ваш собственный плагин, регистрирующий новые бонусы.

Файл: amxmodx/configs/plugins/DeathGift/Gifts.json.

Пример
JSON:
[
    {
        "Name": "Смерть",
        "Chance": 1,
        "Bonus": "Kill"
    },
    {
        "Name": "Тряску экрана",
        "Chance": 15,
        "Bonus": "ScreenShake",
        "Params": {
            "Amplitude": 10,
            "Duration": 3,
            "Frequency": 3
        }
    },
    {
        "Name": "Красный экран",
        "Chance": 20,
        "Bonus": "ScreenFade",
        "Params": {
            "Duration": 5,
            "HoldTime": 3,
            "Green": 0,
            "Blue": 0,
            "Alpha": 127
        }
    }
]
Структура файла
Файл содержит в себе JSON-массив, состоящий из обьектов подарков, поля которых описаны в таблице ниже.

Поле​
Тип данных​
Описание​
Name
Строка​
Название подарка, выводимое в чате​
Chance
Ц.Число​
Шанс выпадения​
Bonus
Строка​
Название бонуса​
Params
Обьект​
Массив параметров бонуса​

Как работает шанс выпадения
Для определения, какой подарок должен подняться, складываются шансы всех подарков и берётся случайное число от единицы до суммы шансов. После чего, из полученного числа вычитаются шансы в том же порядке. На каком подарке число стало меньше нуля, тот подарок и выпадает.

Доступные бонусы для подарков
API
C++:
/**
* Called before pick up gift
*
* @param UserId        Player index
* @param GiftId        Gift entity index
*
* @return        DG_CONTINUE to continue issuing a standard gift
*                 DG_STOP to cancel the results of standard gift
*/
forward DG_OnGiftTouch_Pre(const UserId, const GiftId);

/**
* Called after pick up gift
*
* @param UserId        Player index
* @param GiftId        Gift entity index
*
* @noreturn
*/
forward DG_OnGiftTouch_Post(const UserId, const GiftId);

/**
* Called before create gift entity
*
* @param UserId        Killed player index
*
* @return        DG_CONTINUE to proceed with the creation of entity
*                 DG_STOP to cancel the creation of entity
*/
forward DG_OnGiftCreate_Pre(const UserId);

/**
* Called after create gift entity
*
* @param GiftId        Gift entity index
*
* @noreturn
*/
forward DG_OnGiftCreate_Post(const GiftId);

/**
* Sends a message about raising a gift
*
* @param UserId        ID of the player who raised the gift
* @param GiftName[]    what the player picked up (for Example: if str = "123", it Will be like this: you picked up a gift and got 123). If the string is empty it will be written that the gift is empty
*
* @noreturn
*/
native DG_SendGiftMsg(const UserId, const GiftName[] = "");


// ============ [ More Bonuses ] ================== //


enum DG_ParamType{
    ptInteger = 1,
    ptFloat,
    ptString,
    ptBool,
}

/**
* Called when plugin more bonusees initialed
*
* @noreturn
*/
forward DG_OnBonusesInit();

/**
* Register bonus for gifts
*
* @note Callback function: @func(const UserId, const Trie:Params);
*
*
* @param Name         Name of bonus
* @param Callback     Name of callback function
* @param ...         Names of params
*
* @return 1 on success, 0 otherwise
*/
native DG_RegisterBonus(const Name[], const Callback[], any:...);

/**
* Get bonus param as integer
*
* @param Params     Array of params
* @param Key        Param`s key
* @param Default     Default value
*
* @return Integer value
*/
stock DG_ReadParamInt(const Trie:Params, const Key[], const Default = 0){
    new Val = Default;
    if(!TrieKeyExists(Params, Key))
        return Val;
    TrieGetCell(Params, Key, Val);
    return Val;
}

/**
* Get bonus param as float
*
* @param Params     Array of params
* @param Key        Param`s key
* @param Default     Default value
*
* @return Float value
*/
stock Float:DG_ReadParamFloat(const Trie:Params, const Key[], const Float:Default = 0.0){
    new Float:Val = Default;
    if(!TrieKeyExists(Params, Key))
        return Default;
    TrieGetCell(Params, Key, Val);
    return Val;
}

/**
* Get bonus param as boolean
*
* @param Params     Array of params
* @param Key        Param`s key
* @param Default     Default value
*
* @return Boolean value
*/
stock bool:DG_ReadParamBool(const Trie:Params, const Key[], const bool:Default = false){
    new bool:Val = Default;
    if(!TrieKeyExists(Params, Key))
        return Val;
    TrieGetCell(Params, Key, Val);
    return Val;
}

/**
* Get bonus param as string
*
* @param Params     Array of params
* @param Key        Param`s key
* @param Buff       Buffer for write value
* @param Len        Length of buffer
* @param Default     Default value
*
* @return Number of cells written
*/
stock DG_ReadParamString(const Trie:Params, const Key[], Buff[], Len, const Default[] = ""){
    new Size = formatex(Buff, Len, Default);
    if(!TrieKeyExists(Params, Key))
        return Size;
    TrieGetString(Params, Key, Buff, Len, Size);
    return Size;
}
Сверху Снизу