Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma semicolon 1
- #pragma newdecls required
- #include <sdktools>
- #include <sdkhooks>
- Handle sdkSetAttack;
- float weapon_autoshotgun = 1650.0;
- public void OnPluginStart()
- {
- Handle hGameConf = LoadGameConfigFile("SetAttackSurvivorCommons");
- StartPrepSDKCall(SDKCall_Entity);
- if( PrepSDKCall_SetFromConf(hGameConf, SDKConf_Signature, "SetAttackToSurvivors") == false )
- SetFailState("Could not load the \"SetAttackToSurvivors\" gamedata signature.");
- sdkSetAttack = EndPrepSDKCall();
- HookEvent("weapon_fire", EventFire);
- }
- public Action EventFire(Handle event, const char[] name, bool dontbroadcast)
- {
- int client = GetClientOfUserId(GetEventInt(event, "userid"));
- int weapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
- if(!IsValidEntity(weapon)) return Plugin_Continue;
- char weaponname[36];
- GetEntityClassname(weapon, weaponname, sizeof(weaponname));
- if(bIsSurvivor(client))
- {
- float vPos[3], vTargetPos[3];
- GetClientEyePosition(client, vPos);
- if(strcmp(weaponname, "weapon_autoshotgun") == 0)
- {
- for(int i = 33; i <= 2048; i++)
- {
- if(IsCommonInfected(i))
- {
- GetEntPropVector(i, Prop_Send, "m_vecOrigin", vTargetPos);
- float fTargetDistance = GetVectorDistance(vPos, vTargetPos);
- if(IsVisibleTo(vPos, vTargetPos))
- {
- if(fTargetDistance < weapon_autoshotgun)
- {
- SDKCall(sdkSetAttack, i);
- }
- }
- }
- }
- }
- }
- return Plugin_Continue;
- }
- public bool _TraceFilter(int entity, int contentsMask)
- {
- if (IsValidEntity(entity))
- {
- return false;
- }
- return true;
- }
- stock bool bIsSurvivor(int client)
- {
- return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && !IsClientInKickQueue(client) && IsPlayerAlive(client);
- }
- stock bool IsCommonInfected(int entity)
- {
- if (entity > 33 && IsValidEntity(entity) && IsValidEdict(entity))
- {
- char entType[64];
- GetEdictClassname(entity, entType, sizeof(entType));
- return StrEqual(entType, "infected");
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement