AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Help] Adding Minimum Distance (https://forums.alliedmods.net/showthread.php?t=332679)

Agent3554 05-26-2021 21:01

[Help] Adding Minimum Distance
 
How do I include minimum distance as well?
PHP Code:

amx_bulletwhizz_dis register_cvar("amx_bulletwhizz_maxdis""3000"
amx_bulletwhizz_dis register_cvar("amx_bulletwhizz_mindis""300"

//This is the part where it calculates the distance, I don't know where should I add minimum distance
if( flDistance 0.0 || flDistance get_pcvar_float(amx_bulletwhizz_maxdis) || !fm_is_ent_visible(idtarget)) 


Basically:
I could hear bullet whizz when someone shoots towards me even from 0 to 3000 meters, what I want to happen is to add minimum range, so I could only hear it from 300 or 500 to 3000 meters

Bugsy 05-26-2021 21:13

Re: [Help] Adding Minimum Distance
 
Try this
PHP Code:

if( flDistance 0.0 || ( get_pcvar_float(amx_bulletwhizz_mindis) <= flDistance <= get_pcvar_float(amx_bulletwhizz_maxdis) || !fm_is_ent_visible(idtarget)) 


Agent3554 05-26-2021 21:22

Re: [Help] Adding Minimum Distance
 
Quote:

Originally Posted by Bugsy (Post 2747917)
Try this
PHP Code:

if( flDistance 0.0 || ( get_pcvar_float(amx_bulletwhizz_mindis) <= flDistance <= get_pcvar_float(amx_bulletwhizz_maxdis) || !fm_is_ent_visible(idtarget)) 


It works, thank you very much!

Agent3554 05-28-2021 09:09

Re: [Help] Adding Minimum Distance
 
I realized that this was also possible
PHP Code:

amx_bulletwhizz_dis register_cvar("amx_bulletwhizz_maxdis""3000"
amx_bulletwhizz_dis register_cvar("amx_bulletwhizz_mindis""300"

if( 
flDistance get_pcvar_float(amx_bulletwhizz_mindis) || flDistance get_pcvar_float(amx_bulletwhizz_maxdis) || !fm_is_ent_visible(idtarget)) 


Bugsy 05-28-2021 15:16

Re: [Help] Adding Minimum Distance
 
You can do things many different ways. My code checks both with a single condition.


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

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