AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Is This Well Done? (https://forums.alliedmods.net/showthread.php?t=127909)

#8 SickneSS 05-26-2010 10:21

Is This Well Done?
 
Doesn't works for me
PHP Code:

//Global
new pFreezetime;

//Init 
    
pFreezetime get_cvar_pointer("mp_freezetime");
    
    
register_clcmd("say","hookSay");

public 
hookSay(id) {

      if(
get_pcvar_float(pFreezetime) <= 0)
      {
             
client_print(id,print_chat,"Chat is blocked");
             return 
PLUGIN_HANDLED;
      }
      else
             return 
PLUGIN_CONTINUE;

      return 
PLUGIN_HANDLED;



Xellath 05-26-2010 10:32

Re: Is This Well Done?
 
What is mp_freezetime set to?

#8 SickneSS 05-26-2010 11:08

Re: Is This Well Done?
 
Quote:

Originally Posted by Xellath (Post 1191700)
What is mp_freezetime set to?

if mp_freezetime are more than 0,players can chat,if not,block the chat.

Mxnn 05-26-2010 12:07

Re: Is This Well Done?
 
You are hooking say with the last PLUGIN_HANDLED


Try this
PHP Code:

public hooksay(id) {
if (
get_pcvar_float(pFreezeTime) <= 0) {
            
client_print(idprint_chat"Chat is blocked")
            return 
PLUGIN_HANDLED
}

return 
PLUGIN_CONTINUE



Brreaker 05-26-2010 12:10

Re: Is This Well Done?
 
Wrong. <= it's not greater or equal, it's the exact opposite...
This would be correct:

PHP Code:

public hooksay(id) {
if (
get_pcvar_float(pFreezeTime) > 0.0) {
            
client_print(idprint_chat"Chat is blocked")
            return 
PLUGIN_HANDLED
}

return 
PLUGIN_CONTINUE



#8 SickneSS 05-26-2010 12:13

Re: Is This Well Done?
 
I'll try,thanks

Sylwester 05-26-2010 12:25

Re: Is This Well Done?
 
Brreaker you are wrong. He said he wants it to allow chat if mp_freezetime is "more than 0". Your code will do the exact opposite.

#8 SickneSS: the code from your first post works fine.

Brreaker 05-26-2010 12:30

Re: Is This Well Done?
 
Sorry, I misunderstood
Why don't you just use:
PHP Code:

if(!get_pcvar_float(pFreezeTime)) // if the value is 0
    
return PLUGIN_HANDLED;
else 
// else if is greater than 0, allow chat.
    
return PLUGIN_CONTINUE


Sylwester 05-26-2010 12:40

Re: Is This Well Done?
 
It's not freezetime < 0, but freezetime <= 0 (with "mp_freezetime 0" it will return true).

unnyquee 05-26-2010 12:44

Re: Is This Well Done?
 
PHP Code:

#include <amxmodx>

new g_pFreezeTime;


public 
plugin_init()
{
      
register_plugin("O""M""G");

      
g_pFreezeTime get_cvar_pointer("mp_freezetime");

      
register_clcmd("say""ClientCommand_Say");
}

public 
ClientCommand_Say(iClient)
{
      if(
get_pcvar_num(g_cFreezeTime) <= 0)
      {
            
client_print(iClientprint_chat"* Chat is blocked!");

            return 
PLUGIN_HANDLED;
      }

      return 
PLUGIN_CONTINUE;


Not tested, though.

When do you want to block the chat?
After the freezetime passes or if the 'mp_freezetime' cvar value is lower / equal to 0?


All times are GMT -4. The time now is 05:22.

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