If you run this code, 4 colored beams show surrounding you like a box. Right now, the box just moves with you which is only half of the idea. What I am trying to do is have each beam also rotate in the same direction if you move your mouse left or right. In other words, we should always have the same color beams showing in the same position relative to the player if they turn. The "box" should always be facing the same way as the player is turning. I am unsure how to go about this.
Using GetClientEyeAngles(client, fAngles), and then using the fAngles[1] vector seem to accomplish that movement, just not sure how to work it into the rest of the code to do what I want.
Thanks for any help!
PHP Code:
#include <sourcemod>
#include <sdktools>
int beammdl;
float g_fCmdWait[MAXPLAYERS+1];
public OnMapStart() {
beammdl = PrecacheModel("materials/sprites/laserbeam.vmt", true);
}
public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3], float angles[3], int& weapon, int& subtype, int& cmdnum, int& tickcount, int& seed, int mouse[2]) {
if(g_fCmdWait[client] > GetGameTime()) { return Plugin_Continue; }
DrawBox(client);
g_fCmdWait[client] = GetGameTime() + 0.1;
return Plugin_Continue;
}
DrawBox(client) {
decl Float:fBeamStart[3];
decl Float:fBeamEnd[3];
decl Float:fAngles[3];
decl iColor[4];
GetClientAbsOrigin(client, fBeamStart);
GetClientEyeAngles(client, fAngles);
fBeamStart[0] += 16.0;
fBeamStart[1] += 16.0;
fAngles[0] = -90.0;
iColor[0] = 255;
iColor[1] = 0;
iColor[2] = 0;
iColor[3] = 255;
for(int i; i <= 3; i++) {
switch (i) {
case 1: {
fBeamStart[0] -= 32.0;
iColor[0] = 0;
iColor[1] = 255;
iColor[2] = 0;
}
case 2: {
fBeamStart[1] -= 32.0;
iColor[0] = 0;
iColor[1] = 255;
iColor[2] = 255;
}
case 3: {
fBeamStart[0] += 32.0;
iColor[0] = 255;
iColor[1] = 255;
iColor[2] = 0;
}
}
TR_TraceRayFilter(fBeamStart, fAngles, MASK_SHOT, RayType_Infinite, TraceEntityFilter, client);
TR_GetEndPosition(fBeamEnd);
TE_SetupBeamPoints(fBeamStart, fBeamEnd, beammdl, 0, 0, 0, 0.1, 1.0, 1.0, 1, 0.0, iColor, 1);
TE_SendToAll();
}
}
public bool TraceEntityFilter(int entity, int mask, any data){
if (entity == data)
return false;
return true;
}
__________________