Raised This Month: $51 Target: $400
 12% 

[HELP Scripting] DeathMsg Correctly?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MeliMeli
Senior Member
Join Date: Apr 2022
Location: Brazil
Old 06-23-2023 , 18:51   [HELP Scripting] DeathMsg Correctly?
Reply With Quote #1

Hello everyone, I'm seeking a new way to depict infected zombies through a death message. I would appreciate the help of more experienced coders to confirm if this is correct or if there's a better way to accomplish it:

PHP Code:
g_MsgDeathMsg get_user_msgid("DeathMsg")
g_MsgScoreAttrib get_user_msgid("ScoreAttrib")


// Fix Dead Attrib on scoreboard
FixDeadAttrib(id)
{
    
message_begin(MSG_BROADCASTg_MsgScoreAttrib)
    
write_byte(id// id
    
write_byte(0// attrib
    
message_end()
}

SendDeathInfect(id)
{
    
message_begin(MSG_BROADCASTg_MsgDeathMsg)
    
write_byte(0// killer
    
write_byte(id// victim
    
write_byte(0// headshot flag
    
write_string("infection"// killer's weapon
    
message_end()

I've searched many threads on this topic but couldn't find an answer to my question. I'm using one method to send a death message (infection) and another to fix the death bug in the score table. From what I've seen, the DeathMsg originally expects two arguments: the attacker and the victim. However, I'm only providing the victim because the zombies were randomly selected, so there's no need for attackers. Can anyone tell me if this method is correct or if there are better ways to accomplish this?
MeliMeli is offline
MrPickles
Senior Member
Join Date: Aug 2022
Location: Colombia
Old 06-24-2023 , 01:34   Re: [HELP Scripting] DeathMsg Correctly?
Reply With Quote #2

You Should use:

PHP Code:
ExecuteHamHam_TakeDamageVictimWeaponAttacker 6.00.0 ); 
6.0 is the damage and the message death is the classname of the weapon.

Last edited by MrPickles; 06-24-2023 at 01:35.
MrPickles is offline
MeliMeli
Senior Member
Join Date: Apr 2022
Location: Brazil
Old 06-24-2023 , 02:54   Re: [HELP Scripting] DeathMsg Correctly?
Reply With Quote #3

something like this? i dont understand correcly your example

PHP Code:
// Show infection death notice?
            
if (get_pcvar_num(cvar_infect_show_notice))
            {
                
// Send death notice and fix the "dead" attrib on scoreboard
                
SendDeathMsg(attackerid)  
                
FixDeadAttrib(id)
                
ExecuteHamHam_TakeDamageid0attacker6.00.0 ); 
            } 
MeliMeli is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 06-24-2023 , 09:16   Re: [HELP Scripting] DeathMsg Correctly?
Reply With Quote #4

so i see that you want to trigger the death event using a non existing weapon name (https://wiki.alliedmods.net/Half-lif...Counter-Strike).

i think it would be better if you will create a custom forward that is triggered when you want.


also, triggering deathmsg can induce others plugins into errors

edit:

a simple example (idk if it's what you need)

main plugin:

Code:
#include <amxmodx> #include <hamsandwich> enum _:FORWARDS {     INFECTION_PRE,     INFECTION_POST,     //... etc } new g_iForwards[FORWARDS] new g_iScoreAttrib public plugin_init() {     register_plugin("Main Plugin", "Version", "Author")     RegisterHam(Ham_Killed, "player", "fwHamKilledPre", _:false)     RegisterHam(Ham_Killed, "player", "fwHamKilledPost", _:true)     g_iForwards[INFECTION_PRE] = CreateMultiForward("zp_user_infected_pre", ET_IGNORE, FP_CELL, FP_CELL)     g_iForwards[INFECTION_POST] = CreateMultiForward("zp_user_infected_post", ET_IGNORE, FP_CELL, FP_CELL)     g_iScoreAttrib = get_user_msgid("ScoreAttrib") } public fwHamKilledPre(id, attacker) {     if(id == attacker)     {         return HAM_IGNORED     }     static ret     ExecuteForward(g_iForwards[INFECTION_PRE], ret, id, attacker)         return HAM_HANDLED } public fwHamKilledPost(id, attacker) {     if(id == attacker)     {         return HAM_IGNORED     }         message_begin(MSG_BROADCAST, g_iScoreAttrib)     write_byte(id) // id     write_byte(0) // attrib     message_end()     static ret     ExecuteForward(g_iForwards[INFECTION_POST], ret, id, attacker)     return HAM_HANDLED }

Second plugin:

Code:
#include <amxmodx> forward zp_user_infected_pre(id, attacker); forward zp_user_infected_post(id, attacker); public plugin_init() {     register_plugin("Second Plugin", "Version", "Author") } public zp_user_infected_pre(id, attacker) {     static szName[MAX_NAME_LENGTH]     get_user_name(id, szName, charsmax(szName))     server_print("[PRE]Victim name is %s", szName)     get_user_name(id, szName, charsmax(szName))     server_print("[PRE]Attacker name is %s", szName) } public zp_user_infected_post(id, attacker) {     static szName[MAX_NAME_LENGTH]     get_user_name(id, szName, charsmax(szName))     server_print("[POST] Victim name is %s", szName)     get_user_name(id, szName, charsmax(szName))     server_print("[POST] Attacker name is %s", szName) }

you have a more better and detailed tutorial here https://forums.alliedmods.net/showthread.php?t=41241

Last edited by lexzor; 06-24-2023 at 10:36.
lexzor is offline
MeliMeli
Senior Member
Join Date: Apr 2022
Location: Brazil
Old 06-24-2023 , 13:58   Re: [HELP Scripting] DeathMsg Correctly?
Reply With Quote #5

It does cause errors indeed, as after the message was displayed "correctly visually," there were zombies and humans on the same team. Basically, what I want to do is show a fake death message when the first zombies are selected. I always search the entire forum before making a request or asking for help, sometimes I create a duplicate because the thread is old, etc., but anyway, I hope you understood

So, the zombies are selected, and a death message is sent to the selected zombies through the code. Not the ones infected by an attacker, as they already have a default death message, but the selected ones without an attacker, I have no idea how to properly and safely do it.

Last edited by MeliMeli; 06-24-2023 at 14:36.
MeliMeli 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 10:26.


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