AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   First Person View on another player help (https://forums.alliedmods.net/showthread.php?t=61495)

-hi- 10-02-2007 00:48

First Person View on another player help
 
Hey all,

I'm writing a plugin that will allow a player to spectate another player in first-person view without joining the spectators team. The following code does exactly what I want except for one thing: the model of the player is still visible when I'm spectating them. Is there a way to make it so the camera entity does not see the model of the player it is following? (The camera is right at the spectatee's eye level so I'm always seeing the back of their neck basically.)

Code:
#include <amxmodx> #include <amxmisc> #include <engine> #define PLUGIN "Eye Spectating" #define VERSION "1.0" #define AUTHOR "hi" #pragma semicolon 1 new g_cameras[33];          // g_cameras[id] contains index of camera above the spectatEE new g_eyeingWho[33];        // g_eyeingWho[id] will contain player id of the spectatEE (id is of spectatOR) new Float:g_fPos[33][3];    // float origins of users new Float:g_fAngles[33][3]; // float angles of users (where they're looking) public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR);     register_clcmd("say", "hookSay", 0, "");     register_clcmd("say angles", "angles", 0, "");     register_clcmd("say origins", "origins", 0, ""); } public plugin_precache() {     precache_model("models/bomblet.mdl"); } public origins(id, level, cid) {     new origin1[3], origin2[3];     get_user_origin(id, origin1);     get_user_origin(id, origin2, 1);     client_print(id, print_chat, "%d %d %d", origin1[0], origin1[1], origin1[2]);     client_print(id, print_chat, "%d %d %d", origin2[0], origin2[1], origin2[2]); } public angles(id, level, cid) {     new Float:angles[3];     entity_get_vector(id, EV_VEC_angles, angles);     client_print(id, print_chat, "user angles: %d %d %d", floatround(angles[0]), floatround(angles[1]), floatround(angles[2])); } public hookSay(id, level, cid) {     new args[256];     read_args(args, 255);     remove_quotes(args);     if (equali(args, "/eye", 4)) {         if (containi(args, "off") != -1) {             if (g_eyeingWho[id]) {                 g_eyeingWho[id] = 0;                 // todo: finish this             } else {                 client_print(id, print_chat, "You weren't eyeing anyone!");             }             return PLUGIN_HANDLED;         }         new name[128];         parse(args[4], name, 127);         new target = cmd_target(id, name, 6);         if (target) {             new cam;             cam = create_entity("info_target");             entity_set_model(cam, "models/bomblet.mdl");             entity_set_edict(cam, EV_ENT_pContainingEntity, target);             g_cameras[target] = cam;             attach_view(id, cam);         } else {             client_print(id, print_chat, "ERROR: can't find player %s (be more specific, use quotes to enclose spaces)", name);         }         return PLUGIN_HANDLED;     }     return PLUGIN_CONTINUE; } public client_PreThink(id) {     if (g_cameras[id]) {         entity_get_vector(id, EV_VEC_origin, g_fPos[id]);         entity_get_vector(id, EV_VEC_angles, g_fAngles[id]);         g_fPos[id][2] += 28.0;  // moves camera to eye level         g_fAngles[id][0] *= -3.0; // makes the angle come out right         entity_set_origin(g_cameras[id], g_fPos[id]);         entity_set_vector(g_cameras[id], EV_VEC_angles, g_fAngles[id]);     } }

Wilson [29th ID] 10-02-2007 03:32

Re: First Person View on another player help
 
Set its aiment to the client it's following. That should prevent you from seeing him.

If pev_aiment doesn't do it, do it in EntityState

-hi- 10-02-2007 15:39

Re: First Person View on another player help
 
1 Attachment(s)
I used the following to set the aiment, but I can still see the model of the player I'm following:

Code:

if (target) {
  new cam;           
  cam = create_entity("info_target");
  entity_set_model(cam, "models/bomblet.mdl");
  entity_set_edict(cam, EV_ENT_aiment, target);
  g_cameras[target] = cam;
  attach_view(id, cam);
}

See the attached screenshot for what this looks like.

I used EntityState in the following manner and it crashes the game:

Code:

if (target) {           
    new
cam;           
    cam = create_entity("info_target");           
    entity_set_model(cam, "models/bomblet.mdl");           
    //entity_set_edict(cam, EV_ENT_aiment, target);
           
    set_es(cam, ES_AimEnt, target);           
    g_cameras[target] = cam;           
    attach_view(id, cam);       
}


Wilson [29th ID] 10-02-2007 20:17

Re: First Person View on another player help
 
That's not how you do it with entity state.

Code:
new target; public plugin_init() {    register_forward( FM_UpdateClientData, "hook_UpdateClientData_post", 1 ); } public hook_AddToFullPack_post( es_handle, e, entid, host, hostflags, player, pSet ) {    if( player && target )    {       set_es( entid, ES_AimEnt, target );    } }

Hopefully that gives you the idea.
Make sure you include fakemeta.

-hi- 10-03-2007 17:20

Re: First Person View on another player help
 
I played around with this a lot, and the model is still visible. Is there a property that the "player" entity has that makes it so it doesn't see's it's own model?

Wilson [29th ID] 10-04-2007 03:43

Re: First Person View on another player help
 
No there isn't a property. I wish there was. I was trying to achieve almost the exact opposite a while back, here: http://forums.alliedmods.net/showthread.php?t=52441


All times are GMT -4. The time now is 03:33.

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