amxmodx/scripting/include/
amxmodx/plugins/
amxmodx/data/lang/
/amxmodx/configs
amxmodx/configs/plugins-dgift.ini
amxmodx/configs/plugins/DeathGift/Main.cfg
.DG_DropRarity
DG_LifeTime
DG_Money_Min
DG_Money_Max
DG_SoundVolume
DG_MoreBonuses.amxx
.DG_MoreFuncs.amxx
, либо Ваш собственный плагин, регистрирующий новые бонусы.amxmodx/configs/plugins/DeathGift/Gifts.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
}
}
]
Поле | Тип данных | Описание |
---|---|---|
Name | Строка | Название подарка, выводимое в чате |
Chance | Ц.Число | Шанс выпадения |
Bonus | Строка | Название бонуса |
Params | Обьект | Массив параметров бонуса |
/**
* 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;
}