AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Chat On Off (https://forums.alliedmods.net/showthread.php?t=281513)

notahacker 04-13-2016 11:07

Chat On Off
 
Hi Mates.. I currently have a plugin that disables the chat (cs 1.6).

Code:

public plugin_init()
{
        register_plugin(PLUGIN, VERSION, AUTHOR)
        register_clcmd( "say", "Cmd_Say" );
   
}

public Cmd_Say()
    return PLUGIN_HANDLED_MAIN;

I want to register a command, For example, amx_nochat. when i put "amx_nochat 1", the plugin activates. and when i put "amx_nochat 0", the plugin disactivates and chat is on once again.

i've been trying to edit the plugin, but i'm failing.

Can any mate help please? :oops: Or just give me an example. i've been looking at other plugins but i still can't do it.

Thankss mates :)

gabuch2 04-13-2016 11:13

Re: Chat On Off
 
PHP Code:

new cv_chat

public plugin_init() 
{
    
cv_chat register_cvar("amx_chat_enable""1")
    
register_plugin(PLUGINVERSIONAUTHOR)     
    
register_clcmd"say""Cmd_Say" 
}  

public 
Cmd_Say()
{
    if(
get_pcvar_num(cv_chat) == 0)
        return 
PLUGIN_HANDLED_MAIN


Untested. But it should work.

notahacker 04-13-2016 11:29

Re: Chat On Off
 
Thank you very much.. But these errors


Warning: Possibly unintended assignment on line 19
Error: Must be lvalue (non-constant) on line 19
Warning: Expression has no effect on line 19
Error: Expected token: ";", but found ")" on line 19
Error: Invalid expression, assumed zero on line 19
Error: Too many error messages on one line on line 19


line 19 is
Code:

if(get_pcvar_num(cv_chat) = 0)



Quote:

Originally Posted by Shattered Heart Lynx (Post 2410710)
PHP Code:

new cv_chat

public plugin_init() 
{
    
cv_chat register_cvar("amx_chat_enable""1")
    
register_plugin(PLUGINVERSIONAUTHOR)     
    
register_clcmd"say""Cmd_Say" 
}  

public 
Cmd_Say()
{
    if(
get_pcvar_num(cv_chat) = 0)
        return 
PLUGIN_HANDLED_MAIN


Untested. But it should work.


gabuch2 04-13-2016 11:31

Re: Chat On Off
 
My bad

= is ==, just edited my post above

notahacker 04-13-2016 11:47

Re: Chat On Off
 
Perfect. The == always gets us :D

Thanks mate :)

siriusmd99 04-13-2016 12:37

Re: Chat On Off
 
Use handled without main, plugins down won't be called.
Here's:
PHP Code:


new cv_chat

public plugin_init() 
{
    
cv_chat register_cvar("amx_chat_enable""1")
    
register_plugin(PLUGINVERSIONAUTHOR)     
    
register_clcmd"say""Cmd_Say" 
}  

public 
Cmd_Say()
{
    if(!
get_pcvar_num(cv_chat))
        return 
PLUGIN_HANDLED




All times are GMT -4. The time now is 18:42.

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