AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Traceline (https://forums.alliedmods.net/showthread.php?t=19258)

v3x 10-12-2005 18:09

Traceline
 
Ok, I'm trying to use this method instead of using set_user_hitzones because it's supposedly buggy. The problem is whenever I look at someone or whatever, the debug messages and sounds come up and I'm not even firing.
Code:
// My defines #define ARMOR_OFFSET    112     // Armortype offset #define ARMOR_DEFAULT   100.0       // Default amount of armor #define ARMOR_NONE  0 #define ARMOR_NOHELM    1 #define ARMOR_HELM  2 #define HITS_HELM   3 #define HITS_NOHELM 5 // plugin_init register_forward(FM_TraceLine, "forward_traceline", 1); public forward_traceline( Float:v1[3], Float:v2[3], noMonsters, id ) {     if( !is_user_connected(id) || !is_user_alive(id) )         return FMRES_IGNORED;     new iVictim = get_tr(TR_pHit);     if( !is_user_connected(iVictim) || !is_user_alive(iVictim) || is_user_bot(iVictim) )         return FMRES_IGNORED;     new iHitPlace = get_tr(TR_iHitgroup);     new iArmor = get_pdata_int(iVictim, ARMOR_OFFSET);     new szUserName[33];     get_user_name(iVictim, szUserName, 32);     switch( iArmor )     {         case ARMOR_NOHELM:         {             if( g_iHits[iVictim] <= HITS_NOHELM )             {                 emit_sound(iVictim, CHAN_VOICE, "player/bhit_kevlar-1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM);                 set_tr(TR_iHitgroup, HIT_GENERIC);                 client_print(iVictim, 4, "[DEBUG] Your kevlar just took a shot, %s", szUserName);             }         }         case ARMOR_HELM:         {             if( g_iHits[iVictim] <= HITS_HELM )             {                 if( iHitPlace == HIT_HEAD )                     emit_sound(iVictim, CHAN_VOICE, "player/bhit_helmet-1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM);                 set_tr(TR_iHitgroup, HIT_GENERIC);                 client_print(iVictim, 4, "[DEBUG] Your kevlar/helmet just took a shot, %s", szUserName);             }         }     }     return FMRES_IGNORED; }
Could I do something like this to prevent it?
Code:
if( (get_user_button(id)&IN_ATTACK) && g_iHits[iVictim] <= HITS_NOHELM )
Thanks

Zenith77 10-12-2005 18:33

Quote:

Originally Posted by v3x
Could I do something like this to prevent it? Small:

if( (get_user_button(id)&IN_ATTACK) && g_iHits[iVictim] <= HITS_NOHELM )



You answered your self :)


But i would feel better checking it every frame with a bool.

Code:
// etc etc new bool:shouldCheck[33] ... ... public client_PreThink(id) {        if( (get_user_button(id)&IN_ATTACK) ) {                          shouldCheck[id] = true        }          else {                shouldCheck[id] = false               } }


Then just execute the code through one big if statement ^^
[/small]

v3x 10-12-2005 18:43

Bah, ok. Now I have to do something with FF :?

I'll try this

XxAvalanchexX 10-12-2005 18:49

TraceLines happen alot, regardless of whether or not you are firing. Even checking if they are holding the attack button won't work in all situations, because TraceLine is called more often then bullets come out of their gun, and it can be called while the weapon is drawing, holstering, reloading, etcetera.

v3x 10-12-2005 18:55

[EDITED]

Zenith77 10-12-2005 18:55

Thats what i was thought ( what avalanche said ) but did not think it was right.


So, what i would do is possibly register The Damage event ?


But by then it would be to late to do what ever your going to do.

v3x 10-12-2005 19:34

What do you suggest I do? ;\

Zenith77 10-12-2005 19:39

Try both ways, and see which one works, if any of them :)


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

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