Advertisement
FlacoBey

Untitled

Feb 3rd, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.08 KB | None | 0 0
  1. #include sdktools
  2. #include sdkhooks
  3.  
  4. new bool:IsHealer[MAXPLAYERS+1] = false;
  5. float LastTime[MAXPLAYERS+1];
  6. static Handle hHealCount, hMaxHealth, hDurationRing, CoolDown;
  7.  
  8. Handle HealTimer[MAXPLAYERS+1];
  9.  
  10. new TriggerRef[MAXPLAYERS+1];
  11.  
  12. int g_HaloSprite;
  13. int g_BeamSprite;
  14. int yourColor[4] = {255, 100, 0, 255};
  15.  
  16. public OnPluginStart()
  17. {
  18.     hHealCount = CreateConVar("hCvarHealCount", "5", "Кол-во лечения", FCVAR_NONE, true, 1.0, true, 50000.0);
  19.     hMaxHealth = CreateConVar("hCvarMaxHeal", "75", "Максимальный прохил", FCVAR_NONE);
  20.     hDurationRing = CreateConVar("hCvarDuration", "15.0", "Время жизни кольца", FCVAR_NONE)
  21.     CoolDown = CreateConVar("hCvarCoolDown", "15.0", "Кул даун юзания", FCVAR_NONE)
  22. }
  23.  
  24. public OnMapStart()
  25. {
  26.     HookEvent("bullet_impact", hImpact)
  27.     HookEvent("player_afk", hAfkFix)
  28.     CreateTimer(60.0, hSetMedic, TIMER_FLAG_NO_MAPCHANGE)
  29.    
  30.     g_BeamSprite = PrecacheModel("materials/sprites/laserbeam.vmt", true);
  31.     g_HaloSprite = PrecacheModel("materials/sprites/halo01.vmt", true);
  32. }
  33.  
  34. public hAfkFix(Handle:event, const String:name[], bool:dontBroadcast)
  35. {
  36.     new client = GetClientOfUserId(GetEventInt(event, "player"));
  37.     if(IsHealer[client])
  38.     {
  39.         IsHealer[client] = false;
  40.         new healer = GetAnyRandomSurvivor()
  41.         IsHealer[healer] = true;
  42.         PrintToChatAll("Медик %N отошёл от игры", client);
  43.         PrintToChatAll("%N стал новым медиком", healer);
  44.     }
  45. }
  46.  
  47. public hImpact(Handle:event, const String:name[], bool:dontBroadcast)
  48. {
  49.     new client = GetClientOfUserId(GetEventInt(event, "userid"));
  50.     new Float:f_Pos[3];
  51.     f_Pos[0] = GetEventFloat(event, "x");
  52.     f_Pos[1] = GetEventFloat(event, "y");
  53.     f_Pos[2] = GetEventFloat(event, "z");
  54.    
  55.     if(bIsSurvivor(client))
  56.     {
  57.         if(IsHealer[client])
  58.         {
  59.             if((GetEngineTime() - LastTime[client]) > GetConVarFloat(CoolDown))
  60.             {
  61.                 LastTime[client] = GetEngineTime();
  62.                 TE_SetupBeamRingPoint(f_Pos, 0.0, -600.0, g_BeamSprite, g_HaloSprite, 0, 66, GetConVarFloat(hDurationRing), 1.2, 1.0, yourColor, 40, 0)
  63.                 TE_SendToAll();
  64.                 TriggerMultiple(f_Pos, client);
  65.                 CreateTimer(GetConVarFloat(hDurationRing), KillTrigger, client);
  66.             }
  67.             else
  68.             {
  69.                 PrintToChat(client, "У тебя ещё идёт кул-даун");
  70.             }
  71.         }
  72.     }
  73. }
  74.  
  75. public Action:KillTrigger(Handle:timer, any:client)
  76. {
  77.     int entity = TriggerRef[client];
  78.     AcceptEntityInput(entity, "kill");
  79. }
  80.  
  81. public Action:hSetMedic(Handle timer, any fuck)
  82. {
  83.     new client = GetAnyRandomSurvivor()
  84.     if(client > 0)
  85.     {
  86.         IsHealer[client] = true;
  87.         GiveFunction(client, "pistol_magnum")
  88.         PrintToChatAll("%N стал медиком", client);
  89.     }
  90. }
  91.  
  92. public OnClientPutInServer(client)
  93. {
  94.     //SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
  95.     SDKHook(client, SDKHook_WeaponCanUse, WeaponCanUse);
  96. }
  97.  
  98. public OnClientDisconnect(client)
  99. {
  100.     //SDKUnhook(client, SDKHook_OnTakeDamage, OnTakeDamage);
  101.     SDKUnhook(client, SDKHook_WeaponCanUse, WeaponCanUse);
  102.     if(IsHealer[client] == true)
  103.     {
  104.         IsHealer[client] = false;
  105.         new healer = GetAnyRandomSurvivor()
  106.         IsHealer[healer] = true;
  107.         PrintToChatAll("Медик %N покинул игру", client);
  108.         PrintToChatAll("%N стал новым медиком", healer);
  109.     }
  110.    
  111.     if (HealTimer[client] != INVALID_HANDLE)
  112.     {
  113.         KillTimer(HealTimer[client]);
  114.         HealTimer[client] = INVALID_HANDLE;
  115.     }
  116. }
  117.  
  118. public Action:WeaponCanUse(client, weapon)
  119. {
  120.     if(bIsSurvivor(client))
  121.     {
  122.         if(IsHealer[client])
  123.         {
  124.             new wepn = GetPlayerWeaponSlot(client, 1)
  125.             if (!IsValidEntity(wepn))
  126.             {
  127.                 return Plugin_Continue;
  128.             }
  129.             decl String:sWeaponEx[32];
  130.             GetEntityClassname(wepn, sWeaponEx, sizeof(sWeaponEx));
  131.            
  132.             new String:sClassName[64];
  133.             GetEntityClassname(weapon, sClassName, sizeof(sClassName));
  134.            
  135.             if(StrEqual(sWeaponEx, "weapon_pistol_magnum"))
  136.             {
  137.                 if(StrEqual(sClassName, "weapon_melee") || StrEqual(sClassName, "weapon_pistol"))
  138.                 {
  139.                     return Plugin_Handled;
  140.                 }
  141.             }
  142.         }
  143.     }
  144.     return Plugin_Continue;
  145. }
  146.  
  147. /*
  148. public Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype)  
  149. {
  150.     if(bIsSurvivor(victim) && bIsSurvivor(attacker))
  151.     {
  152.         if(IsHealer[attacker] == true)
  153.         {
  154.             decl String:classname[64];
  155.             GetClientWeapon(attacker, classname, sizeof(classname));
  156.             if(StrEqual(classname, "weapon_pistol_magnum"))
  157.             {
  158.                 damage = 0.0
  159.                 int heal = GetClientHealth(victim)
  160.                 if(GetConVarInt(hMaxHealth) < heal)
  161.                 {
  162.                     SetEntityHealth(victim, GetConVarInt(hHealCount) + 4);
  163.                 }
  164.             }
  165.         }
  166.     }
  167. }
  168. */
  169.  
  170. TriggerMultiple(float vPosHeal[3], client)
  171. {
  172.     new trigger = CreateEntityByName("trigger_multiple");
  173.     if (trigger < 1)
  174.     {
  175.         AcceptEntityInput(trigger, "Kill");
  176.         LogError("ERROR:WCP-231-K57");
  177.         return;
  178.     }
  179.  
  180.     DispatchKeyValue(trigger, "spawnflags", "1");
  181.     DispatchKeyValue(trigger, "wait", "0");
  182.     DispatchSpawn(trigger);
  183.     ActivateEntity(trigger);
  184.     SetEntityModel(trigger, "models/w_models/weapons/w_desert_eagle.mdl");
  185.     TeleportEntity(trigger, vPosHeal, NULL_VECTOR, NULL_VECTOR);
  186.    
  187.     SetEntPropVector(trigger, Prop_Send, "m_vecMins", Float:{-100.0, -100.0, -83.0});
  188.     SetEntPropVector(trigger, Prop_Send, "m_vecMaxs", Float:{100.0, 100.0, 83.0});
  189.     SetEntProp(trigger, Prop_Send, "m_nSolidType", 2);
  190.     new iEffects = GetEntProp(trigger, Prop_Send, "m_fEffects");
  191.     iEffects = 32;
  192.     SetEntProp(trigger, Prop_Send, "m_fEffects", iEffects);
  193.     HookSingleEntityOutput(trigger, "OnStartTouch", OnStartTouch);
  194.     HookSingleEntityOutput(trigger, "OnEndTouch", OnEndTouch);
  195.     TriggerRef[client] = EntIndexToEntRef(trigger);
  196.    
  197. }
  198.  
  199. public OnStartTouch(const String:output[], ent, client, Float:delay)
  200. {
  201.     if(bIsSurvivor(client))
  202.     {
  203.         if (HealTimer[client] == INVALID_HANDLE)
  204.         {
  205.             PrintToChatAll("%N вошёл в зону", client);
  206.             HealTimer[client] = CreateTimer(1.0, HealTime, client, TIMER_REPEAT);
  207.         }
  208.     }
  209. }
  210.  
  211. public OnEndTouch(const String:output[], ent, client, Float:delay)
  212. {
  213.     if(bIsSurvivor)
  214.     {
  215.         if (HealTimer[client] != INVALID_HANDLE)
  216.         {
  217.             KillTimer(HealTimer[client]);
  218.             HealTimer[client] = INVALID_HANDLE;
  219.         }
  220.         PrintToChatAll("%N покинул зону", client);
  221.     }
  222. }
  223.  
  224. public Action:HealTime(Handle:timer, any:client)
  225. {
  226.     new heal = GetClientHealth(client);
  227.     new Need = GetClientHealth(client) + GetConVarInt(hHealCount);
  228.     if (heal < GetConVarInt(hMaxHealth))
  229.     {
  230.         SetEntityHealth(client, Need);
  231.     }
  232.     return Plugin_Stop;
  233. }
  234.  
  235.  
  236. stock GetAnyRandomSurvivor()
  237. {
  238.     new electables = 0, pool[4];
  239.     for (new player = 1; player <= MaxClients; player++)
  240.     {
  241.         if (player > 0 && bIsSurvivor(player) && IsFakeClient(player))
  242.         {
  243.             pool[electables] = player;
  244.             electables += 1;
  245.         }
  246.     }
  247.     return pool[GetRandomInt(0, electables)];
  248. }
  249.  
  250. void GiveFunction(int client, char[] name)
  251. {
  252.     char sBuf[32];
  253.     int flags = GetCommandFlags("give");
  254.     SetCommandFlags("give", flags & ~FCVAR_CHEAT);
  255.     FormatEx(sBuf, sizeof sBuf, "give %s", name);
  256.     FakeClientCommand(client, sBuf);
  257. }
  258.  
  259. stock bool bIsSurvivor(int client)
  260. {
  261.     return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && !IsClientInKickQueue(client) && IsPlayerAlive(client);
  262. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement