AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to achieve the same result without cvar (https://forums.alliedmods.net/showthread.php?t=325093)

Abhinash 06-08-2020 03:34

How to achieve the same result without cvar
 
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.

HamletEagle 06-08-2020 04:40

Re: How to achieve the same result without cvar
 
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.

thEsp 06-08-2020 05:29

Re: How to achieve the same result without cvar
 
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.

Abhinash 06-08-2020 06:22

Re: How to achieve the same result without cvar
 
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 ?

HamletEagle 06-08-2020 07:06

Re: How to achieve the same result without cvar
 
PHP Code:

new 1

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

switch(
x)
{
    case 
0
    {
    }

    case 
1:
    {
    }



Abhinash 06-09-2020 10:43

Re: How to achieve the same result without cvar
 
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 ?

Abhinash 06-09-2020 10:56

Re: How to achieve the same result without cvar
 
Thanks Hamlet btw.
Got it fixed.
Actually I was using one '=' instead of '=='


All times are GMT -4. The time now is 16:49.

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