I tested the following code:
Code:
public Action Hook_ShotgunShot(const char[] te_name, const int[] players, int numClients, float delay)
{
if (!g_bHooked)
return Plugin_Continue;
int shooterIndex = TE_ReadNum("m_iPlayer") + 1;
if(shooterIndex==0 || !IsClientConnected(shooterIndex) || !IsClientInGame(shooterIndex))
return Plugin_Continue;
int[] newClients = new int[MaxClients];
int newTotal = 0;
for (int i = 0; i < numClients; i++)
{
int client = players[i];
bool rebroadcast = true;
if(shooterIndex==0 || !IsClientConnected(client) || !IsClientInGame(client))
rebroadcast = true;
else
{
float clientpos[3];
GetClientAbsOrigin(client, clientpos);
float shooterpos[3];
GetClientAbsOrigin(shooterIndex, shooterpos);
float distance = (clientpos[0]-shooterpos[0])*(clientpos[0]-shooterpos[0])+(clientpos[1]-shooterpos[1])*(clientpos[1]-shooterpos[1]);
if(distance<300*300)
rebroadcast = true;
else
rebroadcast = false;
}
if (rebroadcast)
{
// This Client should be able to hear it.
newClients[newTotal] = client;
newTotal++;
}
}
float vTemp[3];
TE_Start("Shotgun Shot");
TE_ReadVector("m_vecOrigin", vTemp);
TE_WriteVector("m_vecOrigin", vTemp);
TE_WriteFloat("m_vecAngles[0]", TE_ReadFloat("m_vecAngles[0]"));
TE_WriteFloat("m_vecAngles[1]", TE_ReadFloat("m_vecAngles[1]"));
//TE_WriteNum("m_iWeaponID", TE_ReadNum("m_iWeaponID"));
TE_WriteNum("m_weapon", TE_ReadNum("m_weapon"));
TE_WriteNum("m_iMode", TE_ReadNum("m_iMode"));
TE_WriteNum("m_iSeed", TE_ReadNum("m_iSeed"));
TE_WriteNum("m_iPlayer", TE_ReadNum("m_iPlayer"));
TE_WriteFloat("m_fInaccuracy", TE_ReadFloat("m_fInaccuracy"));
TE_WriteFloat("m_fSpread", TE_ReadFloat("m_fSpread"));
TE_Send(newClients, newTotal, delay);
return Plugin_Stop;
}
It was working but I got this error messages:
Quote:
L 04/05/2018 - 19:17:25: [SM] [148] Line 331, wase_weapon_sounds.sp::Hook_ShotgunShot
L 04/05/2018 - 19:17:25: [SM] [150] TE_Send
L 04/05/2018 - 19:17:25: [SM] [151] Line 331, wase_weapon_sounds.sp::Hook_ShotgunShot
L 04/05/2018 - 19:17:25: [SM] [153] TE_Send
L 04/05/2018 - 19:17:25: [SM] [154] Line 331, wase_weapon_sounds.sp::Hook_ShotgunShot
L 04/05/2018 - 19:17:25: [SM] [156] TE_Send
L 04/05/2018 - 19:17:25: [SM] [157] Line 331, wase_weapon_sounds.sp::Hook_ShotgunShot
L 04/05/2018 - 19:17:25: [SM] Exception reported: Not enough space on the stack
|
Additional (I think it is related) it was supersizing the server sv/var?