AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   ignored owner (https://forums.alliedmods.net/showthread.php?t=298960)

abdobiskra 06-27-2017 21:03

ignored owner
 
Hi
How can I ignore the owner after being selected in these cases?

1) first one solved

2)

PHP Code:

public monsters_touch(monstertarget)
{
   new array[
32]
   new 
owner pev(monsterpev_owner)
   
   
pev(targetpev_classname, array, charsmax(array))
      
   if(
equal(array, "func_door") || equal(array, "func_door_rotating") || equal(array, "func_button"))
      
use_func(targetowner)

   else if(
equal(array, "func_pushable"))
      
velocity_func(monstertarget1)
      
   else if(
equal(array, "player"))
   {   
      if(!
is_user_alive(target)) return
      
      new 
skip
      
      pev
(monsterpev_model, array, charsmax(array))
      
      if(
equal(array, "models/w_grenade.mdl"))   set_pev(monsterpev_solidSOLID_NOT)
      else if(
equal(array, "models/w_squeak.mdl"))   skip 1
      
else if(equal(array, "models/w_satchel.mdl"))   skip 0
      
else return // HLW_MP5(grenade) has NO model "o_O"
      
      
if(target != owner && get_pcvar_num(drop)) // here but no luck ( 
         
console_cmd(target"drop")
      
      
velocity_func(monstertarget2)
      
      if(!
skip)
         
hurt_func(ownertargetget_pcvar_num(pain), monster)      
   }



JusTGo 06-27-2017 21:12

Re: ignored owner
 
2)

PHP Code:

