Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <amxmodx>
- #include <fakemeta>
- #include <fun>
- #include <engine>
- #define GIVE_HEALTH 50 //Сколько ХП восстанавливать
- #define EXPLODE_TIME 5 //Через сколько секунд взорвется граната
- #define HEAL_RADIUS 300.0 //Радиус
- #define GENERAL_EXPLODE //Включить основной спрайт взрыва
- #define TWO_EXPLODE //включить дополнительные осколки от взрыва
- #define SHOKWAVE //Включить Shokwave вокруг гранаты при взрыве
- //#define SCREENFADE //Включить скринфейд
- #define STATUSICON //показывать иконку
- #define TOUCH_EXPLODE //Взрываться ли сразу при соприкосновении с обьектами
- #define FLAG_ADM ADMIN_LEVEL_H
- #define AMOUNT_GRENADE 2
- //-------------------------------------
- #define V_MODEL "models/v_he_mk_nade_sib.mdl"
- #define P_MODEL "models/p_he_mk_nade_sib.mdl"
- #define W_MODEL "models/w_he_mk_nade_sib.mdl"
- #if defined GENERAL_EXPLODE
- #define EXPLODE_SPRITE "sprites/heal_explode_sib.spr"
- #endif
- #if defined TWO_EXPLODE
- #define EXPLODE_SPRITE2 "sprites/heal_shape_sib.spr"
- #endif
- #define HEAL_SOUND "woomen_expr_sib.wav"
- //--------------------------------------
- #if defined GENERAL_EXPLODE
- new ExplSpr;
- #endif
- #if defined TWO_EXPLODE
- new ExplSpr2;
- #endif
- #if defined SHOKWAVE
- new g_iSpriteCircle;
- #endif
- #if defined STATUSICON
- new g_IconStatus;
- #endif
- new const g_sound_explosion[] = "weapons/sg_explode.wav";
- new const g_classname_grenade[] = "grenade";
- new g_eventid_createsmoke;
- new g_Mode[33]
- new g_HowMuch[33]
- public plugin_init()
- {
- register_plugin("Nade Health", "1.2", "medusa");
- #if defined STATUSICON
- g_IconStatus = get_user_msgid("StatusIcon");
- #endif
- register_forward(FM_EmitSound, "FMForward_EmitSound");
- register_forward(FM_PlaybackEvent, "FMForward_PlaybackEvent");
- register_event("CurWeapon", "EVCurWeapon", "be", "1=1");
- register_forward(FM_SetModel, "FMForward_SetModel", 1);
- //register_forward(FM_PlayerPreThink, "FW_PlayerPreThink");
- register_forward(FM_CmdStart, "fw_cmdstart")
- register_logevent("round_start", 2, "0=World triggered", "1=Round_Start")
- register_logevent("round_start", 2, "1=Round_End")
- register_think("grenade", "FMForward_Think" )
- register_clcmd("say /grena", "TakeGrenade")
- #if defined TOUCH_EXPLODE
- register_touch("grenade", "*", "FMForward_Touch")
- #endif
- g_eventid_createsmoke = engfunc(EngFunc_PrecacheEvent, 1, "events/createsmoke.sc");
- }
- public client_conntct(id)
- {
- g_HowMuch[id] = 0
- }
- public round_start()
- {
- for(new id = 1; id <= get_maxplayers(); id++)
- {
- if(is_user_connected(id) && get_user_flags(id) & FLAG_ADM)
- g_HowMuch[id] = 0
- }
- }
- public TakeGrenade(id)
- {
- if(!is_user_connected(id) || !is_user_alive(id))
- return
- if(get_user_flags(id) & FLAG_ADM)
- {
- if(g_HowMuch[id] >= AMOUNT_GRENADE)
- {
- color_chat(id, "!g[Режим гранат] !tБесплатно можно брать только %d гранат!", AMOUNT_GRENADE)
- return
- }
- give_item(id, "weapon_smokegrenade")
- g_Mode[id] = 0
- g_HowMuch[id]++
- color_chat(id, "!g[Режим гранат] !tЧто бы изменить режим, нажми правую кнопку мыши!")
- }
- }
- public fw_cmdstart(id, uc_handle, seed)
- {
- if (!is_user_alive(id))
- return FMRES_IGNORED
- static bool:key[32 + 1] = {false, ...}
- static buttons
- buttons = get_uc(uc_handle, UC_Buttons)
- if(get_user_flags(id) & FLAG_ADM)
- {
- if(get_user_weapon(id) != CSW_SMOKEGRENADE)
- return FMRES_IGNORED
- if (buttons & IN_ATTACK2)
- {
- if (!key[id])
- {
- if(!g_Mode[id])
- {
- g_Mode[id] = 1
- client_print(id, print_center, "Режим гранаты: Дым")
- set_pev(id, pev_viewmodel2, "models/v_smokegrenade.mdl");
- set_pev(id, pev_weaponmodel2, "models/p_smokegrenade.mdl");
- }
- else
- {
- g_Mode[id] = 0
- client_print(id, print_center, "Режим гранаты: Хилл")
- set_pev(id, pev_viewmodel2, V_MODEL);
- set_pev(id, pev_weaponmodel2, P_MODEL);
- }
- }
- key[id] = true
- }
- else
- {
- key[id] = false
- }
- }
- return FMRES_IGNORED;
- }
- public plugin_precache()
- {
- #if defined GENERAL_EXPLODE
- ExplSpr = precache_model(EXPLODE_SPRITE);
- #endif
- #if defined TWO_EXPLODE
- ExplSpr2 = precache_model(EXPLODE_SPRITE2);
- #endif
- precache_model(V_MODEL);
- precache_model(W_MODEL);
- precache_model(P_MODEL);
- precache_sound(HEAL_SOUND);
- #if defined SHOKWAVE
- g_iSpriteCircle = precache_model("sprites/shockwave.spr");
- #endif
- }
- public EVCurWeapon(id)
- {
- if(is_user_connected(id) && is_user_alive(id) && !g_Mode[id] && get_user_flags(id) & FLAG_ADM)
- {
- if(get_user_weapon(id) == CSW_SMOKEGRENADE)
- {
- set_pev(id, pev_viewmodel2, V_MODEL);
- set_pev(id, pev_weaponmodel2, P_MODEL);
- #if defined STATUSICON
- message_begin(MSG_ONE_UNRELIABLE, g_IconStatus, {0,0,0}, id);
- write_byte(2)
- write_string("cross");
- write_byte(0);
- write_byte(255);
- write_byte(0);
- message_end();
- #endif
- }
- #if defined STATUSICON
- else
- {
- message_begin(MSG_ONE_UNRELIABLE, g_IconStatus, {0,0,0}, id);
- write_byte(0)
- write_string("cross");
- message_end();
- }
- #endif
- }
- }
- public FMForward_SetModel(entity, const model[])
- {
- if(!pev_valid(entity)) return FMRES_IGNORED;
- static id
- id = entity_get_edict(entity, EV_ENT_owner)
- if(get_user_flags(id) & FLAG_ADM)
- {
- if(g_Mode[id]) return FMRES_IGNORED;
- if(equal(model, "models/w_smokegrenade.mdl"))
- {
- engfunc(EngFunc_SetModel, entity, W_MODEL);
- set_pev(entity, pev_dmgtime, get_gametime() + EXPLODE_TIME);
- set_pev(entity, pev_flTimeStepSound, 555)
- }
- }
- return FMRES_IGNORED;
- }
- #if defined TOUCH_EXPLODE
- public FMForward_Touch(entity)
- {
- if(~get_pdata_int(entity, 114) & (1<<1))
- return;
- new iPlayer = entity_get_edict(entity, EV_ENT_owner)
- if(g_Mode[iPlayer])
- return;
- set_pev(entity, pev_dmgtime, get_gametime());
- }
- #endif
- public FMForward_EmitSound(entity, channel, const sound[])
- {
- if (!equal(sound, g_sound_explosion) || !is_grenade(entity))
- return FMRES_IGNORED;
- static Float:origin[3];
- static id; id = pev(entity, pev_owner);
- pev(entity, pev_origin, origin);
- if(!(get_user_flags(id) & FLAG_ADM)) return FMRES_IGNORED;
- if(g_Mode[id] == 0)
- {
- engfunc(EngFunc_EmitSound, entity, CHAN_WEAPON, HEAL_SOUND, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
- #if defined GENERAL_EXPLODE
- message_begin(MSG_PVS,SVC_TEMPENTITY,{0,0,0});
- write_byte(TE_EXPLOSION);
- write_coord(floatround(origin[0]));
- write_coord(floatround(origin[1]));
- write_coord(floatround(origin[2])+65);
- write_short(ExplSpr);
- write_byte(30);
- write_byte(20);
- write_byte(TE_EXPLFLAG_NOSOUND|TE_EXPLFLAG_NOPARTICLES);
- message_end();
- #endif
- #if defined TWO_EXPLODE
- message_begin(MSG_ALL,SVC_TEMPENTITY,{0,0,0});
- write_byte(TE_SPRITETRAIL);
- write_coord(floatround(origin[0]));
- write_coord(floatround(origin[1]));
- write_coord(floatround(origin[2])+20);
- write_coord(floatround(origin[0]));
- write_coord(floatround(origin[1]));
- write_coord(floatround(origin[2])+80);
- write_short(ExplSpr2);
- write_byte(20);
- write_byte(20);
- write_byte(4);
- write_byte(20);
- write_byte(10);
- message_end();
- #endif
- #if defined SHOKWAVE
- message_begin(MSG_ALL, SVC_TEMPENTITY, {0,0,0});
- write_byte(TE_BEAMCYLINDER);
- write_coord(floatround(origin[0]));
- write_coord(floatround(origin[1]));
- write_coord(floatround(origin[2]));
- write_coord(floatround(origin[0]));
- write_coord(floatround(origin[1]));
- write_coord(floatround(origin[2] + HEAL_RADIUS));
- write_short(g_iSpriteCircle);
- write_byte(0);
- write_byte(1);
- write_byte(5);
- write_byte(30);
- write_byte(1);
- write_byte(10);
- write_byte(255);
- write_byte(40);
- write_byte(255);
- write_byte(5);
- message_end();
- #endif
- new user
- while((user = find_ent_in_sphere(user,origin,HEAL_RADIUS)) != 0)
- {
- if(is_user_alive(user) && g_Mode[id] == 0)
- {
- #if defined SCREENFADE
- message_begin(MSG_ONE, get_user_msgid("ScreenFade"), {0,0,0}, user);
- write_short(1<<10);
- write_short(1<<10);
- write_short(0x0000);
- write_byte(170);
- write_byte(255);
- write_byte(0);
- write_byte(75);
- message_end();
- #endif
- new health[33];
- health[user] = get_user_health(user);
- if (health[user] <= 100 - GIVE_HEALTH)
- set_user_health(user,health[user] + GIVE_HEALTH);
- else if(health[user] > 100 - GIVE_HEALTH)
- set_user_health(user,100);
- }
- }
- }
- return FMRES_SUPERCEDE;
- }
- public FMForward_PlaybackEvent(flags, invoker, eventindex)
- {
- if (eventindex == g_eventid_createsmoke)
- return FMRES_IGNORED
- if(!g_Mode[invoker])
- return FMRES_SUPERCEDE
- return FMRES_IGNORED
- }
- public FMForward_Think(entity)
- {
- static id; id = pev(entity, pev_owner);
- if(!g_Mode[id])
- {
- if(get_pdata_int(entity, 114) & (1<<1))
- set_pev( entity, pev_flags, FL_ONGROUND )
- }
- }
- bool:is_grenade(entity)
- {
- if (!pev_valid(entity))
- return false;
- static classname[sizeof g_classname_grenade + 1]
- pev(entity, pev_classname, classname, sizeof g_classname_grenade);
- if (equal(classname, g_classname_grenade))
- return true;
- return false;
- }
- public CHECK_ValidPlayer(id){
- if (1<=id<=get_maxplayers() && is_user_alive(id))
- return 1;
- return 0;
- }
- stock color_chat(const id, const input[], any:...)
- {
- new count = 1, players[32];
- static msg[191];
- vformat(msg, 190, input, 3);
- replace_all(msg, 190, "!g", "^4");
- replace_all(msg, 190, "!y", "^1");
- replace_all(msg, 190, "!t", "^3");
- if (id) players[0] = id; else get_players(players, count, "ch");
- {
- for (new i = 0; i < count; i++)
- {
- if (is_user_connected(players[i]))
- {
- message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i]);
- write_byte(players[i]);
- write_string(msg);
- message_end();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement