Raised This Month: $12 Target: $400
 3% 

Solved Set player view to specified trigger_camera ent?


Post New Thread Reply   
 
Thread Tools Display Modes
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
DeMNiX
Veteran Member
Join Date: Nov 2011
Location: Russia
Old 06-09-2021 , 22:16   Re: Set player view to specified trigger_camera ent?
Reply With Quote #2

what is g_ent's value? i think its equal zero when u call /cam
__________________
My channel with test codes
https://www.youtube.com/user/demnix03

Zombie Riot [Scenario & bots-zombie 11.11.2023]
https://youtu.be/8ZZan-aq2sc
DeMNiX is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-10-2021 , 02:18   Re: Set player view to specified trigger_camera ent?
Reply With Quote #3

Add another set of () to the while condition.
__________________

Last edited by HamletEagle; 06-10-2021 at 02:18.
HamletEagle is offline
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 06-10-2021 , 08:11   Re: Set player view to specified trigger_camera ent?
Reply With Quote #4

Server prints the log message. Cam's index happens to be 51 currently.
redivcram is offline
kww
Senior Member
Join Date: Feb 2021
Location: Russia
Old 06-10-2021 , 09:07   Re: Set player view to specified trigger_camera ent?
Reply With Quote #5

Quote:
Originally Posted by redivcram View Post
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);

Last edited by kww; 06-10-2021 at 09:08.
kww is offline
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 06-10-2021 , 13:50   Re: Set player view to specified trigger_camera ent?
Reply With Quote #6

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...

Last edited by redivcram; 06-10-2021 at 14:04.
redivcram is offline
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 06-10-2021 , 18:09   Re: Set player view to specified trigger_camera ent?
Reply With Quote #7

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?
redivcram is offline
kww
Senior Member
Join Date: Feb 2021
Location: Russia
Old 06-11-2021 , 09:39   Re: Set player view to specified trigger_camera ent?
Reply With Quote #8

Quote:
Originally Posted by redivcram View Post
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?
kww is offline
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 06-11-2021 , 11:36   Re: Set player view to specified trigger_camera ent?
Reply With Quote #9

What?
I copied the function from another thread. No explanation for the sixth parameter.

Last edited by redivcram; 06-11-2021 at 14:57.
redivcram is offline
Old 06-12-2021, 03:16
kww
This message has been deleted by kww. Reason: nvm
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 06-13-2021 , 21:09   Re: Set player view to specified trigger_camera ent?
Reply With Quote #10

Quote:
Originally Posted by redivcram View Post
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.
__________________

Last edited by DJEarthQuake; 06-13-2021 at 21:27.
DJEarthQuake is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:25.


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