View Single Post
ShD3luxe
Member
Join Date: Aug 2019
Location: Localhost
Old 08-19-2019 , 18:58   Re: SetupBeamLaser to all clients
Reply With Quote #9

If you want to control the position of the beam in space then use TE_SetupBeamPoints and check if the player's z position are equal to not spawn the line.The problem here is that u need to create a timer to check every time for all players position and that will eat a lot of resources.
Doc -> https://sm.alliedmods.net/new-api/sd...etupBeamPoints
Code :
Code:
public DrawLinesToAll()
{
    for(int currentClient = 1;currentClient <= MaxClients;currentClient++) // the first loop to get the start point index
    {
		if(!IsClientAlive(currentClient)) // make sure the player is alive
			continue;
			
		float fstartPosition[3],fendPosition[3]; // x y z float vector position
		GetClientAbsOrigin(currentClient, fstartPosition); // get the position of the client in the vector
		
        for(int clients = 1;clients <= MaxClients;clients++) // the second loop to get the end point positions
		{
		    if(currentClient == clients) // make sure we don't draw the line from-to the same player
				continue;
				
			if(IsClientAlive(currentClient) && IsClientAlive(clients)) // make sure the client is alive
			{
				GetClientAbsOrigin(clients, fendPosition); // get the end point client position
				// do checks here 
				if(fstartPosition[2] != fendPosition[2]) // you can do checks based on position here ( here I checked that the z axis of the clients to not be equal )
				{
					// draw the line from client A position to client B position
					TE_SetupBeamPoints(fstartPosition,fendPosition, g_iBeamSprite, g_iHaloSprite, 0, 10, 0.5, 0.1, 0.1, 1, 0.0, {255, 0, 0, 255}, 10);
					TE_SendToAll();
				}
			}
		}
    }
}
ShD3luxe is offline