I will be hosting a tournament in a few weeks, and every match will be streamed live on Twitch.
Me and a friend will comment on the gameplay, and I will control what you will see on the stream.
Spectating in 1.6 is quite flawed, and it is not so easy to switch between players and make it look good.
But I have used spec_mode and bound the different modes to keys so I can switch using those.
The request:
I would like to be able to place cameras and switch to them by using buttons.
For example: I take the coordinates and angle of bomb site on A and save them in the plugin.
That way I can quickly jump to different positions and get some nice shots.
I chopped up a plugin called
Spectator Camera to try and do this.
And I am able to switch to the camera, but the coordinates I placed are not correct and there is no angle to the camera.
The slimmed code looks like this:
PHP Code:
#include <amxmodx>
#include <fakemeta>
new MODEL[] = "models/player/vip/vip.mdl";
new giCameraEntity;
new bool:gbCameraActive[33];
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR);
register_clcmd("+camera", "CameraActivate");
CameraInit();
}
public plugin_precache()
precache_model(MODEL);
public CameraInit() {
giCameraEntity = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target")); // Create Camera Entity
set_pev(giCameraEntity, pev_classname, "Multiply_Camera"); // Give the Camera a name
set_pev(giCameraEntity, pev_solid, SOLID_NOT); // Make the Camera semiclip
engfunc(EngFunc_SetModel, giCameraEntity, MODEL); // Set Camera Model (Needed, for EngFunc_SetView to work properly)
set_pev(giCameraEntity, pev_movetype, MOVETYPE_FLY); // Stop the Camera from dropping on the ground
set_pev(giCameraEntity, pev_health, 1.0); // Set Camera health to 1
set_pev(giCameraEntity, pev_takedamage, 0.0); // Make Camera invincible
set_pev(giCameraEntity, pev_rendermode, 5); // Fix rendermode
set_pev(giCameraEntity, pev_renderamt, 0.0); // Make it less visable
set_pev(giCameraEntity, pev_angles, Float:{0.0, 180.0, 0.0}); // Test using angles
CameraSetOrigin(Float:{438.2510, 142.30, 312.30}); // Place Camera in the middle of the map
}
public CameraSetOrigin(Float:fOrigin[3]) {
new Float:fMins[3], Float:fMaxs[3];
pev(giCameraEntity, pev_mins, fMins);
pev(giCameraEntity, pev_maxs, fMaxs);
engfunc(EngFunc_SetSize, giCameraEntity, fMins, fMaxs);
return engfunc(EngFunc_SetOrigin, giCameraEntity, fOrigin);
}
public CameraActivate(iPlayerId) {
engfunc(EngFunc_SetView, iPlayerId, giCameraEntity);
gbCameraActive[iPlayerId] = true;
client_print(iPlayerId, print_chat, "[Camera] Has just been enabled.");
}
// Thanks to GHW_Chronic for this stock
stock entity_set_aim(ent,const Float:origin2[3],bone=0)
{
if(!pev_valid(ent))
return 0;
static Float:origin[3]
origin[0] = origin2[0]
origin[1] = origin2[1]
origin[2] = origin2[2]
static Float:ent_origin[3], Float:angles[3]
if(bone)
engfunc(EngFunc_GetBonePosition,ent,bone,ent_origin,angles)
else
pev(ent,pev_origin,ent_origin)
origin[0] -= ent_origin[0]
origin[1] -= ent_origin[1]
origin[2] -= ent_origin[2]
static Float:v_length
v_length = vector_length(origin)
static Float:aim_vector[3]
aim_vector[0] = origin[0] / v_length
aim_vector[1] = origin[1] / v_length
aim_vector[2] = origin[2] / v_length
static Float:new_angles[3]
vector_to_angle(aim_vector,new_angles)
new_angles[0] *= -1
if(new_angles[1]>180.0) new_angles[1] -= 360
if(new_angles[1]<-180.0) new_angles[1] += 360
if(new_angles[1]==180.0 || new_angles[1]==-180.0) new_angles[1]=-179.999999
set_pev(ent,pev_angles,new_angles)
set_pev(ent,pev_fixangle,1)
return 1;
}
If someone could give this a shot it would make me real happy.
Thanks a ton!
__________________