Raised This Month: $ Target: $400
 0% 

COD: HitMarkers v1.7 [Updated April 29th 2021]


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 01-20-2020 , 11:48   Re: COD: HitMarkers [First release: 16/01/2020]
Reply With Quote #11

Quote:
Originally Posted by Napoleon_be View Post
Thanks for the suggestions HamletEagle, Everything is ready to get updated, only for one thing where i'm having trouble with. Which is the cvar for snipers.

This is the check i currently have but it doesn't work, can i get some on help this one?
PHP Code:
if((is_user_connected(iAttacker) && get_pcvar_num(pPlugin) && get_user_team(iVictim) != get_user_team(iAttacker)) ||
    (
is_user_connected(iAttacker) && get_pcvar_num(pPlugin) && get_user_team(iVictim) != get_user_team(iAttacker) && get_pcvar_num(pSnipersOnly) && gWeaponList & (<< get_user_weapon(iAttacker)))) 
Huh... this is next-level stuff right here. Now seriously, don't duplicate if checks like that: it is not needed and makes your code ugly and hard to read.
Also, don't be afraid to split your checks in multiple if statements.

Your code didn't work because inside an if check that looks like if(A || B) A is firstly checked. If A is false, B is checked. If A is true, B is not checked.
So it firstly checks
PHP Code:
is_user_connected(iAttacker) && get_pcvar_num(pPlugin) && get_user_team(iVictim) != get_user_team(iAttacker)) 
and the if check passes without ever checking for pSnipersOnly cvar(and whenever A fails B will fail too because both A and B share the above check)

PHP Code:
    //we are doing the main checks first - the part that you duplicated. We need them to be true to proceed no matter the value of pSnipersOnly 
    
if(is_user_connected(iAttacker) && get_pcvar_num(pPlugin) && get_user_team(iVictim) != get_user_team(iAttacker))
    {
        
//controls whether we will show a hit marker or not
        
new bool:showHitMarker;
        
        if(
get_pcvar_num(pSnipersOnly)) //snipers only
        
{
            if(
gWeaponList & (<< get_user_weapon(iAttacker))) //we are holding a sniper
            
{
                
showHitMarker true//show hit marker
            
}
        }
        else 
        {
            
showHitMarker true//no restrictions on current weapon, show hit marker
        
}
        
        if(
showHitMarker)
        {
            
//hit marker logic
        
}
    } 
You could write it as an one-liner but as I said before, it's horrible:
PHP Code:
is_user_connected(iAttacker) && get_pcvar_num(pPlugin) && get_user_team(iVictim) != get_user_team(iAttacker) && (!get_pcvar_num(pSnipersOnly) || get_pcvar_num(pSnipersOnly) && (gWeaponList & (<< get_user_weapon(iAttacker)))) 
__________________

Last edited by HamletEagle; 01-20-2020 at 11:58.
HamletEagle is offline
 



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 09:07.


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