AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Set player view to specified trigger_camera ent? (https://forums.alliedmods.net/showthread.php?t=332943)

redivcram 06-09-2021 18:45

Set player view to specified trigger_camera ent?
 
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);



DeMNiX 06-09-2021 22:16

Re: Set player view to specified trigger_camera ent?
 
what is g_ent's value? i think its equal zero when u call /cam

HamletEagle 06-10-2021 02:18

Re: Set player view to specified trigger_camera ent?
 
Add another set of () to the while condition.

redivcram 06-10-2021 08:11

Re: Set player view to specified trigger_camera ent?
 
Server prints the log message. Cam's index happens to be 51 currently.

kww 06-10-2021 09:07

Re: Set player view to specified trigger_camera ent?
 
Quote:

Originally Posted by redivcram (Post 2749423)
Server prints the log message. Cam's index happens to be 51 currently.

you can try this, but i think it will behave the same
Code:

native attach_view(iIndex, iTargetIndex);

redivcram 06-10-2021 13:50

Re: Set player view to specified trigger_camera ent?
 
Same thing... I've checked its coordinates and they are definitely matching the ones in the map editor. They're nowhere beyond bounds.
Also tried creating a fresh info_target ent where the trigger_camera is, but same results...

redivcram 06-10-2021 18:09

Re: Set player view to specified trigger_camera ent?
 
This solved my case, but does not solve the issue behind attaching view to a generic entity. This is limited to trigger_camera, but at least it does what I want it to.

PHP Code:

ExecuteHam(Ham_Usecamera_entplayer_idplayer_id11.0); 

Btw... does anyone know what the sixth param of this means?

kww 06-11-2021 09:39

Re: Set player view to specified trigger_camera ent?
 
Quote:

Originally Posted by redivcram (Post 2749454)
This solved my case, but does not solve the issue behind attaching view to a generic entity. This is limited to trigger_camera, but at least it does what I want it to.

PHP Code:

ExecuteHam(Ham_Usecamera_entplayer_idplayer_id11.0); 

Btw... does anyone know what the sixth param of this means?

how are you decided that it should be equal to 1?

redivcram 06-11-2021 11:36

Re: Set player view to specified trigger_camera ent?
 
What?
I copied the function from another thread. No explanation for the sixth parameter.

DJEarthQuake 06-13-2021 21:09

Re: Set player view to specified trigger_camera ent?
 
Quote:

Originally Posted by redivcram (Post 2749454)
This solved my case, but does not solve the issue behind attaching view to a generic entity. This is limited to trigger_camera, but at least it does what I want it to.

PHP Code:

ExecuteHam(Ham_Usecamera_entplayer_idplayer_id11.0); 

Btw... does anyone know what the sixth param of this means?


EngFunc_SetView is for player views. The USE_TYPE float is when func_tracktrain is used for instance, it is the intensity. 0.1 is slow. 1.0 is normal start speed. 3.0 is full speed. Negative float is reverse on the train or same as pressing +backward. Use_type 0, is OFF. 1 is ON. 2 is USE with float added, with incrementing speed each activation until full speed is reached. 3 is TOGGLE ignoring float. So train would be full speed start and stop.

#define TOGGLE 3 would work nicer for cam in some cases to get out of it when needed instead of being stuck there by using 1.
ExecuteHam(Ham_Use, entity#_to_be_used, targetID, sourceID , TOGGLE, 1.0);

For example on Sven one could use Personal Medkit from bot or player AFK otherwise not being useful and give it to self remotely. As well as recharge it from wall charger without being in the same room even.


All times are GMT -4. The time now is 14:22.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.