Raised This Month: $29 Target: $400
 7% 

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);

__________________
Too broke to change username to "Uberwire".
Discord: Uberwire#6773
Gamebanana: Uberwire
ModDB: uberwire

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]
https://youtu.be/aqCqwcuDv8Y
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.
__________________
Too broke to change username to "Uberwire".
Discord: Uberwire#6773
Gamebanana: Uberwire
ModDB: uberwire
redivcram is offline
kww
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...
__________________
Too broke to change username to "Uberwire".
Discord: Uberwire#6773
Gamebanana: Uberwire
ModDB: uberwire

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?
__________________
Too broke to change username to "Uberwire".
Discord: Uberwire#6773
Gamebanana: Uberwire
ModDB: uberwire
redivcram is offline
kww
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.
__________________
Too broke to change username to "Uberwire".
Discord: Uberwire#6773
Gamebanana: Uberwire
ModDB: uberwire

Last edited by redivcram; 06-11-2021 at 14:57.
redivcram is offline
Old Yesterday, 03:16
kww
This message has been deleted by kww. Reason: nvm
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 14:10.


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