Results 1 to 3 of 3

Thread: If player select custom model e.g.: brush_egypt_desert_1 I can't hit and kill him

  1. #1
    Private
    Join Date
    Nov 2019
    Posts
    22
    Thanks
    2
    Thanked 3 Times in 3 Posts

    If player select custom model e.g.: brush_egypt_desert_1 I can't hit and kill him

    Why I can't kill players with custom models? I mean if a player choose a custom model from the menu e.g: a brush (for ex.: brush_egypt_desert_1) I can't hit and kill him.

    I read in some thread here that I need to do bullettrace or trigger_damage function (?) but I have no idea how to do that.

    EDIT: I saw @IzNoGoD script on MODSonline which was:

    PHP Code:
    main()
    {
        
    thread waitforconnect();
    }
    waitforconnect()
    {
        for(;;)
        {
            
    level waittill("connecting",player);
            
    player thread waitforspawn();
        }
    }

    waitforspawn()
    {
        
    self endon("disconnect");
        for(;;)
        {
            
    self waittill("spawned_player");
            
    self thread attackmonitor();
            
    self thread spawneye();
        }
    }

    attackmonitor()
    {
        
    self endon("disconnect");
        
    self endon("killed_player");
        
    self endon("spawned_player");
        if(
    self getcurrentweaponslot()!="none")
            
    ammo=self getweaponslotclipammo(self getcurrentweaponslot());
        else
            
    ammo=0;
        
    oldammo=ammo;
        
    oldangles=self getplayerangles();
        
    weap=self getcurrentweapon();
        
    oldweap=weap;
        for(;;)
        {
            if(
    self getcurrentweaponslot()!="none")
            {
                
    weap=self getcurrentweapon();
                
    ammo=self getweaponslotclipammo(self getcurrentweaponslot());
                if(
    self attackbuttonpressed()&&ammo<oldammo&&oldweap==weap)
                {
                    
    angles=self getplayerangles();
                    
    newangles=((oldangles[0]*2+angles[0])/3,angles[1],angles[2]);
                    
    //above line is added to compensate for kickback from guns

                    
    forward=maps\mp\_utility::vectorscale(anglestoforward(newangles),10000);
                    
    smallforward=anglestoforward(newangles);
                    
    point=self geteyepos();
                    
    trace=bullettrace(point,point+forward,true,self);
                    if(
    trace["fraction"]<1)
                    {
                        if(
    canbedamaged(trace["entity"]))
                        {
                            
    damage=int(getdamage(weap));
                            if(
    damage>0)
                            {
                                
    trace["entity"finishobjectdamage(selfdamage);
                            }
                        }
                    }
                }
            }
            
    oldammo=ammo;
            
    oldweap=weap;
            
    oldangles=self getplayerangles();
            
    wait 0.05;
        }
    }

    finishobjectdamage(attacker,damage)
    {
        if(
    isdefined(self.health))
        {
            
    self.health-=int(damage);
            if(
    self.health<0)
                
    self notify("destroyed_by",attacker);
        }
        else
            
    self notify("destroyed_by",attacker);
        if(
    isdefined(attacker))
            
    attacker thread maps\mp\gametypes\_damagefeedback::updateDamageFeedback();
    }

    getcurrentweaponslot()
    {
        
    weap=self getcurrentweapon();
        if(!
    isdefined(weap)||weap=="none"||weap==self getweaponslotweapon("primary"))
            return 
    "primary";
        return 
    "primaryb";
    }

    canbedamaged(entity)
    {
        if(
    isdefined(entity))
        {
            if(
    isdefined(entity.setcandamage))
            {
                if(
    entity.setcandamage)
                    return 
    true;
                else
                    return 
    false;
            }
            else
                return 
    false;
        }
        else
            return 
    false;
    }


    getdamage(weap)
    {
        switch(
    weap)
        {
        case 
    "springfield_mp":
        case 
    "enfield_scope_mp":
        case 
    "mosin_nagant_sniper_mp":
        case 
    "kar98k_sniper_mp":
        case 
    "mosin_nagant_mp":
        case 
    "enfield_mp":
        case 
    "kar98k_mp":
            return 
    100;
        case 
    "m1carbine_mp":
        case 
    "m1garand_mp":
        case 
    "SVT40_mp":
        case 
    "g43_mp":
            return 
    38;
        case 
    "bar_mp":
        case 
    "bren_mp":
        case 
    "mp44_mp":
            return 
    40;
        case 
    "thompson_mp":
        case 
    "sten_mp":
        case 
    "greasegun_mp":
        case 
    "mp40_mp":
            return 
    36;
        case 
    "ppsh_mp":
            return 
    30;
        case 
    "PPS42_mp":
            return 
    40;
        case 
    "shotgun_mp":
            return 
    100;
        case 
    "TT30_mp":
            return 
    20;
        case 
    "webley_mp":
            return 
    20;
        case 
    "colt_mp":
            return 
    20;
        case 
    "luger_mp":
            return 
    20;
        case 
    "mg42_mp":
            return 
    20;
        default:
            return 
    70;
        }
    }

    spawneye()
    {
        
    self endon("disconnect");
        
    self endon("killed_player");
        
    self endon("spawned_player");
        if(
    isdefined(self.eyemarker))
            
    self.eyemarker delete();
        
    wait 0.05;
        if(
    isalive(self))
        {
            
    self.eyemarker=spawn("script_origin",self.origin);
            
    self.eyemarker linkto(self,"tag_eye",(0,0,0),(0,0,0));
        }
    }

            


    geteyepos()
    {
        if(
    isdefined(self.eyemarker))
        {
            if(
    distancesquared(self.eyemarker.origin,self.origin)>0)
                return 
    self.eyemarker.origin;
            else
                return 
    self geteye();
        }
        else
        {
            return 
    self geteye();
        }
    }


    waitfordestroy()
    {
        
    self waittill("destroyed_by",attacker);
        if(
    isdefined(attacker)&&isplayer(attacker)) //not needed, just for safety
            
    attacker iprintlnbold("you killed a zombie"); //add score here etc etc
        
    playfx(destroy_fx,self.origin);
        
    self playsound("destroy_sound");
        
    self delete();

    Is this what i need? If so how can I implement this in my code so I can hit and kill custom models like a brush or a chair etc... Because in this thread IzNoGoD is just explain when you spawn a zombie you can kill him if I'm right.
    Last edited by Toxys; 4th November 2020 at 15:22.

  2. #2
    Corporal voron00's Avatar
    Join Date
    Nov 2014
    Posts
    248
    Thanks
    64
    Thanked 216 Times in 116 Posts
    Quote Originally Posted by Toxys View Post
    Why I can't kill players with custom models? I mean if a player choose a custom model from the menu e.g: a brush (for ex.: brush_egypt_desert_1) I can't hit and kill him.
    There is simply no hitbox for those models. However, a splash damage will still work (grenades, projectiles).
    sudo apt-get rekt

  3. #3
    Private
    Join Date
    Nov 2019
    Posts
    22
    Thanks
    2
    Thanked 3 Times in 3 Posts
    Yes, but it can be done because I saw it on some other servers... or they changed the bullet of e.g.: kar98k to a rocket launcher projectile and that's why they can kill those models?

    Look at this video: https://youtu.be/ZyJK0oobMGs?t=247 they're did it many years ago...
    Last edited by Toxys; 6th November 2020 at 17:16. Reason: video

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •