AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   enable/disable chat command (https://forums.alliedmods.net/showthread.php?t=228913)

Debesėlis 10-29-2013 08:11

enable/disable chat command
 
How can i make chat command (/info) with which player can enable / disable information? And is it possible to save what he choose by steam_id (to remember on reconnect or next map)?

Example : Player write /info and enable hud message information.
PHP Code:

show_dhudmessage0"info about server"); 


DWIGHTpN 10-29-2013 08:47

Re: enable/disable chat command
 
PHP Code:

new bool:msg[33];
//or bitsum..
new const message[] = "bla...";

public 
plugin_init() {
      
set_task(1.0"MsgApp"0_0"b");
      
register_clcmd("say /info""clcmd_msg");
}

public 
MsgApp() {
      static 
players[32],iNum,player;
      
get_players(playersiNum"ch");
      for(new 
i;i<iNum;i++) {
          
player players[i];
          if( 
msg[player] ) {
               
set_dhudmessage(50,150,250, -1.0, -1.011.01.10.10.1true);
               
show_dhudmessage(playermessage);
          }
      }
}

public 
clcmd_msg(id){
       
msg[id] = msg[id] ? false true;
       return 
PLUGIN_CONTINUE;  // or handled if you want..


You want the message to remain permanently on hud or for 10,15 sec..?

Quote:

And is it possible to save what he choose by steam_id (to remember on reconnect or next map)?
It's possible with nvault, but i think is bad idea to save this...

Debesėlis 10-29-2013 09:54

Re: enable/disable chat command
 
Quote:

Originally Posted by DWIGHTpN (Post 2054140)
PHP Code:

new bool:msg[33];
//or bitsum..
new const message[] = "bla...";

public 
plugin_init() {
      
set_task(1.0"MsgApp"0_0"b");
      
register_clcmd("say /info""clcmd_msg");
}

public 
MsgApp() {
      static 
players[32],iNum,player;
      
get_players(playersiNum"ch");
      for(new 
i;i<iNum;i++) {
          
player players[i];
          if( 
msg[player] ) {
               
set_dhudmessage(50,150,250, -1.0, -1.011.01.10.10.1true);
               
show_dhudmessage(playermessage);
          }
      }
}

public 
clcmd_msg(id){
       
msg[id] = msg[id] ? false true;
       return 
PLUGIN_CONTINUE;  // or handled if you want..


You want the message to remain permanently on hud or for 10,15 sec..?


It's possible with nvault, but i think is bad idea to save this...

How about message?
PHP Code:

msgid ] = msgid ] ? print_chatid"%L"LANG_SERVER"INFO_ON" true print_chatid"%L"LANG_SERVER"INFO_OFF" false

Is this will work?
PHP Code:

switch (msgid ] )
{
    case 
0:
    {
        
msgid ] = false;
print_chatid"%L"LANG_SERVER"INFO_OFF" )
    }
    
    case 
1:
    {
        
msgid ] = true;
print_chatid"%L"LANG_SERVER"INFO_ON" )
    }



simanovich 10-29-2013 10:24

Re: enable/disable chat command
 
Quote:

Originally Posted by Debesėlis (Post 2054163)
How about message?
PHP Code:

msgid ] = msgid ] ? print_chatid"%L"LANG_SERVER"INFO_ON" true print_chatid"%L"LANG_SERVER"INFO_OFF" false

Is this will work?
PHP Code:

switch (msgid ] )
{
    case 
0:
    {
        
msgid ] = false;
print_chatid"%L"LANG_SERVER"INFO_OFF" )
    }
    
    case 
1:
    {
        
msgid ] = true;
print_chatid"%L"LANG_SERVER"INFO_ON" )
    }



PHP Code:

msg[id] = msg[id] ? false true

---------->
PHP Code:

msg[id] = !msg[id]; 

&
PHP Code:

msgid ] = msgid ] ? print_chatid"%L"LANG_SERVER"INFO_ON" true print_chatid"%L"LANG_SERVER"INFO_OFF" false

--------->
PHP Code:

print_chat(id,"%L",id,(msg[id] ? "INFO_ON":"INFO_OFF")); 


Debesėlis 10-29-2013 12:19

Re: enable/disable chat command
 
Quote:

Originally Posted by simanovich (Post 2054167)
PHP Code:

msg[id] = msg[id] ? false true

---------->
PHP Code:

msg[id] = !msg[id]; 

&
PHP Code:

msgid ] = msgid ] ? print_chatid"%L"LANG_SERVER"INFO_ON" true print_chatid"%L"LANG_SERVER"INFO_OFF" false

--------->
PHP Code:

print_chat(id,"%L",id,(msg[id] ? "INFO_ON":"INFO_OFF")); 



Quote:

Originally Posted by simanovich (Post 2054167)
PHP Code:

msg[id] = !msg[id]; 


With this will be enabled by default ?
PHP Code:

msg[id] = msg[id]; 


simanovich 10-29-2013 12:39

Re: enable/disable chat command
 
Quote:

Originally Posted by Debesėlis (Post 2054227)
With this will be enabled by default ?
PHP Code:

msg[id] = msg[id]; 


No.

This expression has no effect.

Debesėlis 10-29-2013 13:10

Re: enable/disable chat command
 
To enable by default must be like this?


PHP Code:

new bool:msg[33] = true


simanovich 10-29-2013 14:49

Re: enable/disable chat command
 
Quote:

Originally Posted by Debesėlis (Post 2054248)
To enable by default must be like this?


PHP Code:

new bool:msg[33] = true


No.

The way is this:
PHP Code:

new bool:msg[33] = { true, ... }; 



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

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