Raised This Month: $32 Target: $400
 8% 

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


Post New Thread Reply   
 
Thread Tools Display Modes
iclassdon
AlliedModders Donor
Join Date: May 2006
Old 01-19-2020 , 11:03   Re: COD: HitMarkers [First release: 16/01/2020]
Reply With Quote #21

Can you add a sniper weapons only option? Its to redundant if using ABD.

It's just missing something... Just my opinion gents. Great idea btw.

Last edited by iclassdon; 01-19-2020 at 11:06.
iclassdon is offline
Send a message via MSN to iclassdon
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 01-19-2020 , 13:11   Re: COD: HitMarkers [First release: 16/01/2020]
Reply With Quote #22

Quote:
Originally Posted by iclassdon View Post
Can you add a sniper weapons only option? Its to redundant if using ABD.

It's just missing something... Just my opinion gents. Great idea btw.
I have added a version which only works with sniper rifles, feel free to use it and give me your feedback on it.

Special thanks to Bugsy for learning me how to use bitsums.

If it's really nessecary, i'll be making a cvar for the sniper options instead of releasing 2 different versions.
__________________

Last edited by Napoleon_be; 01-19-2020 at 13:18.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 01-19-2020 , 13:42   Re: COD: HitMarkers [First release: 16/01/2020]
Reply With Quote #23

Xalus did not say "do not use pcvars", he said fXPos, fYPos, fHoldTime variables do not have to be global since they are used in only one function.

You should do:
PHP Code:
//In PostTakeDamage:
new fXPos get_pcvar_float(pXPosition);
new 
fYPos get_pcvar_float(pYPosition);
new 
fHoldTime get_pcvar_float(pHoldTime); 
Quote:
Half-Life, Gearbox, CS 1.6. Your code. Anytime get_user_team is introduced without the cstrike_running() other mods are no longer compatible. Take 'get_user_team' out, they work. Put it back with cstrike_running() it bridges the gap. It then works on more than 1 mod.
This doesn't make any sense.
get_user_team IS NOT CS specific. cs_get_user_team is. By adding cstrike_running the only thing you did is prevent the code from running in any other mod because the point of the native is to check if cstrike is running. If it isn't, then the if check will fail and no code will be executed.

I don't think I have to explain further, but:
PHP Code:
if(is_user_connected(iAttacker) && get_pcvar_num(pPlugin) && cstrike_running() && get_user_team(iVictim) != get_user_team(iAttacker)) 
Reads as: if user is connected, plugin is on, MOD IS CSTRIKE, and victim and attacker are on different teams do something. If mod is not cstrike the entire if fails and nothing is executed and the plugin is as good as disabled.
@OP, remove that check.

Quote:
He can use static variable to hold the value which will more optimized but the cvar change won't be set immediately. Need to change the map.
No, it won't be any more optimized.

Quote:
cvars are there to be changed immediatly, i won't be changing my code which will lead the plugin to require a map change in order for the cvars to change, even though that would optimize my code.
You are right about one thing: cvars are there to be changed immediately. Plus you are not losing any performance by not caching the cvars so there's literally 0 point in doing so in this case(and in most if not all cases).

P.S: having 2 versions for a small change seems overkill. Add a cvar and have only one version.
__________________

Last edited by HamletEagle; 01-19-2020 at 13:45.
HamletEagle is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 01-19-2020 , 16:25   Re: COD: HitMarkers [First release: 16/01/2020]
Reply With Quote #24

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)))) 
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Midnight Kid
Member
Join Date: Aug 2017
Location: Chornobay, Ukraine
Old 01-20-2020 , 02:37   Re: COD: HitMarkers [First release: 16/01/2020]
Reply With Quote #25

Napoleon_be, why don't you make it easier? I think, there's no need to make 2 especial SMAs, 'cause it just make cvar to select a group of weapons for which the hitmarker is available.
Midnight Kid is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 01-20-2020 , 06:44   Re: COD: HitMarkers [First release: 16/01/2020]
Reply With Quote #26

Quote:
Originally Posted by Midnight Kid View Post
Napoleon_be, why don't you make it easier? I think, there's no need to make 2 especial SMAs, 'cause it just make cvar to select a group of weapons for which the hitmarker is available.
That's what i'm trying to do in the check i posted above, but with no succes.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
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 #27

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
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 01-20-2020 , 12:50   Re: COD: HitMarkers [First release: 16/01/2020]
Reply With Quote #28

Thanks for the intel HamletEagle, will update my code and post update notes when i get home from work.
__________________

Last edited by Napoleon_be; 01-20-2020 at 12:50.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-20-2020 , 16:38   Re: COD: HitMarkers [First release: 16/01/2020]
Reply With Quote #29

I was able to remove a lot of redundant code. I started doing comments line-by-line to help you learn but it was getting messy. Compare this to your current code to see what I did. I didn't implement all of what others have suggested. Not tested.
Spoiler
__________________
Bugsy is offline
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 01-20-2020 , 18:07   Re: COD: HitMarkers [First release: 16/01/2020]
Reply With Quote #30

That's a potential bug report since both Half-life and Gearbox have teams.

Thank you for the plugin NapoleoN. This fork was tested on both cstrike and gearbox. Fun times. I added the screen fades.

Quote:
Originally Posted by DJEarthQuake View Post
All that is not needed unless say when over 100HP damage is done to make random color strobe like from this plugin does on confirmed kills.
Spoiler
__________________
DJEarthQuake is offline
Reply


Thread Tools
Display Modes

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 03:58.


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