AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Can somebody help :/ ? (https://forums.alliedmods.net/showthread.php?t=293853)

InteX01 02-12-2017 10:53

Can somebody help :/ ?
 
Code:

#include <amxmodx>
#include <amxmisc>

#define USERFLAG ADMIN_USER

public plugin_init() {
        register_clcmd("say", "usersay")
}
public usersay(id){
        if(get_user_flags(id) & USERFLAG)
        {
                return PLUGIN_HANDLED;
                ColorChat(id, GREEN, "[AMXX] ^3Chat is locked.")
        }
}

First im noob at this :3
I wanted to make LockChat plugin where Admin could lock chat by /lock - /unlock command to users with Z flag (just user)
Now i dont have idea how to make that or is it even possible :/

InteX01 02-12-2017 11:35

Re: Can somebody help :/ ?
 
I dont think this is gonna work cuz it doesnt mute player from chat by typing that command...

(If user with flag z types /lock or /unlock its only gonna say "Chat is locked" but still be able to chat. That return PLUGIN_HANDLED; will just be used to hide the command, thats not what i wanted but thanks anyway :))

yas17sin 02-12-2017 12:21

Re: Can somebody help :/ ?
 
maybe something like this should work.
PHP Code:

#include <amxmodx>
#include <amxmisc>
//#include <chatcolor>

#define ACSSES_LEVEL ADMIN_USER

public plugin_init() {
    
register_clcmd("say /lock""usersay")
    
register_clcmd("say /unlock""unsay")
}
public 
usersay(id)
{
    if(
get_user_flags(id) && ACSSES_LEVEL )
    {
        
client_cmd(id"amx_cvar hud_saytext_time 0")
        
//ColorChat(id, GREY, "[AMXX] ^3Chat is locked.")
        
client_print(idprint_chat"chat are now locked")
    }
    return 
PLUGIN_HANDLED;
}
public 
unsay(id)
{
    if(
get_user_flags(id) && ACSSES_LEVEL )
    {
        
client_cmd(id"amx_cvar hud_saytext_time 5")
        
//ColorChat(id, GREY, "[AMXX] ^3Chat is unlocked.")
        
client_print(idprint_chat,"chat are now unlocked")
    }
    return 
PLUGIN_HANDLED;



OciXCrom 02-12-2017 12:43

Re: Can somebody help :/ ?
 
No, it won't. It's not even correct.
Simply use a bool and toggle it true/false and return PLUGIN_HANDLED or PLUGIN_CONTINUE according to it.

edon1337 02-12-2017 12:48

Re: Can somebody help :/ ?
 
If you want it to allow say commands (/rs ..) to work use this.
PHP Code:

#include <amxmodx>

new bool:ChatLocked;

public 
plugin_init() {

    
register_plugin("Block Say""1.0""DoNii")

    
register_clcmd("say""block_say")
    
register_clcmd("say /lock""lock_say")
    
register_clcmd("say /unlock""unlock_say")
}

public 
block_say(id) {

    if(
ChatLocked)
    return 
PLUGIN_HANDLED_MAIN;

    return 
PLUGIN_CONTINUE;
}

public 
lock_say(id) {

    if(!(
get_user_flags(id) & ADMIN_USER)) 
    return 
PLUGIN_HANDLED;
    
    
ChatLocked true;
    
client_print(0print_chat"Chat Is Disabled")

    return 
PLUGIN_CONTINUE;    
}

public 
unlock_say(id) {

    if(!(
get_user_flags(id) & ADMIN_USER)) 
    return 
PLUGIN_HANDLED;
    
    if(
ChatLocked) {
        
ChatLocked false;
        
client_print(0print_chat"Chat Is Enabled")
    }
    
    
client_print(idprint_chat"Chat Is Already Enabled")
    return 
PLUGIN_CONTINUE;


Else if not, use this
PHP Code:

#include <amxmodx>

new bool:ChatLocked;

public 
plugin_init() {

    
register_plugin("Block Say""1.0""DoNii")

    
register_clcmd("say""block_say")
    
register_clcmd("say /lock""lock_say")
    
register_clcmd("say /unlock""unlock_say")
}

public 
block_say(id) {

    if(
ChatLocked)
    return 
PLUGIN_HANDLED;

    return 
PLUGIN_CONTINUE;
}

public 
lock_say(id) {

    if(!(
get_user_flags(id) & ADMIN_USER)) 
    return 
PLUGIN_HANDLED;
    
    
ChatLocked true;
    
client_print(0print_chat"Chat Is Disabled")

    return 
PLUGIN_CONTINUE;    
}

public 
unlock_say(id) {

    if(!(
get_user_flags(id) & ADMIN_USER)) 
    return 
PLUGIN_HANDLED;
    
    if(
ChatLocked) {
        
ChatLocked false;
        
client_print(0print_chat"Chat Is Enabled")
    }
    
    
client_print(idprint_chat"Chat Is Already Enabled")
    return 
PLUGIN_CONTINUE;



yas17sin 02-12-2017 12:56

Re: Can somebody help :/ ?
 
Quote:

Originally Posted by yas17sin (Post 2494899)
maybe something like this should work.
PHP Code:

#include <amxmodx>
#include <amxmisc>
//#include <chatcolor>

#define ACSSES_LEVEL ADMIN_USER

public plugin_init() {
    
register_clcmd("say /lock""usersay")
    
register_clcmd("say /unlock""unsay")
}
public 
usersay(id)
{
    if(
get_user_flags(id) && ACSSES_LEVEL )
    {
        
client_cmd(id"amx_cvar hud_saytext_time 0")
        
//ColorChat(id, GREY, "[AMXX] ^3Chat is locked.")
        
client_print(idprint_chat"chat are now locked")
    }
    return 
PLUGIN_HANDLED;
}
public 
unsay(id)
{
    if(
get_user_flags(id) && ACSSES_LEVEL )
    {
        
client_cmd(id"amx_cvar hud_saytext_time 5")
        
//ColorChat(id, GREY, "[AMXX] ^3Chat is unlocked.")
        
client_print(idprint_chat,"chat are now unlocked")
    }
    return 
PLUGIN_HANDLED;



actualy this did work i test it.

edon1337 02-12-2017 12:57

Re: Can somebody help :/ ?
 
Quote:

Originally Posted by yas17sin (Post 2494924)
actualy this did work i test it.

What does 'hud_saytext_time 5' do ?

Natsheh 02-12-2017 13:09

Re: Can somebody help :/ ?
 
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <colorchat>

#define USERFLAG ADMIN_USER

new bool:chat_locked

public plugin_init() {
        
register_plugin("Block the Chat""1.0""Natsheh")
    
register_clcmd("say""usersay")
        
register_clcmd("say_team""usersay")
        
register_clcmd("say /lock""lock_chat"ADMIN_KICK)
}

public 
lock_chat(idlevelcid)
{
             if(!
cmd_access(idlevelcid1)) return 1;

             
chat_locked chat_locked false:true
             ColorChat
(0GREEN"[AMXX] ^3The Chat has been %slocked."chat_locked "":"un")
             return 
0;
}
public 
usersay(id){
        if(!
chat_locked) return PLUGIN_CONTINUE;
        
    if(
get_user_flags(id) & USERFLAG)
    {
        
ColorChat(idGREEN"[AMXX] ^3Chat is locked.")
                return 
PLUGIN_HANDLED
    
}
        return 
PLUGIN_CONTINUE;



Natsheh 02-12-2017 13:12

Re: Can somebody help :/ ?
 
Quote:

Originally Posted by edon1337 (Post 2494925)
What does 'hud_saytext_time 5' do ?

Its a cvar which dosent remove the chat actually but its a cvar controls the display time of the message.

edon1337 02-12-2017 13:15

Re: Can somebody help :/ ?
 
And how's that supposed to block the chat?


All times are GMT -4. The time now is 21:03.

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