AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Trigger Ham_Killed from Ham_TakeDamage (https://forums.alliedmods.net/showthread.php?t=281835)

hellmonja 04-22-2016 10:13

Trigger Ham_Killed from Ham_TakeDamage
 
Hey guys! I got a code for a grenade launcher and it uses ExecuteHamB with Ham_TakeDamage to dish out the damage to be dealt. The death message reads that the player got killed by a "worldspawn " and I was hoping of making a custom DeathMsg for it.

I've researched around and think Ham_Killed is the best way to do it. But I can't find any example code and am very new to HamSandwich.

I need the Ham_Killed to detect if the player in Ham_TakeDamage gets killed and then execute some code. Can you guys help me?...

EpicMonkey 04-22-2016 11:41

Re: [HELP] Trigger Ham_Killed from Ham_TakeDamage
 
One way of doing this would be by using make_deathmsg

HamletEagle 04-22-2016 11:43

Re: [HELP] Trigger Ham_Killed from Ham_TakeDamage
 
Quote:

Originally Posted by hellmonja (Post 2413157)
Hey guys! I got a code for a grenade launcher and it uses ExecuteHamB with Ham_TakeDamage to dish out the damage to be dealt. The death message reads that the player got killed by a "worldspawn " and I was hoping of making a custom DeathMsg for it.

I've researched around and think Ham_Killed is the best way to do it. But I can't find any example code and am very new to HamSandwich.

I need the Ham_Killed to detect if the player in Ham_TakeDamage gets killed and then execute some code. Can you guys help me?...

Give use the plugin, or at least the ExecuteHamB(Ham_TakeDamage,....) line.

hellmonja 04-22-2016 11:49

Re: [HELP] Trigger Ham_Killed from Ham_TakeDamage
 
1 Attachment(s)
sorry about that, I forgot to include the plugin

PHP Code:

    for(new 0get_maxplayers(); i++)
    {
        if(!
is_user_alive(i))
            continue
        
pev(ipev_originOrigin2)
        if(
get_distance_f(OriginOrigin2) > float(GRENADE_RADIUS))
            continue

        
ExecuteHamB(Ham_TakeDamagei0pev(entpev_owner), float(GRENADE_DAMAGE), DMG_BULLET)
    } 

that's the portion of the code where it does the damage. it starts in line 646. I've also attached the plugin itself in case you need the whole thing...

hellmonja 04-22-2016 11:58

Re: [HELP] Trigger Ham_Killed from Ham_TakeDamage
 
Quote:

Originally Posted by EpicMonkey (Post 2413184)
One way of doing this would be by using make_deathmsg

thanks. i actually know how to make a custom deathmsg, but the damage has to be dished out normally by the game itself (ie. getting hit by a bullet). i don't know how to do it if the plugin itself is creating the damage.

the other thing about this is, the weapon is an OTs-14 Groza with a GP-30 Grenade Launcher attached. so there's actually 2 ways to kill a player with this single weapon. the Groza's deathmsg works fine. it's the GP-30 that's giving the "worldspawn" deathmsg and i'm hoping to fix that...

klippy 04-22-2016 12:04

Re: [HELP] Trigger Ham_Killed from Ham_TakeDamage
 
PHP Code:

ExecuteHamB(Ham_TakeDamagei0pev(entpev_owner), float(GRENADE_DAMAGE), DMG_BULLET

it's about the third parameter, which is 0 here. That's the inflictor, or the entity that caused damage. For guns, it's same as the player, but for other entities (like grenades), it's the entity itself.

What you could do is create an entity with your desired classname before you execute TakeDamage, and input its index in that 3rd param, and then remove that entity afterwards.

hellmonja 04-22-2016 12:39

Re: [HELP] Trigger Ham_Killed from Ham_TakeDamage
 
Quote:

Originally Posted by KliPPy (Post 2413190)
PHP Code:

ExecuteHamB(Ham_TakeDamagei0pev(entpev_owner), float(GRENADE_DAMAGE), DMG_BULLET

it's about the third parameter, which is 0 here. That's the inflictor, or the entity that caused damage. For guns, it's same as the player, but for other entities (like grenades), it's the entity itself.

What you could do is create an entity with your desired classname before you execute TakeDamage, and input its index in that 3rd param, and then remove that entity afterwards.

Ok so it works, meaning if I change it, the information on the DeathMsg changes as well. I tested it by replacing "0" with "CSW_HEGRENADE" (i know, but just bear with me a bit) and it read player was killed by "player". I'm trying to replace it so it would look like he died of a hand grenade, FOR NOW. I regrettably admit that I do not know what I am doing and how to create and remove an entity. Sorry for being such an idiot. As of now i'm googling how to create one.

By the way, please don't laugh at my plugin. That came from Dias' OICW plugin but i've added a substantial amount of code there that you guys might find perplexing or even laughable...

HamletEagle 04-22-2016 13:12

Re: [HELP] Trigger Ham_Killed from Ham_TakeDamage
 
PHP Code:

new Entity create_entity("weapon_hegrenade")
ExecuteHamB(Ham_TakeDamageiEntity, .......)  
remove_entity(Entity


klippy 04-22-2016 13:25

Re: [HELP] Trigger Ham_Killed from Ham_TakeDamage
 
Quote:

Originally Posted by hellmonja (Post 2413198)
Ok so it works, meaning if I change it, the information on the DeathMsg changes as well. I tested it by replacing "0" with "CSW_HEGRENADE" (i know, but just bear with me a bit) and it read player was killed by "player". I'm trying to replace it so it would look like he died of a hand grenade, FOR NOW. I regrettably admit that I do not know what I am doing and how to create and remove an entity. Sorry for being such an idiot. As of now i'm googling how to create one.

CSW_HEGRENADE is not an entity index (or any other CSW_* constant), they are weapon indexes, which is totally different from entity indexes.
What you did there is put 4 (CSW_HEGRENADE is equal to 4) as inflictor in there, which is a "player" entity as they are in entity slots 1 through 32.

Quote:

Originally Posted by hellmonja (Post 2413198)
By the way, please don't laugh at my plugin. That came from Dias' OICW plugin but i've added a substantial amount of code there that you guys might find perplexing or even laughable...

No worries, nobody is going to laugh at it, you are here to learn.

hellmonja 04-23-2016 13:43

Re: [HELP] Trigger Ham_Killed from Ham_TakeDamage
 
sorry i took so long to reply. it actually worked but i wanted to test it thoroughly so i know what to say when i get back here. ok so now i'm going to try and elaborate in case others are researching this as well. the code now looks like this:

PHP Code:

        new Entity create_entity("weapon_hegrenade")
        
ExecuteHamB(Ham_TakeDamageiEntitypev(entpev_owner), float(GRENADE_DAMAGE), DMG_BULLET)
        
remove_entity(Entity

like you guys said, create an entity and use for Ham_TakeDamage them remove it later. i didn't even have to use Ham_Killed. with that said, i edited my DeathMsg code:

PHP Code:

    if(equalszWeapon"aug" ) && g_Has_Groza[iAttacker]) set_msg_arg_string(4"groza")
    if(
equalszWeapon"hegrenade" )) set_msg_arg_string(4"gp30"

the one on top is when you get killed by the bullet. the one on the bottom is for the grenade launcher. "gp30" is the model of the launcher.

for the icon i needed to edit my sprites\hud.txt file, add a "gp30" entry there. that also meant editing an actual sprite file so i can add the icon there.

i did some tests to see if it would conflict with the real he grenade. so far no conflicts what-so-ever. everything is working the way they should.

Thanks for all the help guys! Here's some bacon, it's all I can give for now... :bacon!:


All times are GMT -4. The time now is 18:37.

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