AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
02-09-2016
, 10:30
Re: Error get_user_origin
#5
Probably not the most precise approach, but it should do what you want. I may work later on this, if something is not working as you want.
Spoiler
PHP Code:
#include <amxmodx> #include <fakemeta> #include <xs> public plugin_init () { register_clcmd ( "say /tp" , "ClientCommand_Teleport" ) } public ClientCommand_Teleport ( id ) { new Float : playerOrigin [ 3 ], Float : playerViewOffset [ 3 ] pev ( id , pev_origin , playerOrigin ) pev ( id , pev_view_ofs , playerViewOffset ) xs_vec_add ( playerOrigin , playerViewOffset , playerOrigin ) new Float : playerViewAngle [ 3 ] pev ( id , pev_v_angle , playerViewAngle ) engfunc ( EngFunc_MakeVectors , playerViewAngle ) global_get ( glb_v_forward , playerViewAngle ) xs_vec_mul_scalar ( playerViewAngle , 9999.0 , playerViewAngle ) xs_vec_add ( playerOrigin , playerViewAngle , playerViewAngle ) new handleTraceLine , Float : traceLineEndPos [ 3 ] engfunc ( EngFunc_TraceLine , playerOrigin , playerViewAngle , IGNORE_MONSTERS , id , handleTraceLine ) get_tr2 ( 0 , TR_vecEndPos , traceLineEndPos ) new startDistance = 5 if( validSpotFound ( id , traceLineEndPos )) { set_pev ( id , pev_origin , traceLineEndPos ) } else { new restrictMaxSearches = 150 , i , Float : foundOrigin [ 3 ] while(-- restrictMaxSearches > 0 ) { for( i = 0 ; i < 3 ; i ++) { foundOrigin [ i ] = random_float ( traceLineEndPos [ i ] - startDistance , traceLineEndPos [ i ] + startDistance ) } if( validSpotFound ( id , foundOrigin )) { set_pev ( id , pev_origin , foundOrigin ) break } else { startDistance = startDistance + 1 } } } } bool : validSpotFound ( id , Float : Origin [ 3 ]) { new handleTraceHull engfunc ( EngFunc_TraceHull , Origin , Origin , IGNORE_MONSTERS , pev ( id , pev_flags ) & FL_DUCKING ? HULL_HEAD : HULL_HUMAN , id , handleTraceHull ) if( get_tr2 ( handleTraceHull , TR_InOpen ) && !( get_tr2 ( handleTraceHull , TR_StartSolid ) || get_tr2 ( handleTraceHull , TR_AllSolid ))) { return true } return false }
__________________
Last edited by HamletEagle; 02-09-2016 at 10:34 .