-
Notifications
You must be signed in to change notification settings - Fork 1
/
rm_invis_rune.sma
112 lines (94 loc) · 3.18 KB
/
rm_invis_rune.sma
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include <amxmodx>
#include <amxmisc>
#include <rm_api>
new bool:g_invis[MAX_PLAYERS + 1] = {false,...};
const MovingBits = ( IN_FORWARD | IN_BACK | IN_MOVELEFT | IN_MOVERIGHT );
new rune_model_id = -1;
new rune_name[] = "rm_invis_rune_name";
new rune_descr[] = "rm_invis_rune_desc";
new rune_model_path[64] = "models/rm_reloaded/rune_sky.mdl";
new rune_sound_path[64] = "sound/rm_reloaded/invis.wav";
new g_iCfgSpawnSecondsDelay = 0;
public plugin_init()
{
register_plugin("RM_INVIS","2.7","Karaulov");
rm_register_rune(rune_name,rune_descr,Float:{99.0, 197.0, 218.0}, rune_model_path, rune_sound_path, rune_model_id);
RegisterHookChain(RG_CBasePlayer_TakeDamage, "CPlayer_TakeDamage_Post", .post = true);
/* Чтение конфигурации */
new cost = 8500;
rm_read_cfg_int(rune_name,"COST_MONEY",cost,cost);
rm_base_set_rune_cost(cost);
// Максимальное количество предметов/рун которые могут быть на карте в одно время
new max_count = 10;
rm_read_cfg_int(rune_name,"MAX_COUNT_ON_MAP",max_count,max_count);
rm_base_set_max_count( max_count );
// Задержка между спавнами
rm_read_cfg_int(rune_name,"DELAY_BETWEEN_NEXT_SPAWN",g_iCfgSpawnSecondsDelay,g_iCfgSpawnSecondsDelay);
}
new Float:flLastSpawnTime = 0.0;
public rm_spawn_rune(iEnt)
{
if (floatround(floatabs(get_gametime() - flLastSpawnTime)) > g_iCfgSpawnSecondsDelay)
{
flLastSpawnTime = get_gametime();
return SPAWN_SUCCESS;
}
return SPAWN_ERROR;
}
public plugin_precache()
{
/* Чтение конфигурации */
rm_read_cfg_str(rune_name,"model",rune_model_path,rune_model_path,charsmax(rune_model_path));
rm_read_cfg_str(rune_name,"sound",rune_sound_path,rune_sound_path,charsmax(rune_sound_path));
rune_model_id = precache_model(rune_model_path);
if (file_exists(rune_sound_path,true))
{
precache_generic(rune_sound_path);
}
}
public rm_give_rune(id)
{
g_invis[id] = true;
rm_base_highlight_screen(id);
if (task_exists(id))
remove_task(id);
set_task(0.1,"update_invis_state",id, _, _, "b");
}
public rm_drop_rune(id)
{
g_invis[id] = false;
if (task_exists(id))
remove_task(id);
if (is_user_connected(id))
{
rg_set_rendering(id);
new iFlags = get_entvar( id, var_flags );
if (iFlags & FL_NOTARGET)
{
set_entvar( id, var_flags, iFlags - FL_NOTARGET );
}
}
}
// Таск срабатывает 10 раз в секунду. Если игрок держит нажатой клавишу движения, становится частично видимым.
public update_invis_state(id)
{
if ( is_real_player(id) && g_invis[id] )
{
new iFlags = get_entvar( id, var_flags );
if (!(iFlags & FL_NOTARGET))
{
set_entvar( id, var_flags, iFlags + FL_NOTARGET )
}
if (get_entvar(id, var_button) & MovingBits)
rg_set_rendering(id, kRenderFxNone, kRenderTransAlpha, Float: {255.0, 255.0, 255.0}, 40.0)
else
rg_set_rendering(id, kRenderFxNone, kRenderTransAlpha, Float: {255.0, 255.0, 255.0}, 0.0)
}
}
public CPlayer_TakeDamage_Post(iVictim, iInflictor, iAttacker, Float:flDamage, iBitsDamageType)
{
if (is_real_player(iAttacker) && g_invis[iAttacker])
{
rm_base_drop_rune( iAttacker );
}
}