AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to check if enemy was killed trough walls? (https://forums.alliedmods.net/showthread.php?t=243217)

pob18 07-01-2014 10:15

How to check if enemy was killed trough walls?
 
Okay, so I have this code and I want to add more stuff!
Check if the player killed the enemy trough a wall, is it possible?

PHP Code:

#include <amxmodx>
#include <fun>
#include <dhudmessage>

new nKiller

public plugin_init()
{
    
register_event("DeathMsg""hook_death""a""1>0")     
}

public 
hook_death()
{
    
nKiller read_data(1)

// CHECK WALL?
// DO STUFF...

    
if ( (read_data(3) == 1) && (read_data(5) == 0) )
    {
        
screenFade()
        
set_dhudmessage(1001000, -1.00.1511.01.00.10.1)
        
show_dhudmessage(nKiller"HEADSHOT")
    }
    else
        
screenFade()
}

public 
screenFade()
{
    
message_begin(MSG_ONEget_user_msgid("ScreenFade"), {0,0,0}, nKiller)
    
write_short(1<<10)
    
write_short(1<<10)
    
write_short(0x0000)
    
write_byte(255)
    
write_byte(0)
    
write_byte(0)
    
write_byte(100)
    
message_end()



Flick3rR 07-01-2014 11:19

Re: How to check if enemy was killed trough walls?
 
You can use the is_visible native. Search the internet, you will find info.

pob18 07-01-2014 11:36

Re: How to check if enemy was killed trough walls?
 
I searched but nothing found that can help me resolve/make this

Flick3rR 07-01-2014 12:23

Re: How to check if enemy was killed trough walls?
 
http://amxmodx.org/doc/index.html?pa...is_visible.htm
http://www.amx-x.ru/viewtopic.php?f=8&t=9682
Simpl, you have to include engine and the check should look like this:
PHP Code:

if(is_visible(nKillerread_data(2))){} 

This checks if the victim was visible for the killer during the kill.

pob18 07-01-2014 13:57

Re: How to check if enemy was killed trough walls?
 
What I'm doing wrong? If the enemy kills me trough a wall, the message displays "not visible", but if is visible the message stills the same.

PHP Code:

public hook_death()
{
    if(!
is_visible(nKillerread_data(2)))
    {
        
client_print(0,print_chat,"not visible")
    
    }  
    
    if(
is_visible(nKillerread_data(2)))
    {
        
client_print(0,print_chat,"visible")
    
    }  

    if ( (
read_data(3) == 1) && (read_data(5) == 0) )
    {
        
screenFade()
        
set_dhudmessage(RGB, -1.00.1511.01.00.10.1)
        
show_dhudmessage(nKiller"headshot")
    }
    else
        
screenFade()



Flick3rR 07-01-2014 14:03

Re: How to check if enemy was killed trough walls?
 
I can't see anything wrong with the code. Just a note, use else, because with "else" you won't force the engine to check again the conditions. Also, you have to know that you have to be FULLY visible, otherwise you are still invisible.

pob18 07-01-2014 14:06

Re: How to check if enemy was killed trough walls?
 
But what I need, is when you kill the enemy trought a wall (not visible) print message "not visible", else if visible (not trought wall) print "visible"

Flick3rR 07-01-2014 14:08

Re: How to check if enemy was killed trough walls?
 
I understand this. But, as far as I know, you are still invisible if part of you is visible. You have to be the whole visible, so the engine will think you for visible.

pob18 07-01-2014 14:10

Re: How to check if enemy was killed trough walls?
 
I don't understand :(
If possible to make a function, just when you kill someone trough a wall like a wallhack, do some stuff then?

Flick3rR 07-01-2014 14:30

Re: How to check if enemy was killed trough walls?
 
This is your function. All I wanted to say is that you have to be FULLY visible, so is_visible will return possitive result (-> you are visible). If only some part of you is visible, then you are still not visible, and the message will be
"not visible".


All times are GMT -4. The time now is 21:13.

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