View Single Post
Author Message
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 06-09-2021 , 18:45   Set player view to specified trigger_camera ent?
Reply With Quote #1

I've made a custom map and included a single trigger_camera entity with the targetname set to "KEYCAM" and don't want to set it off through the usual way by triggering it (not that it matters, since it's multiplayer cs 1.6), but would rather use the engine function and set the player's view to it instead.
When I trigger the engine function, the player's view gets to the center of the map (0, 0, 0) instead of the camera that is placed elsewhere. How do I resolve this issue? Note that I want it to be done programmatically and not through mapping.

PHP Code:
new g_ent;

public 
plugin_init() {

    
register_clcmd("say /cam""CmdCam");

    new 
ent = -1tname[32];
    while (
ent find_ent_by_class(ent"trigger_camera")) {

        
pev(entpev_targetnametnamecharsmax(tname));
        if (
equal(tname"KEYCAM")) {

            
g_ent ent;
            
log_amx("Cam found: %d"ent);
            break;
        }
    }
}

public 
CmdCam(id) {

    
engfunc(EngFunc_SetViewidg_ent);


Last edited by redivcram; 06-10-2021 at 18:09.
redivcram is offline