Can this be modified to automatically start the fireworks at round end? I hooked the roundend hook and tried to use GetClientAbsOrigin and GetClientAbsAngles of the players alive at round end and start the fireworks, however the fireworks model seems to spawn in random places.
Code:
PHP Code:
public Action:RoundEnded(Handle: event , const String: name[] , bool: dontBroadcast)
{
for(new client = 1; client <= MAXPLAYERS; client++)
{
if (IsClientInGame(client) && !IsFakeClient(client) && IsPlayerAlive(client))
{
if ( Fireworks_IsFireworkExists(FIREWORK_NAME) ) {
decl Float:vOrigin[3], Float:vAngles[3];
if ( GetClientViewOriginAndAngles(client, vOrigin, vAngles) ) {
Fireworks_SpawnFirework(FIREWORK_NAME, vOrigin, vAngles);
}
else {
PrintToChat(client, "Surface not found");
}
}
else {
PrintToChat(client, "Firework with name \"%s\" doesn't exists", FIREWORK_NAME);
}
}
}
return Plugin_Continue;
}
And the function to get the origin and angles:
PHP Code:
bool:GetClientViewOriginAndAngles(const iClient, Float:vOrigin[3], Float:vAngles[3])
{
// get client eye position and angles
GetClientAbsOrigin(iClient, vOrigin);
GetClientAbsAngles(iClient, vAngles);
// start trace ray
TR_TraceRayFilter(vOrigin, vAngles, MASK_SOLID, RayType_Infinite, TR_DontHitSelf, iClient);
// if hit something
if ( TR_DidHit(INVALID_HANDLE) )
{
// get collusion origin
TR_GetEndPosition(vOrigin, INVALID_HANDLE);
// get angles
// TR_GetPlaneNormal(INVALID_HANDLE, vAngles);
// find projection
// GetVectorAngles(vAngles, vAngles);
// vAngles[0] += 90.0;
// return true
return true;
}
// return false
return false;
}
__________________
We all live under the same sky but we have different horizons.