View Single Post
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