Created
February 15, 2022 14:00
-
-
Save nosoop/4c09c760ea36bda30aac1f092bee3879 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Prevents birds from spawning near players in water. | |
*/ | |
#pragma semicolon 1 | |
#include <sourcemod> | |
#pragma newdecls required | |
#define DOVE_SQUARED_TOLERANCE 2500.0 // 50.0 HU^2 | |
public void OnPluginStart() { | |
HookUserMessage(GetUserMessageId("SpawnFlyingBird"), OnDoveSpawned, true); | |
} | |
public Action OnDoveSpawned(UserMsg id, BfRead buffer, const int[] players, int nPlayers, | |
bool reliable, bool init) { | |
float vecCoord[3]; | |
buffer.ReadVecCoord(vecCoord); | |
for (int i = 1; i <= MaxClients; i++) { | |
// check for any taunting medics in water for bird spawning, delete them from existence | |
if (IsClientInGame(i) && GetEntProp(i, Prop_Send, "m_iTauntItemDefIndex") == 477 | |
&& GetEntityFlags(i) & FL_INWATER) { | |
float vecOrigin[3]; | |
GetClientAbsOrigin(i, vecOrigin); | |
float flDistance = GetVectorDistance(vecOrigin, vecCoord, true); | |
if (flDistance < DOVE_SQUARED_TOLERANCE) { | |
return Plugin_Stop; | |
} | |
} | |
} | |
return Plugin_Continue; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment