Raised This Month: $51 Target: $400
 12% 

Solved hide cvar no notification in chat


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
indraraj striker
Veteran Member
Join Date: Mar 2014
Location: Under the water
Old 02-18-2018 , 00:22   hide cvar no notification in chat
Reply With Quote #1

hide cvar no notification in chat
i want to hide this only cvar whether admin trying to change or server or from another plugin
cmd : amx_cvar the_notification "0"
I don't want to hide all cvars by doing this amx_show_activity 0

check below screenshot


Main plugin :
PHP Code:

#include amxmodx 

new TEST_CVAR;

public 
plugin_init()
{
    
TEST_CVAR register_cvar("the_notification","1"
    
// say hello to get msg
    
register_clcmd("say /hello","allied_welcome");
}

public 
allied_welcome(id)
{
   if(
get_pcvar_num(TEST_CVAR))
     {
        
client_print(id,print_chat,"Welcome to ALLIEDMODDERS");
     }
    else
    {
        
client_print(id,print_chat,"the cvar is off");
    }

from another plugin

PHP Code:

#include amxmodx

public plugin_init()
{
    
register_clcmd("say /disable","disable_cvar");
    
register_clcmd("say /enable","enable_cvar");
}

public 
disable_cvar(id)
{
      
server_cmd("amx_cvar the_notification 0");
      
client_print(id,print_chat,"off off off");
}

public 
enable_cvar(id)
{
    
server_cmd("amx_cvar the_notification 1");
    
client_print(id,print_chat,"on on on");

Thanks

Last edited by indraraj striker; 02-18-2018 at 09:16.
indraraj striker is offline
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: White Plains
Old 02-18-2018 , 02:28   Re: hide cvar no notification in chat
Reply With Quote #2

Have you tried using return PLUGIN_HANDLED?
__________________
Relaxing is offline
indraraj striker
Veteran Member
Join Date: Mar 2014
Location: Under the water
Old 02-18-2018 , 03:21   Re: hide cvar no notification in chat
Reply With Quote #3

thanks for reply,

return PLUGIN_HANDLED is for chat that will not work for cvar
indraraj striker is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-18-2018 , 04:43   Re: hide cvar no notification in chat
Reply With Quote #4

You shouldn't be using the amx_cvar command when setting a cvar from within a plugin. Simply use set_cvar_num().
__________________
fysiks is offline
indraraj striker
Veteran Member
Join Date: Mar 2014
Location: Under the water
Old 02-18-2018 , 05:35   Re: hide cvar no notification in chat
Reply With Quote #5

Quote:
Originally Posted by fysiks View Post
You shouldn't be using the amx_cvar command when setting a cvar from within a plugin. Simply use set_cvar_num().
thanks for reply,
i know set_cvar_num() will not give you notification when you change cvar
but i want to change that cvar from another plugin
indraraj striker is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 02-18-2018 , 05:37   Re: hide cvar no notification in chat
Reply With Quote #6

Quote:
Originally Posted by indraraj striker View Post
thanks for reply,
i know set_cvar_num() will not give you notification when you change cvar
but i want to change that cvar from another plugin
And that's exactly why you should use set_cvar_num(). What's the issue?
__________________
klippy is offline
indraraj striker
Veteran Member
Join Date: Mar 2014
Location: Under the water
Old 02-18-2018 , 05:48   Re: hide cvar no notification in chat
Reply With Quote #7

Quote:
Originally Posted by KliPPy View Post
And that's exactly why you should use set_cvar_num(). What's the issue?
set_pcvar_num() will work when you change cvar from within plugin
i want to change cvar from another plugin
Please refer my first post
indraraj striker is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 02-18-2018 , 06:31   Re: hide cvar no notification in chat
Reply With Quote #8

Quote:
Originally Posted by indraraj striker View Post
set_pcvar_num() will work when you change cvar from within plugin
That's not true, plugins don't own cvars. Did you even try it?
__________________

Last edited by klippy; 02-18-2018 at 06:31.
klippy is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 02-18-2018 , 06:57   Re: hide cvar no notification in chat
Reply With Quote #9

:facepalm:

Of course you get an undefined symbol, the_notification variable is not defined in your second plugin. Look at set_pcvar_num function prototype. The first argument is:
Quote:
pcvar
Pointer to cvar to set value of
It's a pointer to your cvar, this means you need a way to retrieve the pointer from the cvar name. If you simply search the api page for pointer you will get get_cvar_pointer function. It's argument is:
Quote:
cvar
Cvar name to find
Go figure from here what you should do.
__________________

Last edited by HamletEagle; 02-18-2018 at 06:57.
HamletEagle is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 02-18-2018 , 06:58   Re: hide cvar no notification in chat
Reply With Quote #10

Of course you are getting undefined symbol, what did you think that would do? There's a difference between set_pcvar_num and set_cvar_num. Also there's get_cvar_pointer if you would like to use the former solution.

EDIT:
Ninja'd. D:
__________________

Last edited by klippy; 02-18-2018 at 06:58.
klippy 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 04:34.


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