AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] Get Enemy origin in Radius (https://forums.alliedmods.net/showthread.php?t=229790)

m4m3ts 11-15-2013 02:16

[HELP] Get Enemy origin in Radius
 
i trying to detect zombie around me, when i shooting.
i put the code on fw_TraceAttack, i using "print_chat" to test counting wrong or not.

i'm using this method to count zombie around me

PHP Code:

public fw_TraceAttack(iEntiAttackerFloat:flDamageFloat:fDir[3], ptriDamageType)
{
    if(!
is_user_alive(iAttacker))
        return
    if(
get_user_weapon(iAttacker) != CSW_M249)
        return
    
    new 
NearestZombie 0
    
for(new 0<= get_maxplayers(); i++)
    {
        if(
is_user_alive(i) && entity_range(iAttackeri) < 400.0 && zp_get_user_zombie(i))
        
NearestZombie ++
    }
    
    if(
NearestZombie == 0client_print(iAttackerprint_chat"0 Zombie Near You !")
    if(
NearestZombie == 1client_print(iAttackerprint_chat"1 Zombie Near You !")
    if(
NearestZombie == 2client_print(iAttackerprint_chat"2 Zombie Near You !")
    if(
NearestZombie == 3client_print(iAttackerprint_chat"3 Zombie Near You !")
    if(
NearestZombie == 4client_print(iAttackerprint_chat"4 Zombie Near You !")


it works well to detect zombie, but my question is:
how to get each zombie origin near me & count it ??


i try this but not work
Code:

new vOrigin[3]
pev(NearestZombie, pev_origin, vOrigin)

-----------------------------------------------
Note:

but when i change to this.
it's not work, counting zombie is wrong.

PHP Code:

public fw_TraceAttack(iEntiAttackerFloat:flDamageFloat:fDir[3], ptriDamageType)
{
    if(!
is_user_alive(iAttacker))
        return
    if(
get_user_weapon(iAttacker) != CSW_M249)
        return
    
    for(new 
0<= get_maxplayers(); i++)
    {
        if(!
is_user_alive(i))
            continue
        if(
entity_range(iAttackeri) > 400.0)
            continue
        if(!
zp_get_user_zombie(i))
            continue
            
        if(
== 0client_print(iAttackerprint_chat"0 Zombie Near You !")
        if(
== 1client_print(iAttackerprint_chat"1 Zombie Near You !")
        if(
== 2client_print(iAttackerprint_chat"2 Zombie Near You !")
        if(
== 3client_print(iAttackerprint_chat"3 Zombie Near You !")
        if(
== 4client_print(iAttackerprint_chat"4 Zombie Near You !")
    }



Arkshine 11-15-2013 04:05

Re: [HELP] Get Enemy origin in Radius
 
Quote:

how to get each zombie origin near me & count it ??
You do it already in the first code.

m4m3ts 11-15-2013 04:57

Re: [HELP] Get Enemy origin in Radius
 
Quote:

Originally Posted by Arkshine (Post 2061052)
You do it already in the first code.

that only count zombie near me, not get origin of each zombie that near me.

alan_el_more 11-15-2013 05:04

Re: [HELP] Get Enemy origin in Radius
 
PHP Code:

new vOrigin[3]
pev(NearestZombiepev_originvOrigin

-->
PHP Code:

new Float:vOrigin[3]
pev(NearestZombiepev_originvOrigin

PHP Code:

for(new 0<= get_maxplayers(); i++) 

-->
PHP Code:

for(new 1<= get_maxplayers(); i++) 



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

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