Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include sdktools
- #include sdkhooks
- new bool:IsHealer[MAXPLAYERS+1] = false;
- float LastTime[MAXPLAYERS+1];
- static Handle hHealCount, hMaxHealth, hDurationRing, CoolDown;
- Handle HealTimer[MAXPLAYERS+1];
- new TriggerRef[MAXPLAYERS+1];
- int g_HaloSprite;
- int g_BeamSprite;
- int yourColor[4] = {255, 100, 0, 255};
- public OnPluginStart()
- {
- hHealCount = CreateConVar("hCvarHealCount", "5", "Кол-во лечения", FCVAR_NONE, true, 1.0, true, 50000.0);
- hMaxHealth = CreateConVar("hCvarMaxHeal", "75", "Максимальный прохил", FCVAR_NONE);
- hDurationRing = CreateConVar("hCvarDuration", "15.0", "Время жизни кольца", FCVAR_NONE)
- CoolDown = CreateConVar("hCvarCoolDown", "15.0", "Кул даун юзания", FCVAR_NONE)
- }
- public OnMapStart()
- {
- HookEvent("bullet_impact", hImpact)
- HookEvent("player_afk", hAfkFix)
- CreateTimer(60.0, hSetMedic, TIMER_FLAG_NO_MAPCHANGE)
- g_BeamSprite = PrecacheModel("materials/sprites/laserbeam.vmt", true);
- g_HaloSprite = PrecacheModel("materials/sprites/halo01.vmt", true);
- }
- public hAfkFix(Handle:event, const String:name[], bool:dontBroadcast)
- {
- new client = GetClientOfUserId(GetEventInt(event, "player"));
- if(IsHealer[client])
- {
- IsHealer[client] = false;
- new healer = GetAnyRandomSurvivor()
- IsHealer[healer] = true;
- PrintToChatAll("Медик %N отошёл от игры", client);
- PrintToChatAll("%N стал новым медиком", healer);
- }
- }
- public hImpact(Handle:event, const String:name[], bool:dontBroadcast)
- {
- new client = GetClientOfUserId(GetEventInt(event, "userid"));
- new Float:f_Pos[3];
- f_Pos[0] = GetEventFloat(event, "x");
- f_Pos[1] = GetEventFloat(event, "y");
- f_Pos[2] = GetEventFloat(event, "z");
- if(bIsSurvivor(client))
- {
- if(IsHealer[client])
- {
- if((GetEngineTime() - LastTime[client]) > GetConVarFloat(CoolDown))
- {
- LastTime[client] = GetEngineTime();
- TE_SetupBeamRingPoint(f_Pos, 0.0, -600.0, g_BeamSprite, g_HaloSprite, 0, 66, GetConVarFloat(hDurationRing), 1.2, 1.0, yourColor, 40, 0)
- TE_SendToAll();
- TriggerMultiple(f_Pos, client);
- CreateTimer(GetConVarFloat(hDurationRing), KillTrigger, client);
- }
- else
- {
- PrintToChat(client, "У тебя ещё идёт кул-даун");
- }
- }
- }
- }
- public Action:KillTrigger(Handle:timer, any:client)
- {
- int entity = TriggerRef[client];
- AcceptEntityInput(entity, "kill");
- }
- public Action:hSetMedic(Handle timer, any fuck)
- {
- new client = GetAnyRandomSurvivor()
- if(client > 0)
- {
- IsHealer[client] = true;
- GiveFunction(client, "pistol_magnum")
- PrintToChatAll("%N стал медиком", client);
- }
- }
- public OnClientPutInServer(client)
- {
- //SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
- SDKHook(client, SDKHook_WeaponCanUse, WeaponCanUse);
- }
- public OnClientDisconnect(client)
- {
- //SDKUnhook(client, SDKHook_OnTakeDamage, OnTakeDamage);
- SDKUnhook(client, SDKHook_WeaponCanUse, WeaponCanUse);
- if(IsHealer[client] == true)
- {
- IsHealer[client] = false;
- new healer = GetAnyRandomSurvivor()
- IsHealer[healer] = true;
- PrintToChatAll("Медик %N покинул игру", client);
- PrintToChatAll("%N стал новым медиком", healer);
- }
- if (HealTimer[client] != INVALID_HANDLE)
- {
- KillTimer(HealTimer[client]);
- HealTimer[client] = INVALID_HANDLE;
- }
- }
- public Action:WeaponCanUse(client, weapon)
- {
- if(bIsSurvivor(client))
- {
- if(IsHealer[client])
- {
- new wepn = GetPlayerWeaponSlot(client, 1)
- if (!IsValidEntity(wepn))
- {
- return Plugin_Continue;
- }
- decl String:sWeaponEx[32];
- GetEntityClassname(wepn, sWeaponEx, sizeof(sWeaponEx));
- new String:sClassName[64];
- GetEntityClassname(weapon, sClassName, sizeof(sClassName));
- if(StrEqual(sWeaponEx, "weapon_pistol_magnum"))
- {
- if(StrEqual(sClassName, "weapon_melee") || StrEqual(sClassName, "weapon_pistol"))
- {
- return Plugin_Handled;
- }
- }
- }
- }
- return Plugin_Continue;
- }
- /*
- public Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype)
- {
- if(bIsSurvivor(victim) && bIsSurvivor(attacker))
- {
- if(IsHealer[attacker] == true)
- {
- decl String:classname[64];
- GetClientWeapon(attacker, classname, sizeof(classname));
- if(StrEqual(classname, "weapon_pistol_magnum"))
- {
- damage = 0.0
- int heal = GetClientHealth(victim)
- if(GetConVarInt(hMaxHealth) < heal)
- {
- SetEntityHealth(victim, GetConVarInt(hHealCount) + 4);
- }
- }
- }
- }
- }
- */
- TriggerMultiple(float vPosHeal[3], client)
- {
- new trigger = CreateEntityByName("trigger_multiple");
- if (trigger < 1)
- {
- AcceptEntityInput(trigger, "Kill");
- LogError("ERROR:WCP-231-K57");
- return;
- }
- DispatchKeyValue(trigger, "spawnflags", "1");
- DispatchKeyValue(trigger, "wait", "0");
- DispatchSpawn(trigger);
- ActivateEntity(trigger);
- SetEntityModel(trigger, "models/w_models/weapons/w_desert_eagle.mdl");
- TeleportEntity(trigger, vPosHeal, NULL_VECTOR, NULL_VECTOR);
- SetEntPropVector(trigger, Prop_Send, "m_vecMins", Float:{-100.0, -100.0, -83.0});
- SetEntPropVector(trigger, Prop_Send, "m_vecMaxs", Float:{100.0, 100.0, 83.0});
- SetEntProp(trigger, Prop_Send, "m_nSolidType", 2);
- new iEffects = GetEntProp(trigger, Prop_Send, "m_fEffects");
- iEffects = 32;
- SetEntProp(trigger, Prop_Send, "m_fEffects", iEffects);
- HookSingleEntityOutput(trigger, "OnStartTouch", OnStartTouch);
- HookSingleEntityOutput(trigger, "OnEndTouch", OnEndTouch);
- TriggerRef[client] = EntIndexToEntRef(trigger);
- }
- public OnStartTouch(const String:output[], ent, client, Float:delay)
- {
- if(bIsSurvivor(client))
- {
- if (HealTimer[client] == INVALID_HANDLE)
- {
- PrintToChatAll("%N вошёл в зону", client);
- HealTimer[client] = CreateTimer(1.0, HealTime, client, TIMER_REPEAT);
- }
- }
- }
- public OnEndTouch(const String:output[], ent, client, Float:delay)
- {
- if(bIsSurvivor)
- {
- if (HealTimer[client] != INVALID_HANDLE)
- {
- KillTimer(HealTimer[client]);
- HealTimer[client] = INVALID_HANDLE;
- }
- PrintToChatAll("%N покинул зону", client);
- }
- }
- public Action:HealTime(Handle:timer, any:client)
- {
- new heal = GetClientHealth(client);
- new Need = GetClientHealth(client) + GetConVarInt(hHealCount);
- if (heal < GetConVarInt(hMaxHealth))
- {
- SetEntityHealth(client, Need);
- }
- return Plugin_Stop;
- }
- stock GetAnyRandomSurvivor()
- {
- new electables = 0, pool[4];
- for (new player = 1; player <= MaxClients; player++)
- {
- if (player > 0 && bIsSurvivor(player) && IsFakeClient(player))
- {
- pool[electables] = player;
- electables += 1;
- }
- }
- return pool[GetRandomInt(0, electables)];
- }
- void GiveFunction(int client, char[] name)
- {
- char sBuf[32];
- int flags = GetCommandFlags("give");
- SetCommandFlags("give", flags & ~FCVAR_CHEAT);
- FormatEx(sBuf, sizeof sBuf, "give %s", name);
- FakeClientCommand(client, sBuf);
- }
- stock bool bIsSurvivor(int client)
- {
- return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && !IsClientInKickQueue(client) && IsPlayerAlive(client);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement