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

[BUG] attach_view()


  
 
 
Thread Tools Display Modes
Author Message
rain
Senior Member
Join Date: Oct 2004
Location: Poland
Old 06-09-2006 , 11:54   [BUG] attach_view()
#1

I tried to achieve the attach_view to player functionality. In fact creating an entity to follow player yields no results. Attach_view is always attached to the same place (despite changing entity coordinates).

I don't know, I thought I may be doing something wrong, but searching through the forums revealed more cases of '(0,0,0)' problem.

Tested on 1.71.

Thank you in advance for any comments.
rain is offline
BAILOPAN
Join Date: Jan 2004
Old 06-09-2006 , 19:31  
#2

did you read this first? http://forums.alliedmods.net/showthread.php?t=19356
__________________
egg
BAILOPAN is offline
rain
Senior Member
Join Date: Oct 2004
Location: Poland
Old 06-10-2006 , 09:15  
#3

Sure I read it. But the problem described in that topic seems to be with attaching directly to another player. And OK, I know it's not an intended feature. But I can't really attach_view to any artificially created entity (no matter if it's really player follower or sth other - like remote cameras etc.). Only internal entities of HL engine seem to work (as with grenades in 'Steer your nade').
rain is offline
jtp10181
Veteran Member
Join Date: May 2004
Location: Madison, WI
Old 06-10-2006 , 10:04  
#4

you can't use attach_view on players. You can however use it on created entities, the entity just has to have certain step done on it. I think it has to have a model and some other properties set.

If you are trying to make something to follow the view of another player in first person I have already done this and I can tell it does not work very well. The created entity lags behind the player a little when they are moving fast so the view gets screwed up.

Here was my code in progress, I was trying to make it so you could record a demo of a player without being in SPEC mode. This should help you test it yourself and come to the same realization I did.

Code:
/* AMX Mod X script. * *  AMX Hacker Tools (amx_hacker_tools.sma) *  Copyright (C) 2004  jtp10181 * *  This program is free software; you can redistribute it and/or modify it *  under the terms of the GNU General Public License as published by the *  Free Software Foundation; either version 2 of the License, or (at *  your option) any later version. * *  This program is distributed in the hope that it will be useful, but *  WITHOUT ANY WARRANTY; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *  General Public License for more details. * *  You should have received a copy of the GNU General Public License *  along with this program; if not, write to the Free Software Foundation, *  Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *  In addition, as a special exception, the author gives permission to *  link the code of this program with the Half-Life Game Engine ("HL *  Engine") and Modified Game Libraries ("MODs") developed by Valve, *  L.L.C ("Valve"). You must obey the GNU General Public License in all *  respects for all of the code used other than the HL Engine and MODs *  from Valve. If you modify this file, you may extend this exception *  to your version of the file, but you are not obligated to do so. If *  you do not wish to do so, delete this exception statement from your *  version. */ #include <amxmodx> #include <amxmisc> #include <engine> new isRecording[33] new hEyes[33] public plugin_init() {     register_plugin("Hacker Tools","0.2","JTP10181");     //register_clcmd("amx_hackss","admin_hack_snapshot", ADMIN_LEVEL_A ,"<authid, nick or #userid>");     register_clcmd("amx_hdemo","admin_hack_demo", ADMIN_LEVEL_A ,"[authid, nick or #userid]"); } public client_connect(id) {     isRecording[id] = 0 } public plugin_precache() {     precache_model("models/rpgrocket.mdl") } /* public client_PreThink(id) {     if (isRecording[id] && is_valid_ent(hEyes[id])) {         new Float:flOrigin[3], iOrigin[3], Float:vAngles[3], Float:Angles[3]         get_user_origin(isRecording[id], iOrigin, 1)         IVecFVec(iOrigin, flOrigin)         entity_get_vector(isRecording[id], EV_VEC_v_angle, vAngles)         entity_get_vector(isRecording[id], EV_VEC_angles, Angles)         attach_view(id,hEyes[id])         entity_set_origin(hEyes[id], flOrigin)         entity_set_vector(hEyes[id], EV_VEC_v_angle, vAngles)         entity_set_vector(hEyes[id], EV_VEC_angles, Angles)     } } */ public admin_hack_demo(id,level,cid) {     if (!cmd_access(id,level,cid,1)) return PLUGIN_HANDLED     new numbargs = read_argc()     if (numbargs == 2 && isRecording[id]) {         console_print(id, "[AMXX] You are already recording, to stop use the command with no arguments.")         return PLUGIN_HANDLED     }     else if (numbargs == 1 && isRecording[id]) {         stop_recording(id)     }     else if (numbargs == 2) {         new arg[32]         read_argv(1,arg,31)         new hid = cmd_target(id,arg,0)         if (!hid) return PLUGIN_HANDLED         start_recording(id, hid)     }     else {         console_print(id, "Usage:  amx_hdemo [authid, nick or #userid]")         return PLUGIN_HANDLED     }     return PLUGIN_HANDLED } public start_recording(id, hid) {     /*     pNewCamera = CREATE_NAMED_ENTITY(MAKE_STRING("info_target"));     pNewCamera->v.classname = MAKE_STRING("VexdCam");     SET_MODEL(pNewCamera, "models/rpgrocket.mdl");     SET_SIZE(pNewCamera, Vector(0, 0, 0), Vector(0, 0, 0));     pNewCamera->v.movetype = MOVETYPE_NOCLIP;     pNewCamera->v.solid = SOLID_NOT;     pNewCamera->v.takedamage = DAMAGE_NO;     pNewCamera->v.gravity = 0;     pNewCamera->v.owner = pPlayer;     pNewCamera->v.rendermode = kRenderTransColor;     pNewCamera->v.renderamt = 0;     pNewCamera->v.renderfx = kRenderFxNone;     */     new Float:flOrigin[3], iOrigin[3], Float:vAngles[3], Float:Angles[3]     get_user_origin(hid, iOrigin, 1)     IVecFVec(iOrigin, flOrigin)     entity_get_vector(hid, EV_VEC_v_angle, vAngles)     entity_get_vector(hid, EV_VEC_angles, vAngles)     hEyes[id] = create_entity("info_target")     entity_set_string(hEyes[id], EV_SZ_classname, "hackerdemo_eyes")     entity_set_model(hEyes[id], "models/rpgrocket.mdl")     entity_set_edict(hEyes[id], EV_ENT_aiment, hid)     entity_set_int(hEyes[id], EV_INT_movetype, MOVETYPE_FOLLOW)     //entity_set_int(hEyes[id], EV_INT_movetype, MOVETYPE_NOCLIP)     //entity_set_size(follow, Float:{-1.0, -1.0, -1.0}, Float:{1.0, 1.0, 1.0})     entity_set_int(hEyes[id], EV_INT_solid, SOLID_NOT)     entity_set_float(hEyes[id], EV_FL_dmg_take, 0.0)     entity_set_float(hEyes[id], EV_FL_gravity, 0.0)     entity_set_edict(hEyes[id], EV_ENT_owner, id)     entity_set_int(hEyes[id], EV_INT_rendermode, kRenderTransColor)     entity_set_float(hEyes[id], EV_FL_renderamt, 0.0)     entity_set_int(hEyes[id], EV_INT_renderfx, kRenderFxNone)     attach_view(id, hEyes[id])     entity_set_origin(hEyes[id], flOrigin)     entity_set_vector(hEyes[id], EV_VEC_v_angle, vAngles)     entity_set_vector(hEyes[id], EV_VEC_angles, Angles)     isRecording[id] = hid } public stop_recording(id) {     attach_view(id, id)     isRecording[id] = 0     hEyes[id] = 0     //Kill the entity     entity_set_int(hEyes[id], EV_INT_flags, entity_get_int(hEyes[id], EV_INT_flags)|FL_KILLME) } public admin_hack_snapshot(id,level,cid) {     if (!cmd_access(id,level,cid,2)) return PLUGIN_HANDLED     new arg[32]     read_argv(1,arg,31)     new hid = cmd_target(id,arg,12)     if (!hid) return PLUGIN_HANDLED     new red = random_num(50,255)     new green = random_num(50,255)     new blue = random_num(50,255)     new red2 = random_num(50,255)     new green2 = random_num(50,255)     new blue2 = random_num(50,255)     new red3 = random_num(50,255)     new green3 = random_num(50,255)     new blue3 = random_num(50,255)     new red4 = random_num(50,255)     new green4 = random_num(50,255)     new blue4 = random_num(50,255)     new randmsg[14],randmsg2[10],randmsg3[10],randmsg4[10]     num_to_str(random_num(100000000000,999999999999),randmsg,13)     num_to_str(random_num(1000000,9999999),randmsg2,9)     num_to_str(random_num(1000000,9999999),randmsg3,9)     num_to_str(random_num(1000000,9999999),randmsg4,9)     new Float:rx1 = random_float(0.10,0.80)     new Float:ry1 = random_float(0.10,0.80)     new Float:rx2 = random_float(0.10,0.80)     new Float:ry2 = random_float(0.10,0.80)     new Float:rx3 = random_float(0.10,0.80)     new Float:ry3 = random_float(0.10,0.80)     set_hudmessage(red,green,blue, -1.0, 0.25, 0, 0.02, 2.0, 0.0, 0.3, 1)     show_hudmessage(id,randmsg)     show_hudmessage(hid,randmsg)     set_hudmessage(red2,green2,blue2,rx1,ry1, 0, 0.02, 2.0, 0.0, 0.3, 2)     show_hudmessage(id,randmsg2)     show_hudmessage(hid,randmsg2)     set_hudmessage(red3,green3,blue3,rx2,ry2, 0, 0.02, 2.0, 0.0, 0.3, 3)     show_hudmessage(id,randmsg3)     show_hudmessage(hid,randmsg3)     set_hudmessage(red4,green4,blue4,rx3,ry3, 0, 0.02, 2.0, 0.0, 0.3, 4)     show_hudmessage(id,randmsg4)     show_hudmessage(hid,randmsg4)     new idx[1], hidx[1]     idx[0] = id     hidx[0] = hid     set_task(0.3,"snapshot_task",0,idx,1)     set_task(0.3,"snapshot_task",0,hidx,1)     set_task(1.0,"motd_message",0,hidx,1)     return PLUGIN_CONTINUE } public snapshot_task(idx[1]) {     new id = idx[0]     client_cmd(id,"snapshot")     return PLUGIN_CONTINUE } public motd_message(idx[1]) {     new id = idx[0]     new buffer[2501]     new len = 0     #if !defined NO_STEAM     len += copy( buffer[len], 2500-len , "<html><head><style type=^"text/css^">pre{color:#FFB000;font-size:18px;}body{background:#000000;margin-left:8px;margin-top:0px;}</style></head><body><pre>")     #endif     len += copy( buffer[len], 2500-len , "You have been suspected of hacking^n^n")     len += copy( buffer[len], 2500-len , "Random HUD messages were printed to your screen and a screenshot was taken.^n^n")     len += copy( buffer[len], 2500-len , "Please e-mail this to <a href="mailto:fix@replace.com">[email protected]</a> within 24 hours or you will be banned.")     #if !defined NO_STEAM     len += copy( buffer[len], 2500-len , "</pre></body></html>")     #endif     show_motd(id,buffer,"Possible Hacker")     return PLUGIN_CONTINUE }
__________________
jtp10181 is offline
Send a message via ICQ to jtp10181 Send a message via AIM to jtp10181 Send a message via MSN to jtp10181 Send a message via Yahoo to jtp10181
rain
Senior Member
Join Date: Oct 2004
Location: Poland
Old 06-10-2006 , 12:24  
#5

Big thanks jtp10181. It seems you resolved my problem. Though you will have to wait a bit as my karma is depleted. :-)

Getting to the point, after some testing it seems that attach_view() works only on entities who posses a real model. Maybe this is some obvious HL internal thing (at least it wasn't for me), but it is worth mentioning in the function Wiki, it could spare some poor coding hours.

Heck, I was so close. Even tried setting the model, forgot about precaching.

By the way, I almost fell off my chair when I saw your script. It's a pity you hadn't published it. I wouldn't have to reinvent the wheel. In fact this is exactly what I coded, ehm, wanted to code. (admin_hack_snapshot() function) - just that I used md5 hashes of local time+secret for screen fingerprinting. ;-)

Sorry BAILOPAN for bothering you with not really good bug report. I know how frustrating for devs it can be. Hope you won't get angry. Nevertheless, I would be really glad to see some little modifications to the docs.

And for the resolver, once more - thank you jtp10181. Your aid is highly appreciated.
rain is offline
BAILOPAN
Join Date: Jan 2004
Old 06-10-2006 , 14:13  
#6

attach_view is a crazy native ported from AMX Mod a long time ago. Not too many people understand it (myself included), so it probably would be a good idea for someone to write something helpful on the funcwiki.
__________________
egg
BAILOPAN is offline
 



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 08:24.


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