Raised This Month: $ Target: $400
 0% 

get_user_origin keeps returning 0,0,0


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
jameszhao00
Junior Member
Join Date: Jan 2008
Old 01-04-2008 , 23:59   get_user_origin keeps returning 0,0,0
Reply With Quote #1

Hi,

I'm currently trying to log the player position in the client_PostThink code. However, get_user_origin keeps returning 0,0,0 as the position, even as I move around. Can anyone spot an error?
Code:
new angle[3];
new text[30];
public client_PostThink(id)
{        
    get_user_origin(id, angle, 0);
    format(text, 30, " %f, %f, %f", angle[0], angle[1], angle[2]);
    write_file("viewvec.txt", text);    
    client_print(id, print_chat, text);    
}
Thanks,
James
jameszhao00 is offline
Drak
Veteran Member
Join Date: Jul 2005
Old 01-05-2008 , 01:15   Re: get_user_origin keeps returning 0,0,0
Reply With Quote #2

Maybe using "client_PreThink" might work. Also, perhaps not having "angle" and "text" a global variable. But a local one. Like so:
Code:
public client_PreThink(id) {     new angle[3];     new text[30];     get_user_origin(id, angle, 0);     format(text, 30, " %f, %f, %f", angle[0], angle[1], angle[2]);     write_file("viewvec.txt", text);         client_print(id, print_chat, text);     }
__________________
Oh yeah
Drak is offline
Send a message via MSN to Drak
jameszhao00
Junior Member
Join Date: Jan 2008
Old 01-05-2008 , 01:40   Re: get_user_origin keeps returning 0,0,0
Reply With Quote #3

Nope. No luck. Still 0,0,0.
Here's my complete source file, if it helps.
Code:
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <fakemeta>
#include <engine>
#include <core>
new PLUGIN[]="AMXX Demo"
new AUTHOR[]="BAILOPAN"
new VERSION[]="1.00"
public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    log_amx("TestScript Plugin Inited");
}
public client_PreThink(id)
{        
    new angle[3];
    new text[30];
    get_user_origin(id, angle, 0);
    format(text, 30, " %f, %f, %f", angle[0], angle[1], angle[2]);
    write_file("viewvec.txt", text);    
    client_print(id, print_chat, text);
    
}
jameszhao00 is offline
Drak
Veteran Member
Join Date: Jul 2005
Old 01-05-2008 , 02:10   Re: get_user_origin keeps returning 0,0,0
Reply With Quote #4

Oh.. Dur.. Change:
Code:
 format(text, 30, " %f, %f, %f", angle[0], angle[1], angle[2]);
To:
Code:
 format(text, 29, " %i, %i, %i", angle[0], angle[1], angle[2]);
'get_user_origin()' doesn't return a float.

Also, that is going to be writing to a file.. A lot.. That would reach 100 lines in a few seconds.
You could make a task instead, to make it write every few seconds or so.
__________________
Oh yeah

Last edited by Drak; 01-05-2008 at 02:13.
Drak is offline
Send a message via MSN to Drak
jameszhao00
Junior Member
Join Date: Jan 2008
Old 01-05-2008 , 02:24   Re: get_user_origin keeps returning 0,0,0
Reply With Quote #5

It worked. Thank you very much. +karma

The huge text file isn't gonna be a problem. I'm analyzing aimbot behaviors, so I'm only going to record only around 100 angles deltas before each shot. Then it's straight to matlab for analysis.

I'm curious as to why the float version didn't work though. Does Pawn not autocast ints to floats?

Last edited by jameszhao00; 01-05-2008 at 02:28.
jameszhao00 is offline
Drak
Veteran Member
Join Date: Jul 2005
Old 01-05-2008 , 06:52   Re: get_user_origin keeps returning 0,0,0
Reply With Quote #6

Quote:
Originally Posted by jameszhao00 View Post
It worked. Thank you very much. +karma

The huge text file isn't gonna be a problem. I'm analyzing aimbot behaviors, so I'm only going to record only around 100 angles deltas before each shot. Then it's straight to matlab for analysis.

