AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved This Way is Good For Get Client Dead? (https://forums.alliedmods.net/showthread.php?t=294880)

nea 03-10-2017 08:05

This Way is Good For Get Client Dead?
 
Hello i was wonder if this way can get client dead probably without any mistake

that i use register_message for "ScoreAttrib" and check if the flag was dead and else mean he's alive

for example of code :
PHP Code:

#include <amxmodx>

new g_IsDead=0
public plugin_init()
{
    
register_plugin("Get Client Dead","1.0","Nea")
    
register_message(get_user_msgid("ScoreAttrib"),"fn_CheckIfDied")
}
public 
fn_CheckIfDied(_1,_2,_3/*i don't care about them anyway*/)
{
    new 
id get_msg_arg_int(1// We Get User ID
    
new flag get_msg_arg_int(2// Get User Status 
    
if(flag ==1// He's Dead Now
        
g_IsDead |= (1<<(id 31))
    else 
// He's Alive
        
g_IsDead &= ~ ( 1<< ( id 31) )


so now we have a variable [g_IsDead] that we can use to check if player died in future use..and we can also use a function that can be run when client dead in fn_CheckIfDead..
but i wonder is that way is bad or something like that i don't know about?

cuz when i used DeathMsg,there's some cases that no detected ..
for example when player killed by C4 in (Counter-Strike) it's not sent message about that..

klippy 03-10-2017 09:02

Re: This Way is Good For Get Client Dead?
 
Why not just use is_user_alive()?

nea 03-10-2017 10:06

Re: This Way is Good For Get Client Dead?
 
as i said :
Quote:

in future use..and we can also use a function that can be run when client dead in fn_CheckIfDead..

and dead cache is just for example
ex :

PHP Code:

#include <amxmodx>

new g_IsDead=0
public plugin_init()
{
    
register_plugin("Get Client Dead","1.0","Nea")
    
register_message(get_user_msgid("ScoreAttrib"),"fn_CheckIfDied")
}
public 
fn_CheckIfDied(_1,_2,_3/*i don't care about them anyway*/)
{
    new 
id get_msg_arg_int(1// We Get User ID
    
new flag get_msg_arg_int(2// Get User Status 
    
if(flag ==1// He's Dead Now
    
{
        
g_IsDead |= (1<<(id 31))
        
fn_ClientDied(id)
    }
    else 
// He's Alive
        
g_IsDead &= ~ ( 1<< ( id 31) )

public 
fn_ClientDied(id)
{
   
// So Here We Can Put Block Of Code


But it will be good idea? that's the question..

Natsheh 03-10-2017 11:06

Re: This Way is Good For Get Client Dead?
 
No check is user alive

georgik57 03-10-2017 11:06

Re: This Way is Good For Get Client Dead?
 
Code:
register_event("DeathMsg", "fwEvDeathMsg", "a")
Best to use this if you don't want to use the HamSandwich module.
Code:
read_data(1)
...is killer ID.
Code:
read_data(2)
...is victim ID.

Natsheh 03-10-2017 11:20

Re: This Way is Good For Get Client Dead?
 
Quote:

Originally Posted by KliPPy (Post 2502364)
Why not just use is_user_alive()?


nea 03-10-2017 11:43

Re: This Way is Good For Get Client Dead?
 
Quote:

Originally Posted by Natsheh (Post 2502397)
No check is user alive

mm.. im not talking about checking user alive/dead..im talking about using it as event
for simple purpose..
And 'DeathMsg' Not Detect Client When Be Killed By C4 Explode in 'Counter-Strike'
But 'ScoreAttrib' Detect All Kind Of Die..

Quote:

Best to use this if you don't want to use the HamSandwich module.
mm.. i didn't talk about HamSandwich Here.. But in General Yes It Will Be Better From HamSandwich
, but i discuss why not using this method - i mean 'ScoreAttrib' - instead of 'DeathMsg' In Simple Purpose that no need to know who's killer or other info ..

HamletEagle 03-10-2017 11:55

Re: This Way is Good For Get Client Dead?
 
Because if some plugin is messing with ScoreAttrib your code logic will fail. Just use hamsandwich.

georgik57 03-10-2017 11:55

Re: This Way is Good For Get Client Dead?
 
Because it's a message.
Messages can be blocked, so if your plugin isn't the first in the list, the other plugins might block it and the hook won't trigger.
As for events, as far as I understood, they're some kind of post-messages and cannot be blocked(someone correct me if I'm wrong).

nea 03-10-2017 12:16

Re: This Way is Good For Get Client Dead?
 
Quote:

Originally Posted by HamletEagle (Post 2502408)
Because if some plugin is messing with ScoreAttrib your code logic will fail. Just use hamsandwich.

Aha,So it will work just only when the plugin was the first when hooking this message.. ok thank you


Quote:

Originally Posted by georgik57
Because it's a message.
Messages can be blocked, so if your plugin isn't the first in the list, the other plugins might block it and the hook won't trigger.
As for events, as far as I understood, they're some kind of post-messages and cannot be blocked(someone correct me if I'm wrong).

Thank you too :)


All times are GMT -4. The time now is 17:52.

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