Raised This Month: $ Target: $400
 0% 

need small fix


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
avril-lavigne
Banned
Join Date: Apr 2009
Old 02-08-2013 , 02:27   need small fix
Reply With Quote #1

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


__________________
VDS in Europe 1 gb/s unmetered.Any configurations.
I accept Paypal, Moneybookers,etc

Last edited by avril-lavigne; 02-08-2013 at 02:32.
avril-lavigne is offline
naven
Veteran Member
Join Date: Jun 2008
Location: Poland, Cieszyn
Old 02-08-2013 , 02:49   Re: need small fix
Reply With Quote #2

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;
__________________
naven.com.pl
"At the end of the day, there are always going to be mental disorders and people who cause violence for no other reason than the fact that they're fucked up and lost. And all we can do is try to learn from it." Corey Taylor.

Last edited by naven; 02-08-2013 at 02:51.
naven is offline
avril-lavigne
Banned
Join Date: Apr 2009
Old 02-08-2013 , 02:52   Re: need small fix
Reply With Quote #3

I know I said it just for example.

so how to set_origin using these 3 coords.
__________________
VDS in Europe 1 gb/s unmetered.Any configurations.
I accept Paypal, Moneybookers,etc
avril-lavigne is offline
naven
Veteran Member
Join Date: Jun 2008
Location: Poland, Cieszyn
Old 02-08-2013 , 03:08   Re: need small fix
Reply With Quote #4

Code:
entity_get_vector(id, EV_VEC_origin, origin)
Code:
entity_set_vector(id, EV_VEC_origin, origin)
__________________
naven.com.pl
"At the end of the day, there are always going to be mental disorders and people who cause violence for no other reason than the fact that they're fucked up and lost. And all we can do is try to learn from it." Corey Taylor.
naven is offline
simanovich
AlliedModders Donor
Join Date: Jun 2012
Location: Israel
Old 02-08-2013 , 03:16   Re: need small fix
Reply With Quote #5

Fakemeta version:

PHP Code:
// Get
pev(entity,pev_origin,origin,3);

// Set
set_pev(entity,pev_originorigin); 
__________________

Last edited by simanovich; 02-08-2013 at 03:16.
simanovich is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 02-08-2013 , 04:13   Re: need small fix
Reply With Quote #6

check this: https://forums.alliedmods.net/showth...44#post1681544
__________________
Impossible is Nothing
Sylwester is offline
avril-lavigne
Banned
Join Date: Apr 2009
Old 02-08-2013 , 13:40   Re: need small fix
Reply With Quote #7

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.
__________________
VDS in Europe 1 gb/s unmetered.Any configurations.
I accept Paypal, Moneybookers,etc

Last edited by avril-lavigne; 02-08-2013 at 14:27.
avril-lavigne is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 02-08-2013 , 14:47   Re: need small fix
Reply With Quote #8

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.
__________________
Impossible is Nothing
Sylwester is offline
avril-lavigne
Banned
Join Date: Apr 2009
Old 02-08-2013 , 14:53   Re: need small fix
Reply With Quote #9

oh, yes , fantastic, it works
thank you silwester
__________________
VDS in Europe 1 gb/s unmetered.Any configurations.
I accept Paypal, Moneybookers,etc

Last edited by avril-lavigne; 02-08-2013 at 14:55.
avril-lavigne 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