Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sourcemod>
- #include <sdktools>
- #include sdkhooks
- #pragma tabsize 0
- float GrenadeRadius = 1000.0
- float PipeBombRadius = 1000.0
- float BarrelRadius = 1000.0
- bool IsAllow = false;
- public OnMapStart()
- {
- IsAllow = false;
- CreateTimer(3.0, allow)
- }
- public Action allow(Handle timer)
- {
- IsAllow = true;
- }
- public void OnEntityDestroyed(int entity)
- {
- if(!IsAllow) return;
- if (IsValidEntity(entity) && IsValidEdict(entity))
- {
- char classname[128];
- GetEdictClassname(entity, classname, 128);
- if (StrEqual(classname, "grenade_launcher_projectile", false))
- {
- GrenadeTouch(entity);
- }
- if (StrEqual(classname, "pipe_bomb_projectile", false))
- {
- BombTouch(entity);
- }
- if (StrEqual(classname, "prop_fuel_barrel", false))
- {
- BarrelTouch(entity);
- }
- }
- }
- public int GrenadeTouch(int entity)
- {
- float pos[3];
- GetEntPropVector(entity, PropType:0, "m_vecOrigin", pos, 0);
- GranadeExplode(pos);
- }
- public int BombTouch(int entity)
- {
- float pos[3];
- GetEntPropVector(entity, PropType:0, "m_vecOrigin", pos, 0);
- BombExplode(pos)
- }
- public int BarrelTouch(int entity)
- {
- float pos[3];
- GetEntPropVector(entity, PropType:0, "m_vecOrigin", pos, 0);
- BarrelExplode(pos);
- }
- int GranadeExplode(float pos[3])
- {
- float fDistance = 0.0;
- float pos2[3];
- for( int i = 0; i < 32; i++ )
- {
- if(IsValidClient(i) && GetClientTeam(i) == 3)
- {
- int vClass = GetEntProp(i, Prop_Send, "m_zombieClass")
- if(vClass == 6)
- {
- GetClientAbsOrigin(i, pos2);
- fDistance = GetVectorDistance(pos, pos2);
- if(fDistance < GrenadeRadius)
- {
- StaggerClient(i, pos)
- }
- }
- }
- }
- }
- int BombExplode(float pos[3])
- {
- float fDistance = 0.0;
- float pos2[3];
- for( int i = 0; i < 32; i++ )
- {
- if(IsValidClient(i) && GetClientTeam(i) == 3)
- {
- int vClass = GetEntProp(i, Prop_Send, "m_zombieClass")
- if(vClass == 6)
- {
- GetClientAbsOrigin(i, pos2);
- fDistance = GetVectorDistance(pos, pos2);
- if(fDistance < PipeBombRadius)
- {
- StaggerClient(i, pos)
- }
- }
- }
- }
- }
- int BarrelExplode(float pos[3])
- {
- float fDistance = 0.0;
- float pos2[3];
- for( int i = 0; i < 32; i++ )
- {
- if(IsValidClient(i) && GetClientTeam(i) == 3)
- {
- int vClass = GetEntProp(i, Prop_Send, "m_zombieClass")
- if(vClass == 6)
- {
- GetClientAbsOrigin(i, pos2);
- fDistance = GetVectorDistance(pos, pos2);
- if(fDistance < BarrelRadius)
- {
- StaggerClient(i, pos)
- }
- }
- }
- }
- }
- void StaggerClient(int iUserID, const float fPos[3])
- {
- static int iScriptLogic = INVALID_ENT_REFERENCE;
- if(iScriptLogic == INVALID_ENT_REFERENCE || !IsValidEntity(iScriptLogic))
- {
- iScriptLogic = EntIndexToEntRef(CreateEntityByName("logic_script"));
- if(iScriptLogic == INVALID_ENT_REFERENCE || !IsValidEntity(iScriptLogic))
- LogError("Could not create 'logic_script");
- DispatchSpawn(iScriptLogic);
- }
- char sBuffer[96];
- Format(sBuffer, sizeof(sBuffer), "GetPlayerFromUserID(%d).Stagger(Vector(%d,%d,%d))", iUserID, RoundFloat(fPos[0]), RoundFloat(fPos[1]), RoundFloat(fPos[2]));
- SetVariantString(sBuffer);
- AcceptEntityInput(iScriptLogic, "RunScriptCode");
- AcceptEntityInput(iScriptLogic, "Kill");
- }
- stock bool:IsValidClient(client)
- {
- if ( client < 1 || client > MaxClients ) return false;
- if ( !IsClientConnected( client )) return false;
- if ( !IsClientInGame( client )) return false;
- if ( GetClientTeam( client ) != 3 ) return false;
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment