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

How to achieve the same result without cvar


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Abhinash
Senior Member
Join Date: Jan 2015
Location: India,kolkata
Old 06-08-2020 , 03:34   How to achieve the same result without cvar
Reply With Quote #1

Hey there everyone.
So, I don't want to use cvars in my plugins.
Thats why I want to know how to achieve the same result without using cvar.
I did some with normal variables, but I am not able to do proper expression which checking the switch cvars ( 0 and 1 eg. amx_on ).
So can you guys help me out.

I have a variable amx_glow set to 1.
Now, I want to make a check in a function. Can you tell me how to do the proper check with a small example code ?
Thanks.
Abhinash is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-08-2020 , 04:40   Re: How to achieve the same result without cvar
Reply With Quote #2

Use cvars. If you are planning to post/release your plugin here then this is mandatory. Hardcoding every configuration in the source file is bad practice and makes it so much harder for the regular user to tweak the setting to his liking.
__________________

Last edited by HamletEagle; 06-08-2020 at 04:41.
HamletEagle is offline
thEsp
BANNED
Join Date: Aug 2017
Old 06-08-2020 , 05:29   Re: How to achieve the same result without cvar
Reply With Quote #3

I completely agree with Hamlet. Use the advantage of configurations to the disadvantage of cvars, which if you didn't know is, having multiple unlimited settings per something.
thEsp is offline
Abhinash
Senior Member
Join Date: Jan 2015
Location: India,kolkata
Old 06-08-2020 , 06:22   Re: How to achieve the same result without cvar
Reply With Quote #4

The plugin is for my own use. And my liking about cvar is just a personal preference.
Then also, even if it becomes hard-coded. I want to know how to do it, cause I want to learn from it.
So, can anyone tell me how to ?
Abhinash is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-08-2020 , 07:06   Re: How to achieve the same result without cvar
Reply With Quote #5

PHP Code:
new 1

if(== 0)
{
}
else if(
== 1)
{
}

switch(
x)
{
    case 
0
    {
    }

    case 
1:
    {
    }

__________________
HamletEagle is offline
Abhinash
Senior Member
Join Date: Jan 2015
Location: India,kolkata
Old 06-09-2020 , 10:43   Re: How to achieve the same result without cvar
Reply With Quote #6

Hey @HamletEagle
I tried the way you said with this piece of code --

PHP Code:
if (g_nemesis[id])
        {
            if(
NEMESIS_GLOW 1)
            {
                
fm_set_rendering(idkRenderFxGlowShell25000kRenderNormal)
            
            }
            else if(
NEMESIS_GLOW 0)
            {
                
fm_set_rendering(id)
            }
        }
        else if (
g_assassin[id])
        {
            if(
ASSASSIN_GLOW 1)
            {
                
fm_set_rendering(idkRenderFxGlowShell255140 0kRenderNormal)
            }
            else if(
ASSASSIN_GLOW 0)
            {
                
fm_set_rendering(id)
            }
        } 
This result is it as expected.
The glow is still there even after setting NEMESIS_GLOW and ASSASSIN_GLOW to 0.

How to fix it ?

Last edited by Abhinash; 06-09-2020 at 10:45.
Abhinash is offline
Abhinash
Senior Member
Join Date: Jan 2015
Location: India,kolkata
Old 06-09-2020 , 10:56   Re: How to achieve the same result without cvar
Reply With Quote #7

Thanks Hamlet btw.
Got it fixed.
Actually I was using one '=' instead of '=='
Abhinash is offline
Reply



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


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