Skip to content

Commit

Permalink
Some fixes & optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
ArKaNeMaN committed Mar 9, 2019
1 parent 539b322 commit 44457cb
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 33 deletions.
16 changes: 8 additions & 8 deletions DeathGift.sma
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

#define PDATA_SAFE 2

#define MODEL_PATH "models/awDeathGift/gift.mdl"
#define TAKE_SOUND "awDeathGift/take.wav"
new const MODEL_PATH[] = "models/awDeathGift/gift.mdl";
new const TAKE_SOUND[] = "awDeathGift/take.wav";
#define SOUND_VOL 0.8
#define CHAT_PREFIX "DeathGift"
new const CHAT_PREFIX[] = "DeathGift";
#define FLY_SPEED 5.0
#define ROTATE_SPEED 5.0
#define THINK_DELAY 1.0
Expand Down Expand Up @@ -47,11 +47,12 @@ new Float:dropRarity;
new giftLifeTime;
new giftMoney[minMax];

#define PLUG_VER "1.2.1"
#define PLUG_NAME "DeathGift"
new const PLUG_VER[] = "1.2.1";
new const PLUG_NAME[] = "DeathGift";

public plugin_init(){
register_dictionary("awDeathGift.txt");
cfgExec();
RegisterHam(Ham_Killed, "player", "pDeath", false);
register_think("gift", "giftThink");
register_touch("gift", "player", "giftTouch");
Expand All @@ -69,12 +70,12 @@ cfgExec(){
pCvars[cMoneyMin] = create_cvar("awDgMoneyMin", "500", FCVAR_NONE, "Минимальная сумма получаемая за подарок");
pCvars[cMoneyMax] = create_cvar("awDgMoneyMax", "5000", FCVAR_NONE, "Максимальная сумма получаемая за подарок");

AutoExecConfig(true, "Main", "DeathGift");

bind_pcvar_float(pCvars[cDropRarity], dropRarity);
bind_pcvar_num(pCvars[cLifeTime], giftLifeTime);
bind_pcvar_num(pCvars[cMoneyMin], giftMoney[mMin]);
bind_pcvar_num(pCvars[cMoneyMax], giftMoney[mMax]);

AutoExecConfig(true, "Main", "DeathGift");
}

public plugin_natives(){
Expand All @@ -83,7 +84,6 @@ public plugin_natives(){

public plugin_precache(){
register_plugin(PLUG_NAME, PLUG_VER, "ArKaNeMaN");
cfgExec();

if(file_exists(MODEL_PATH)) precache_model(MODEL_PATH);
else{
Expand Down
14 changes: 13 additions & 1 deletion amxmodx/data/lang/awDeathGift.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
[en]
GIFT_TAKE = You picked up a gift and received
GIFT_TAKE_EMPTY = You picked up an empty gift
CVAR_DROP_RARITY = Gift drop chance
CVAR_LIFE_TIME = Gift lifetime (0 - infinite)
CVAR_MONEY_MIN = Minimum amount received for a gift
CVAR_MONEY_MAX = Maximum amount received for a gift

[ru]
GIFT_TAKE = Вы подобрали подарок и получили
GIFT_TAKE_EMPTY = Вы подобрали пустой подарок
CVAR_DROP_RARITY = Шанс выпадения подарка
CVAR_LIFE_TIME = Время жизни подарка (0 - бесконечно)
CVAR_MONEY_MIN = Минимальная сумма получаемая за подарок
CVAR_MONEY_MAX = Максимальная сумма получаемая за подарок

[ua]
GIFT_TAKE = Ви підібрали подарунок та отримали
GIFT_TAKE_EMPTY = Ви підібрали порожній подарунок
GIFT_TAKE_EMPTY = Ви підібрали порожній подарунок
CVAR_DROP_RARITY = Шанс випадання подарунка
CVAR_LIFE_TIME = Час життя подарунка (0 - нескінченно)
CVAR_MONEY_MIN = Мінімальна сума отримується за подарунок
CVAR_MONEY_MAX = Максимальна сума отримується за подарунок
54 changes: 38 additions & 16 deletions amxmodx/scripting/include/awDeathGift.inc
Original file line number Diff line number Diff line change
@@ -1,30 +1,52 @@
// Форварды:
#define AW_DG_CONT 0 /* Continue function execution */
#define AW_DG_STOP 1 /* abort function */

// Для возврата в форварде
#define AW_DG_CONT 0 // Продолжить выполнение функции
#define AW_DG_STOP 1 // Прекратить выполнение функции

// Вызывается до выдачи подарка
/**
* Called after the creation of entity gift
*
* @param id ID of the player
* @param ent ID entity gift
*
* @return AW_DG_CONT to continue issuing a standard gift
* AW_DG_STOP to cancel the results of standard gift
*/
forward awDgFwdTouchPre(id, ent);

// Вызывается после выдачи подарка
// Игнорирует возвращаемое значение
/**
* Called after the creation of entity gift
*
* @param id ID of the player
* @param ent ID entity gift
*
* @noreturn
*/
forward awDgFwdTouchPost(id, ent);

// Вызывается до создания енити подарка
/**
* Called after the creation of entity gift
*
* @param ent ID entity gift
*
* @return AW_DG_CONT to proceed with the creation of entity
* AW_DG_STOP to cancel the creation of entity
*/
forward awDgFwdCreatePre();

// Вызывается после создания ентити подарка
// Игнорирует возвращаемое значение
/**
* Called after the creation of entity gift
*
* @param ent ID entity gift
*
* @noreturn
*/
forward awDgFwdCreatePost(ent);

// Нативы и стоки:
/**
* Отправляет сообщение о поднятии подарка
* Sends a message about raising a gift
*
* @param id ID игрока поднявшего подарок
* @param str[] Что именно поднял игрок (Например: Если str = "123", Будет так: Вы подняли подарок и получили 123). Если строка пустая то будет написано что подарок пустой
* @param id ID of the player who raised the gift
* @param str[] 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 line is empty it will be written that the gift is empty
*
* @noreturn
*/
native awDgSendGiftMsg(id, const str[] = "");
native awDgSendGiftMsg(id, const str [] = "");
4 changes: 2 additions & 2 deletions dgMoreBonuses.sma
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ enum e_giftType{
new Array:gifts;
new Array:giftFuncs;

#define PLUG_VER "1.0"
#define PLUG_NAME "[DG] MoreBonuses"
new const PLUG_VER[] = "1.0";
new const PLUG_NAME[] = "[DG] MoreBonuses";

public plugin_init(){
register_plugin(PLUG_NAME, PLUG_VER, "ArKaNeMaN");
Expand Down
10 changes: 4 additions & 6 deletions dgmbMoreFuncs.sma
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,13 @@
#include <awCoins>
#endif

#define DMG_POISON (1<<17)

#define PLUG_NAME "[DG][MB] More Functions"
#define PLUG_VER "1.0"
new const PLUG_NAME[] = "[DG][MB] More Functions";
new const PLUG_VER[] = "1.0";

public plugin_init(){
register_plugin(PLUG_NAME, PLUG_VER, "ArKaNeMaN");
RegisterHam(Ham_Player_Jump, "player", "pJump");
RegisterHam(Ham_TakeDamage, "player", "pTakeDamage");
RegisterHam(Ham_Player_Jump, "player", "pJump", false);
RegisterHam(Ham_TakeDamage, "player", "pTakeDamage", false);
server_print("[%s v%s] loaded.", PLUG_NAME, PLUG_VER);
}

Expand Down

0 comments on commit 44457cb

Please sign in to comment.