Raised This Month: $ Target: $400
 0% 

Solved This Way is Good For Get Client Dead?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
nea
Junior Member
Join Date: Jan 2017
Old 03-10-2017 , 08:05   This Way is Good For Get Client Dead?
Reply With Quote #1

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..

Last edited by nea; 03-10-2017 at 13:57.
nea is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 03-10-2017 , 09:02   Re: This Way is Good For Get Client Dead?
Reply With Quote #2

Why not just use is_user_alive()?
klippy is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 03-10-2017 , 11:20   Re: This Way is Good For Get Client Dead?
Reply With Quote #3

Quote:
Originally Posted by KliPPy View Post
Why not just use is_user_alive()?
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
nea
Junior Member
Join Date: Jan 2017
Old 03-10-2017 , 10:06   Re: This Way is Good For Get Client Dead?
Reply With Quote #4

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..

Last edited by nea; 03-10-2017 at 10:16.
nea is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 03-10-2017 , 11:06   Re: This Way is Good For Get Client Dead?
Reply With Quote #5

No check is user alive
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
nea
Junior Member
Join Date: Jan 2017
Old 03-10-2017 , 11:43   Re: This Way is Good For Get Client Dead?
Reply With Quote #6

Quote:
Originally Posted by Natsheh View Post
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 ..
nea is offline
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 03-10-2017 , 11:06   Re: This Way is Good For Get Client Dead?
Reply With Quote #7

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.
__________________
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 03-10-2017 , 11:55   Re: This Way is Good For Get Client Dead?
Reply With Quote #8

Because if some plugin is messing with ScoreAttrib your code logic will fail. Just use hamsandwich.
__________________
HamletEagle is offline
nea
Junior Member
Join Date: Jan 2017
Old 03-10-2017 , 12:16   Re: This Way is Good For Get Client Dead?
Reply With Quote #9

Quote:
Originally Posted by HamletEagle View Post
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
nea is offline
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 03-10-2017 , 11:55   Re: This Way is Good For Get Client Dead?
Reply With Quote #10

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).
__________________

Last edited by georgik57; 03-10-2017 at 11:56.
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
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 17:53.


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