AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Simulate HS kill (https://forums.alliedmods.net/showthread.php?t=254301)

Flick3rR 01-01-2015 12:12

Simulate HS kill
 
Hey guys! I'm currently facing a problem. Which is the best method to simulate HS kill? Let's get for example that I want to put a comand /kill and that will kill a random player from the other team with headshot with the exact weapon, which I'm holding. In simple words, to false th ekill as I've really done it and the player would fall down like really HS killed. That's all, I doubt it will be some hard stuff, but I can't think of it...

bat 01-01-2015 12:35

Re: Simulate HS kill
 
https://forums.alliedmods.net/showthread.php?t=830
I don't know, if it will help you

Flick3rR 01-01-2015 12:43

Re: Simulate HS kill
 
No, no. That's just a fake deathmsg, it's simple. But I want to remake the whole kill, the dying animation, the score info, all of it. Just like it's a real kill.

HamletEagle 01-01-2015 12:46

Re: Simulate HS kill
 
Maybe by sending a DeathMsg message? https://wiki.alliedmods.net/Half-Lif...Counter-Strike

Flick3rR 01-01-2015 12:49

Re: Simulate HS kill
 
That's what bat has already suggested. The deathmsg is just displayed in the corner and calls the event, right? It's not just that, what I'm trying to achieve. I'd want to remake the death animation of a HS kill on the victim, the score info to be immediately updated and all the details of a normal kill, like it was actually done. Is there some way?

klippy 01-01-2015 16:51

Re: Simulate HS kill
 
I am writing this of top of my head right now, and I don't know if it will work, but I would create a new trace handle with create_tr2(), set TR_iHitGroup member of trace handle to HIT_HEAD, then make a ExecuteHam(Ham_TraceAttack, ...) call with that trace handle. And don't forget to free the handle with free_tr2()!

Flick3rR 01-01-2015 18:26

Re: Simulate HS kill
 
Hey, dude, thanks a lot! It worked! I created a simple plugin to test it. It does the following: when you shoot a random shot with a deagle, you kill all the players from the opponent team with HS. There is only one thing bothering me - they all die how they should, but only one guy survives and doesn't give a f*ck about my plugin :D
It's not from the loop, since the 'num' returns 1 (printed it), but the trace doesn't kill the last guy. I mean, they are like 4 CTs, and when I shoot with the deagle, three of them die and the fourth just sirvives like nothing has event ment to kill him. It's strange and I can't understand what is causing that. Here is the code, I think the loops are okay and there is some special detail with the traces, that I'm missing. Some opinions?
PHP Code:

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

public plugin_init()
{
    
register_plugin("Insta Deagle HS""1.0""Flicker")
    
RegisterHam(Ham_Weapon_PrimaryAttack"weapon_deagle""onPrimaryAttack"true)
}

public 
onPrimaryAttack(ent)
{
    new 
id pev(entpev_owner)
    new 
iTeam get_user_team(id)
    new 
clipammo
    get_user_weapon
(idclipammo)
    
    if(!
clip)    return
    
    new 
szTeam[32]
    
copy(szTeamcharsmax(szTeam), iTeam == "CT" "TERRORIST")
    
    new 
ptr create_tr2()
    
set_tr2(ptrTR_iHitgroupHIT_HEAD)
    new 
Float:flDirection[3]
            
    new 
players[32], num
    get_players
(playersnum"aeh"szTeam)
    
    for(new 
inumi++)
    {
        
ExecuteHamB(Ham_TraceAttackplayers[i], id147.0flDirectionptrDMG_NEVERGIB DMG_BULLET)
    }
    
    
free_tr2(ptr)



klippy 01-01-2015 18:47

Re: Simulate HS kill
 
I really don't know what could it be, try debugging it a little more, make sure it is executed for every player.
also, try setting TR_pHit member for each player.

Flick3rR 01-01-2015 19:15

Re: Simulate HS kill
 
Ooookay, that's the current code. With and without TR_pHit it's the same. No error logs. And I've debugged it enough to see, that it's executed on all players, but not all die - the last one stands alive. Here's the test code:
PHP Code:

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

public plugin_init()
{
    
register_plugin("Insta Deagle HS""1.0""Flicker")
    
RegisterHam(Ham_Weapon_PrimaryAttack"weapon_deagle""onPrimaryAttack"true)
}

public 
onPrimaryAttack(ent)
{
    new 
id pev(entpev_owner)
    new 
iTeam get_user_team(id)
    new 
clip get_pdata_int(ent514// cs_get_weapon_ammo(get_pdata_cbase(id, 373))
    
    
if(!clip)    return
    
    new 
szTeam[15]
    
copy(szTeamcharsmax(szTeam), iTeam == "CT" "TERRORIST")
    
    new 
ptr create_tr2()
    
set_tr2(ptrTR_iHitgroupHIT_HEAD)
    new 
Float:flDirection[3]
            
    new 
players[32], num
    get_players
(playersnum"aeh"szTeam)
    new 
iNum num num 6
    
    
for(new iiNumi++)
    {
        
set_tr2(ptrTR_pHitplayers[i])
        
ExecuteHam(Ham_TraceAttackplayers[i], id147.0flDirectionptrDMG_NEVERGIB DMG_BULLET)
        
client_print(idprint_chat"Executed! %d / %d"i+1iNum)
    }
    
    
free_tr2(ptr)


And here is some image for the results:http://prikachi.com/images/345/7821345V.jpg
Therefore it's something from the trie. Any suggestions anyone?

RateX 01-02-2015 03:53

Re: Simulate HS kill
 
Don't know what's wrong with it, but Ham_Killed works. Remember to set m_LastHitGroup value to HIT_HEAD and catch DeathMsg, modify weapon string to the weapon you're holding.


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

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