I'm curious as to why the float version didn't work though. Does Pawn not autocast ints to floats?
Nope. They are manually define like so:
Code:
new Float:fOrigin[3]
Although my programming knowledge is horrible. I assume, that is what you were meaning.
__________________
Oh yeah
Drak is offline
Send a message via MSN to Drak
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-05-2008 , 07:41   Re: get_user_origin keeps returning 0,0,0
Reply With Quote #7

get_user_origin (mode 0) doesn't return any angle, only player's position...

http://www.amxmodx.org/funcwiki.php?...igin&go=search

Code:
If mode is passed, the origin changes:
0 - current position (Default)
1 - Position from eyes (weapon aiming)
2 - End position from player position
3 - End position from eyes (hit point for weapon)
4 - Position from last bullet hit (only CS)
PHP Code:
static cell AMX_NATIVE_CALL get_user_origin(AMX *amxcell *params/* 3 param */
{
    
int index params[1];
    
    if (
index || index gpGlobals->maxClients)
    {
        
LogError(amxAMX_ERR_NATIVE"Invalid player id %d"index);
        return 
0;
    }
    
    
CPlayerpPlayer GET_PLAYER_POINTER_I(index);
    
    if (
pPlayer->ingame)
    {
        
int mode params[3];
        
cell *cpOrigin get_amxaddr(amxparams[2]);
        
        if (
mode == 4)
        {
            
cpOrigin[0] = (long int)pPlayer->lastHit.x;
            
cpOrigin[1] = (long int)pPlayer->lastHit.y;
            
cpOrigin[2] = (long int)pPlayer->lastHit.z;
            return 
1;
        }
        
        
edict_tedict pPlayer->pEdict;
        
Vector pos edict->v.origin;
        
        if (
mode && mode != 2)
            
pos pos edict->v.view_ofs;
        
        if (
mode 1)
        {
            
Vector vec;
            
Vector v_angle edict->v.v_angle;
            
float v_vec[3];
            
            
v_vec[0] = v_angle.x;
            
v_vec[1] = v_angle.y;
            
v_vec[2] = v_angle.z;
            
            
ANGLEVECTORS(v_vecvecNULLNULL);
            
TraceResult trEnd;
            
Vector v_dest pos vec 9999;
            
            
float f_pos[3];
            
f_pos[0] = pos.x;
            
f_pos[1] = pos.y;
            
f_pos[2] = pos.z;
            
            
float f_dest[3];
            
f_dest[0] = v_dest.x;
            
f_dest[1] = v_dest.y;
            
f_dest[2] = v_dest.z;
            
            
TRACE_LINE(f_posf_dest0edict, &trEnd);
            
pos = (trEnd.flFraction 1.0) ? trEnd.vecEndPos Vector(000);
        }
        
cpOrigin[0] = (long int)pos.x;
        
cpOrigin[1] = (long int)pos.y;
        
cpOrigin[2] = (long int)pos.z;
        
        return 
1;
    }
    
    return 
0;


May be you could check pev_v_angle
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
jameszhao00
Junior Member
Join Date: Jan 2008
Old 01-05-2008 , 14:37   Re: get_user_origin keeps returning 0,0,0
Reply With Quote #8

I was only debugging my code with mode 0. I originally did mode 3 - mode 1, which returns the view vector. Then in my other program I batch convert them to angles.

Edit. Now I look at it, it does include traceline, which is a bit heavy. Does anyone know if pev_v_angle returns ints or floats?

Edit: Here's the weird part. pev_v_angle only returns x,y view dir, but not z.
Code:
    new Float:angle[3];
    new text[30];
    pev(id, pev_v_angle, angle);
    format(text, 30, " %f, %f, %f", angle[0], angle[1], angle[2]);
Edit: NVM. I think it's strictly the view angle, which doesn't have a z. I was thinking of the view vectors.

Last edited by jameszhao00; 01-05-2008 at 15:00.
jameszhao00 is offline
Reply



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


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