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

get_user_origin() and trace_line() incompatibility


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
gabuch2
AlliedModders Donor
Join Date: Mar 2011
Location: Chile
Old 01-24-2019 , 20:33   get_user_origin() and trace_line() incompatibility
Reply With Quote #1

Hello, I'm trying to use the function trace_line() however, it expects Float values instead of integer values, which get_user_origin() is returning.

Is there any way to accomplish this without using variable conversion?

Code:
public heal_pre(weaponID) {     new id = get_pdata_ehandle(weaponID, 404, 16);     new Float:v_Player[3], Float:v_Target[3], Float:v_Return[3];     get_user_origin(id, v_Player, 1);     get_user_origin(id, v_Target, 3);     new ent = trace_line(-1, v_Player, v_Target, v_Return); [...]

Thanks in advance.
__________________
gabuch2 is offline
bad_boy
Member
Join Date: Oct 2018
Old 01-24-2019 , 21:36   Re: get_user_origin() and trace_line() incompatibility
Reply With Quote #2

PHP Code:
pevidpev_originv_Player 
You can use to that if you need the origin as a float
bad_boy is offline
gabuch2
AlliedModders Donor
Join Date: Mar 2011
Location: Chile
Old 01-24-2019 , 22:27   Re: get_user_origin() and trace_line() incompatibility
Reply With Quote #3

Yes, I can use pev() to get the player origin, but I need the extra functionality that get_user_origin() provides.
__________________
gabuch2 is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 01-25-2019 , 05:38   Re: get_user_origin() and trace_line() incompatibility
Reply With Quote #4

It's probably a bad design left over from AMX days. Use http://amxmodx.org/api/vector/IVecFVec if you have to use get_user_origin(), there's no other way.
__________________
klippy is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 01-25-2019 , 07:14   Re: get_user_origin() and trace_line() incompatibility
Reply With Quote #5

Code:
new Float:vecSrc[3], Float:vecAim[3], Float:vecViewOfs[3], Float:vecVelocity[3]; pev(pPlayer, pev_origin, vecSrc); pev(pPlayer, pev_view_ofs, vecViewOfs); // 128 it's the distance velocity_by_aim(pPlayer, 128, vecVelocity); xs_vec_add(vecSrc, vecViewOfs, vecSrc); xs_vec_add(vecSrc, vecVelocity, vecAim); // vecSrc it's eye position and vecAim it's aim position // Trace line between them
__________________









Last edited by CrazY.; 01-25-2019 at 07:15.
CrazY. is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 01-25-2019 , 07:43   Re: get_user_origin() and trace_line() incompatibility
Reply With Quote #6

Quote:
Originally Posted by CrazY. View Post
Code:
new Float:vecSrc[3], Float:vecAim[3], Float:vecViewOfs[3], Float:vecVelocity[3]; pev(pPlayer, pev_origin, vecSrc); pev(pPlayer, pev_view_ofs, vecViewOfs); // 128 it's the distance velocity_by_aim(pPlayer, 128, vecVelocity); xs_vec_add(vecSrc, vecViewOfs, vecSrc); xs_vec_add(vecSrc, vecVelocity, vecAim); // vecSrc it's eye position and vecAim it's aim position // Trace line between them
Or just call get_user_origin and do the conversion, which is the right thing to do.
__________________
klippy is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 01-25-2019 , 08:18   Re: get_user_origin() and trace_line() incompatibility
Reply With Quote #7

Might be, but both work anyway.
__________________








CrazY. is offline
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 02:08.


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