public monsters_touch(monstertarget

   new array[
32
   new 
owner pev(monsterpev_owner
    
   
pev(targetpev_classname, array, charsmax(array)) 
       
   if(
equal(array, "func_door") || equal(array, "func_door_rotating") || equal(array, "func_button")) 
      
use_func(targetowner

   else if(
equal(array, "func_pushable")) 
      
velocity_func(monstertarget1
       
   else if(
equal(array, "player")) 
   {    
      if(!
is_user_alive(target) || target == owner ) return 
       
      new 
skip 
       
      pev
(monsterpev_model, array, charsmax(array)) 
       
      if(
equal(array, "models/w_grenade.mdl"))   set_pev(monsterpev_solidSOLID_NOT
      else if(
equal(array, "models/w_squeak.mdl"))   skip 
      
else if(equal(array, "models/w_satchel.mdl"))   skip 
      
else return // HLW_MP5(grenade) has NO model "o_O" 
       
      
if(get_pcvar_num(drop)) (  
         
console_cmd(target"drop"
       
      
velocity_func(monstertarget2
       
      if(!
skip
         
hurt_func(ownertargetget_pcvar_num(pain), monster)       
   } 



abdobiskra 06-28-2017 04:07

Re: ignored owner
 
also did not work
The only problem I can see in this code that owner of the weapon possibly can't be detected this way, because in HLSDK there is often a separate field to store actual owner of the grenade (etc.) and pev->owner is empty.

JusTGo 06-28-2017 05:26

Re: ignored owner
 
show the code you are using to create the entity ?

abdobiskra 06-28-2017 05:39

Re: ignored owner
 
this full code :
PHP Code:

/*

* Date creation: / v0.1 - 07.05.11, v0.2 - 15.05.11, v0.3 - 09.07.11, v0.4 - 13.07.11, v0.4a - 18.07.11
*
* v0.1 - [first release]
* v0.2 - [removed sound on activate & few little errors]
* v0.3 - [code little rewriting]
* v0.4 - [1)added chek cvar "mp_weaponstay", 2)added cvar "amx_HL_hurt_player"]
* v0.4a - [1)added chek on hit - victim alive ?, 2)fix HANDGRENADE touch, 3)fix "4" cvar 1-st value, 4)Now support damager plugin, 5)Fixed plugin run time error with HLW_MP5(then grenade throw & weapon swiched)].
*
* http://aghl.ru/forum/ - Russian Half-Life and Adrenaline Gamer Community
*
*/

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

#define PLUGIN "activate on shoot"
#define VERSION "0.4a"
#define AUTHOR "Turanga_Leela"

new droppush, use, pain

new const func_classes[][] = 
{
    
"func_door",
    
"func_door_rotating",
    
"func_button"
}

new const 
monsters[][] = 
{
    
"monster_satchel",
    
"grenade",
    
"monster_snark"
}

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
set_task(0.0"map_restart")
    
    for(new 
usizeof func_classesu++)
        
RegisterHam(Ham_TraceAttackfunc_classes[u], "classes_TraceAttack"1)
    
    
RegisterHam(Ham_TraceAttack"func_pushable""pushable"1)
    
    for(new 
isizeof monstersi++)
        
RegisterHam(Ham_Touchmonsters[i], "monsters_touch"1)

    
drop =    register_cvar("amx_HL_drop_on_touch""1")
    
push =    register_cvar("amx_HL_push_objects""1")
    use =    
register_cvar("amx_HL_use_objects""1")
    
pain =    register_cvar("amx_HL_hurt_player""1")
}    

public 
map_restart()
{
    if(
get_cvar_num("mp_weaponstay"))
    {    
        
set_cvar_num("mp_weaponstay"0)
        
server_cmd("restart")
    }
}

public 
pushable(this)
    
velocity_func(this01)

velocity_func(entvictimmode)
{
    if(!
get_pcvar_num(push)) return;
    
    new 
Float:vel[3]
    switch(
mode)
    {
        case 
1:    // func_pushable
        
{
            
vel[0] = random_float(-125.0125.0), vel[1] = random_float(-125.0125.0), vel[2] = random_float(25.0125.0)
            
set_pev(entpev_velocityvel)
        }
        case 
2:    // player
        
{
            
pev(entpev_velocityvel)
            
vel[0] *= 2vel[1] *= 2vel[2] *= 2
            set_pev
(victimpev_velocityvel)
        }
    }
}
    
public 
classes_TraceAttack(thisidattacker)
    
use_func(thisidattacker)

use_func(thisagressor)
{
    if(
get_pcvar_num(use))
        
ExecuteHamB(Ham_Usethisagressoragressor21.0)
}
    
public 
monsters_touch(monstertarget)
{
    new array[
32]
    new 
owner pev(monsterpev_owner)
    
    
pev(targetpev_classname, array, charsmax(array))
        
    if(
equal(array, "func_door") || equal(array, "func_door_rotating") || equal(array, "func_button"))
        
use_func(targetowner)

    else if(
equal(array, "func_pushable"))
        
velocity_func(monstertarget1)
        
    else if(
equal(array, "player"))
    {    
        if(!
is_user_alive(target) || target == owner ) return
        
        new 
skip
        
        pev
(monsterpev_model, array, charsmax(array))
        
        if(
equal(array, "models/w_grenade.mdl"))    set_pev(monsterpev_solidSOLID_NOT)
        else if(
equal(array, "models/w_squeak.mdl"))    skip 1
        
else if(equal(array, "models/w_satchel.mdl"))    skip 0
        
else return // HLW_MP5(grenade) has NO model "o_O"
        
        
if(get_pcvar_num(drop))
            
console_cmd(target"drop")
        
        
velocity_func(monstertarget2)
        
        if(!
skip)
            
hurt_func(ownertargetget_pcvar_num(pain), monster)    
    }
}
        
hurt_func(killervictimmodeinflictor)    
{
    new 
damage

    
switch(mode)
    {
        case 
0: return
        case 
1
        {
            new 
Floatkil_orig[3], Floatvic_orig[3]
            
            
pev(victimpev_originvic_orig), pev(killerpev_originkil_orig)
            
            
damage floatround(get_distance_f(kil_origvic_orig)) / 32
        
}
        case 
2,3,4,5,6,7,8,9,10,11damage random(get_pcvar_num(pain))
        default: 
damage get_pcvar_num(pain)
    }
    (
pev(victimpev_health) - float(damage) >= 1.0) ? (ExecuteHamB(Ham_TakeDamagevictiminflictorkillerfloat(damage), 0)):ExecuteHamB(Ham_Killedvictimkiller2)




All times are GMT -4. The time now is 22:56.

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