AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   need small fix (https://forums.alliedmods.net/showthread.php?t=207904)

avril-lavigne 02-08-2013 02:27

need small fix
 
Im trying to make simple fake death and vengeance plugin
I need help with spawn behind killers back.
can i use specified set_user_origin like origin[1]-20 . [2]+30. [3]+40 ???





PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <fun>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "me"

new Float:origin[3]

new 
g_MaxPlayers;
#define IsPlayer(%1)  ( 1 <= %1 <= g_MaxPlayers )

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
RegisterHamHam_TakeDamage "player" "fw_HamTakeDamage" );
    
g_MaxPlayers get_maxplayers();
}


public 
fw_HamTakeDamageiVictim iInflictor iAttacker Float:fDamage iBitDamage 
{   
    if ( 
IsPlayeriAttacker ) && fDamage 85 ) {  
    
set_pev iVictimpev_deadflagDEAD_DYING )
    
set_pev(iVictimpev_framerate0.7);
    }
    
    if ( 
IsPlayeriAttacker ) && fDamage 95 ) {
    
set_pev(iVictimpev_deadflagDEAD_DEAD);
    
ExecuteHam(Ham_KillediVictimiAttacker0// just for testing what is better 
    
set_user_frags(iVictim,get_user_frags(iVictim) +1)
    
get_user_origin(iAttacker,origin,2)
    
set_task(2.0,"respawn_123",iVictim)
    }

}

public 
respawn_123(id) { 
   
set_pev(idpev_deadflagDEAD_NO);
   
spawn(id)   // or execute ham cs round respawn
   
set_user_origin(id,origin)   // i need here to spawn in attacker positions< but better if behind his back




naven 02-08-2013 02:49

Re: need small fix
 
Yes, but
Code:

origin[1]-20 . [2]+30. [3]+40 ???
Is not correct, you should use
Code:

origin[0] -= 20.0;
origin[1] += 30.0;
origin[2] += 40.0;


avril-lavigne 02-08-2013 02:52

Re: need small fix
 
I know I said it just for example.

so how to set_origin using these 3 coords.

naven 02-08-2013 03:08

Re: need small fix
 
Code:

entity_get_vector(id, EV_VEC_origin, origin)
Code:

entity_set_vector(id, EV_VEC_origin, origin)

simanovich 02-08-2013 03:16

Re: need small fix
 
Fakemeta version:

PHP Code:

// Get
pev(entity,pev_origin,origin,3);

// Set
set_pev(entity,pev_originorigin); 


Sylwester 02-08-2013 04:13

Re: need small fix
 
check this: https://forums.alliedmods.net/showth...44#post1681544

avril-lavigne 02-08-2013 13:40

Re: need small fix
 
dont understand this should work> but


PHP Code:

public fw_HamTakeDamageiVictim iInflictor iAttacker Float:fDamage iBitDamage 
{   
   
    
    if ( 
IsPlayeriAttacker ) && fDamage 80 )    
    
teleport_behindiAttackeriVictim )
    

}


public 
teleport_behind(idtarget){
 
   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)


I did as in your example just without console command
id = iAttacker , traget = iVictim
but its not working.

Sylwester 02-08-2013 14:47

Re: need small fix
 
What is not working? My function or your part of code?
Also id is player who will be teleported behind target, so id = iVictim, target = iAttacker.

avril-lavigne 02-08-2013 14:53

Re: need small fix
 
oh, yes , fantastic, it works
thank you silwester


All times are GMT -4. The time now is 20:34.

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