Raised This Month: $ Target: $400
 0% 

[REQUEST] Teleport in the target's head or behind.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
h3h3
Senior Member
Join Date: Sep 2011
Old 02-08-2012 , 06:33   [REQUEST] Teleport in the target's head or behind.
Reply With Quote #1

Hello, I'm looking for a plugin that teleport me to the target's head [example] or behind whenever he is in the map.
the command will be amx_stack x (x=traget's name).

Thanks in advance.

Last edited by h3h3; 04-03-2012 at 19:49.
h3h3 is offline
Old 02-15-2012, 14:08
h3h3
This message has been deleted by Exolent[jNr]. Reason: Don't bump until 2 weeks have passed since last post. That was 7 days, not 13.
h3h3
Senior Member
Join Date: Sep 2011
Old 03-04-2012 , 05:22   Re: looking for plugin that does what admin_stack does, but reverse.
Reply With Quote #2

bump
h3h3 is offline
h3h3
Senior Member
Join Date: Sep 2011
Old 04-03-2012 , 19:18   Re: looking for plugin that does what admin_stack does, but reverse.
Reply With Quote #3

bump
h3h3 is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 04-04-2012 , 03:50   Re: [REQUEST] Teleport in the target's head or behind.
Reply With Quote #4

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>

new Float:_pg_ftmp
#define _Vec3ToAngles(%1,%2) _pg_ftmp = floatsqroot(%1[0]*%1[0] + %1[1]*%1[1]);\
    
%2[1] = floatacos(%1[0]/_pg_ftmp1)*(1-2*_:(%1[1]<0));\
    %
2[0] =-floatatan(%1[2]/_pg_ftmp1);\
    %
2[2] = 0.0

#define _Vec3AddScalar(%1,%2) %1[0]+=%2;%1[1]+=%2;%1[2]+=%2
#define _Vec3Set(%1,%2) %1[0]=%2[0];%1[1]=%2[1];%1[2]=%2[2]
#define _Vec3Add(%1,%2) %1[0]+=%2[0];%1[1]+=%2[1];%1[2]+=%2[2]   


public plugin_init() {
    
register_plugin("Teleport Behind Target""1.0""Sylwester");
    
register_clcmd("amx_stack""cmd_stack"ADMIN_KICK" <target> - teleports you behind target")
}


public 
cmd_stack(idlevelcid){
    if(!
cmd_access(idlevelcid2))
        return 
PLUGIN_HANDLED
    
new args[32]
    
read_args(argssizeof(args)-1)
    
trim(args)
    
remove_quotes(args)
    new 
target cmd_target(idargs4)
    if(!
target){
        
client_print(idprint_console"Error: Could not find player %s"args)
        return 
PLUGIN_HANDLED
    
}
    
teleport_behind(idtarget)
    return 
PLUGIN_HANDLED
}


public 
teleport_behind(idtarget){
    if(!
is_user_alive(id) || !is_user_alive(target)){
        
client_print(idprint_console"Error: you and your target must be alive")
        return
    }

    new 
Float:vec[3], Float:origin[3], Float:fractionFloat:ftmp[3], Float:ftmp2[3], Float:ftmp3[3], Float:ftmp4[3], Float:len2trij
    
    velocity_by_aim
(target1vec)
    new 
Float:len floatsqroot(vec[0]*vec[0]+vec[1]*vec[1])
    
    
pev(targetpev_originorigin)
    
ftmp3[0] = origin[0]-vec[0]*50.0/len
    ftmp3
[1] = origin[1]-vec[1]*50.0/len
    ftmp3
[2] = origin[2]+5.0

    ftmp4
[0] = origin[0]-vec[0]*10.0/len
    ftmp4
[1] = origin[1]-vec[1]*10.0/len
    ftmp4
[2] = origin[2]+91.0
    
    
for(j=0j<20j++){
        if(
j<15){
            
_Vec3Set(ftmpftmp3)
        }else{
            
_Vec3Set(ftmpftmp4)
        }
        for(
i=0i<100i++){      
            
engfunc(EngFunc_TraceHullftmpftmp0HULL_HUMAN0tr)
            if(
get_tr2(trTR_StartSolid) || get_tr2(trTR_AllSolid)){
                
_Vec3AddScalar(ftmprandom_float(-10.010.0))
                continue
            }   
            
engfunc(EngFunc_TraceLineoriginftmpIGNORE_MONSTERS0tr)
            
get_tr2(trTR_flFractionfraction)
            break
        }
        if(
fraction == 1.0){
            
_Vec3Set(ftmp2ftmp)    
            
_Vec3Add(ftmp2, -origin)            
            
len2 len*floatsqroot(ftmp2[0]*ftmp2[0]+ftmp2[1]*ftmp2[1]+ftmp2[2]*ftmp2[2])
            if(
len2 100.0 || (ftmp2[0]*vec[0]+ftmp2[1]*vec[1])/len2 0.1){
                
fraction 0.0
                
continue
            }
            break
        }
    }

    if(
fraction !=1.0){
        
//failed to find correct position behind target
        
return
    }
    
    
set_pev(idpev_originftmp)
    
    
_Vec3Set(ftmp, -ftmp)        
    
_Vec3Add(ftmporigin)
    
_Vec3ToAngles(ftmpftmp)    
    
    
set_pev(idpev_anglesftmp)
    
set_pev(idpev_fixangle1)

__________________
Impossible is Nothing

Last edited by Sylwester; 04-04-2012 at 03:51.
Sylwester is offline
h3h3
Senior Member
Join Date: Sep 2011
Old 04-04-2012 , 06:04   Re: [REQUEST] Teleport in the target's head or behind.
Reply With Quote #5

Quote:
Originally Posted by Sylwester View Post
[php]
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>

new Float:_pg_ftmp
#define _Vec3ToAngles(%1,%2) _pg_ftmp = floatsqroot(%1[0]*%1[0] + %1[1]*%1[1]);\
%2[1] = floatacos(%1[0]/_pg_ftmp, 1)*(1-2*_%1[1]<0));\
%2[0] =-floatatan(%1[2]/_pg_ftmp, 1);\
%2[2] = 0.0

#define _Vec3AddScalar(%1,%2) %1[0]+=%2;%1[1]+=%2;%1[2]+=%2
#define _Vec3Set(%1,%2) %1[0]=%2[0];%1[1]=%2[1];%1[2]=%2[2]
#define _Vec3Add(%1,%2) %1[0]+=%2[0];%1[1]+=%2[1];%1[2]+=%2[2]


public plugin_init() {
register_plugin("Teleport Behind Target", "1.0", "Sylwester");
register_clcmd("amx_stack", "cmd_stack", ADMIN_KICK, " <target> - teleports you behind target")
}


public cmd_stack(id, level, cid){
if(!cmd_access(id, level, cid, 2))
return PLUGIN_HANDLED
new args[32]
read_args(args, sizeof(args)-1)
trim(args)
remove_quotes(args)
new target = cmd_target(id, args, 4)
if(!target){
client_print(id, print_console, "Error: Could not find player %s", args)
return PLUGIN_HANDLED
}
teleport_behind(id, target)
return PLUGIN_HANDLED
}


public teleport_behind(id, target){
if(!is_user_alive(id) || !is_user_alive(target)){
client_print(id, print_console, "Error: you and your target must be alive")
return
}

new Float:vec[3], Floatrigin[3], Float:fraction, Float:ftmp[3], Float:ftmp2[3], Float:ftmp3[3], Float:ftmp4[3], Float:len2, tr, i, j

velocity_by_aim(target, 1, vec)
new Float:len = floatsqroot(vec[0]*vec[0]+vec[1]*vec[1])

pev(target, pev_origin, origin)
ftmp3[0] = origin[0]-vec[0]*50.0/len
ftmp3[1] = origin[1]-vec[1]*50.0/len
ftmp3[2] = origin[2]+5.0

ftmp4[0] = origin[0]-vec[0]*10.0/len
ftmp4[1] = origin[1]-vec[1]*10.0/len
ftmp4[2] = origin[2]+91.0

for(j=0; j<20; j++){
if(j<15){
_Vec3Set(ftmp, ftmp3)
}else{
_Vec3Set(ftmp, ftmp4)
}
for(i=0; i<100; i++){
engfunc(EngFunc_TraceHull, ftmp, ftmp, 0, HULL_HUMAN, 0, tr)
if(get_tr2(tr, TR_StartSolid) || get_tr2(tr, TR_AllSolid)){
_Vec3AddScalar(ftmp, random_float(-10.0, 10.0))
continue
}
engfunc(EngFunc_TraceLine, origin, ftmp, IGNORE_MONSTERS, 0, tr)
get_tr2(tr, TR_flFraction, fraction)
break
}
if(fraction == 1.0){
_Vec3Set(ftmp2, ftmp)
_Vec3Add(ftmp2, -origin)
len2 = len*floatsqroot(ftmp2[0]*ftmp2[0]+ftmp2[1]*ftmp2[1]+ftmp2[2]*ftmp2[2])
if(len2 > 100.0 || (ftmp2[0]*vec[0]+ftmp2[1]*vec[1])/len2 > 0.1){
fraction = 0.0
continue
}
break
}
}

if(fraction !=1.0){
//failed to find correct position behind target
return
}

set_pev(id, pev_origin, ftmp)

_Vec3Set(ftmp, -ftmp)
_Vec3Add(ftmp, origin)
_Vec3ToAngles(ftmp, ftmp)

set_pev(id, pev_angles, ftmp)
set_pev(id, pev_fixangle, 1)
}
Thanks you very much but I couldn't compile it.

Quote:
/tmp/textyEZV0q.sma( : error 010: invalid function or declaration
/tmp/textyEZV0q.sma(101) : warning 204: symbol is assigned a value that is never used: "_pg_ftmp" 1 Error. Could not locate output file /home/groups/amxmodx/public_html/websc3/textyEZV0q.amx (compile failed).

Last edited by h3h3; 04-04-2012 at 06:06.
h3h3 is offline
bazhenov93
Veteran Member
Join Date: Oct 2010
Old 04-04-2012 , 08:28   Re: [REQUEST] Teleport in the target's head or behind.
Reply With Quote #6

Here.
Attached Files
File Type: sma Get Plugin or Get Source (test.sma - 645 views - 3.1 KB)
bazhenov93 is offline
h3h3
Senior Member
Join Date: Sep 2011
Old 04-04-2012 , 10:40   Re: [REQUEST] Teleport in the target's head or behind.
Reply With Quote #7

Works.
thanks you very much guys, have a nice day.
h3h3 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 20:34.


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