AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to detect exactly special Attacker (https://forums.alliedmods.net/showthread.php?t=214196)

newcomer 04-24-2013 05:43

How to detect exactly special Attacker
 
I have try detect special attacker, but it's not excatly, sometimes it's not show anything.
And I thing the code isn't well, my server have little laggy if run this detect
Please help me :)
Note: STEAM_0:0:1111111111 is just example
Quote:

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#define IsPlayer(%1) (1<=%1<=g_MaxPlayers)

new g_MaxPlayers;
new bool:detected[33]
new g_szAuthid[33]

public plugin_init()
{
RegisterHam(Ham_TraceAttack, "player", "HamTraceAttack")
g_MaxPlayers = get_maxplayers()
}

public client_putinserver(id)
{
detected[id] = false
set_task(2.0,"detect_player",id)
}

public detect_player(id)
{
get_user_authid(id, g_szAuthid[id], 32)
if (equal(g_szAuthid, "STEAM_0:0:1111111111"))
{
detected[id] = true
}
else
{
detected[id] = false
}
}

public HamTraceAttack(Vic, Att, Float:dmg, Float:dir[3], traceresult, dmgbits)
{
if (!detected[Att] || Vic == Att || !IsPlayer(Att))
{
return HAM_IGNORED;
}


if (detected[Att])
{
if (get_tr2(traceresult,TR_iHitgroup) == HIT_HEAD)
{
client_print(detected[Att], print_chat,"You're pro")
}
return HAM_IGNORED;
}

return HAM_IGNORED;
}

hornet 04-24-2013 07:48

Re: How to detect exactly special Attacker
 
You need to make g_szAuthid global and add a second dimension to it.
Also indent your code for the sake of readability.

newcomer 04-24-2013 09:13

Re: How to detect exactly special Attacker
 
it's still not exactly :(
is it poor code ?

hornet 04-24-2013 09:19

Re: How to detect exactly special Attacker
 
You did not add the second dimension:
Code:
new g_szAuthid[ 33 ][ 32 ];
And then every time you use it you must use g_szAuthid[ id ].

And then:
Code:

get_user_authid(id, g_szAuthid[id], 31 )

newcomer 04-24-2013 12:37

Re: How to detect exactly special Attacker
 
then don't need this ?
Quote:

detected[33]
and how can use g_szAuthid for detect special attacker ?


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

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