AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   adminchat modification [SOLVED] (https://forums.alliedmods.net/showthread.php?t=87960)

ehha 03-18-2009 16:28

adminchat modification [SOLVED]
 
I wanted to modify admin chat to display a amx_chat message if you type @message in say if you have ADMIN_CHAT flag or just @message in normal say chat if yo don't.

Code:
public plugin_init() {     register_clcmd("say", "chat123", ADMIN_ALL, "@stuff") } public chat123(id, level, cid) {     if(get_user_flags(id) & ADMIN_CHAT)         return PLUGIN_CONTINUE     new said[2]     read_argv(1, said, 1)         if (said[0] != '@')         return PLUGIN_CONTINUE         new message[192], name[32], players[32], inum, authid[32], userid         read_args(message, 191)     remove_quotes(message)     get_user_authid(id, authid, 31)     get_user_name(id, name, 31)     userid = get_user_userid(id)     get_players(players, inum)         log_amx("Chat: ^"%s<%d><%s><>^" chat ^"%s^"", name, userid, authid, message)     log_message("^"%s<%d><%s><>^" triggered ^"admin_chat^" (text ^"%s^")", name, userid, authid, message)         format(message, 191, "(Admin Chat) %s :   %s", name, message[1])     console_print(id, "%s", message)         for (new i = 0; i < inum; ++i)     {         if (access(players[i], ADMIN_CHAT))             client_print(players[i], print_chat, "%s", message)     }         return PLUGIN_HANDLED }

It works when i have the chat flag but wen i don't it doesn't display anything and i get this in the server's console:
Code:

L 03/18/2009 - 22:02:39: [adminchat.amxx] Chat: "player<5><STEAM_0:1:8796278><>" chat "@test 123"
L 03/18/2009 - 22:02:39: "player<5><STEAM_0:1:8796278><>" triggered "amx_chat" (text "@test 123")

One more thing, after reading the info from the return constants i still don't know how to use the correctly. Can someone explain and perhaps give me 3 examples for PLUGIN_CONTINUE, PLUGIN_HANDLED, PLUGIN_HANDLED_MAIN?
Thank you.

slice231`SD 03-21-2009 04:14

Re: adminchat modification
 
have you used colorchat.inc?

ehha 03-21-2009 09:54

Re: adminchat modification
 
Nope.

DruGzOG 04-01-2009 22:56

Re: adminchat modification
 
In this plugin-

plugin_handled_main isn't really necessary.

And what you want I dont really understand

Code:

/* Plugin generated by Zombie Zealots
||||||||||www.zombiezealots.com||||||||||
Enjoy the Plugin */
#include <amxmodx>
#define PLUGIN "Chat"
#define VERSION "1.0"
#define AUTHOR "Ehha"


public plugin_init()
{
    register_clcmd("say", "chat123", ADMIN_ALL, "@stuff"),
    register_clcmd("say_team", "chat123", ADMIN_ALL, "@stuff")
}

public chat123(id, level, cid)
{
    if(get_user_flags(id) & ADMIN_CHAT)
        return PLUGIN_CONTINUE

    new said[2]
    read_argv(1, said, 1)
   
    if (said[0] !=
'@')
        return PLUGIN_CONTINUE
   
    new message[192], name[32], players[32], inum, authid[32], userid
   
    read_args(message, 191)
    remove_quotes(message)
    get_user_authid(id, authid, 31)
    get_user_name(id, name, 31)
    userid = get_user_userid(id)
    get_players(players, inum)
   
    log_amx("Chat: ^"%s<%d><%s><>^" chat ^"%s^"", name, userid, authid, message)
    log_message("^"%s<%d><%s><>^" triggered ^"admin_chat^" (text ^"%s^")", name, userid, authid, message)
   
    format(message, 191, "(Admin Chat) %s :  %s", name, message[1])
    console_print(id, "%s", message)
   
    for (new i = 0; i < inum; ++i)
    {
        if (access(players[i], ADMIN_CHAT))
            client_print(players[i], print_chat, "%s", message)
    }
   
    return PLUGIN_HANDLED

}


ehha 04-02-2009 06:42

Re: adminchat modification
 
Thanks for the info.
I want to make a shortcut for amx_chat in the normal chat (say command).
This shortcut will use '@' so:

Code:
public chat123(id, level, cid) { if( (sayd[0]==@) && (get_user_flags(id) & ADMIN_CHAT) ) display message without @ for all players with admin_chat flag else display the full message (with @) in normal say (like this plugin did not exists) }

Now, the way i tried it blocks normal chat for non-admin users, after i fixed that, messages (with @ in front) from non-admin users don't display at all & triggers the logs (this should not happen for non-admin users).

LATER EDIT: I managed to do it myself with your help on the return plugin_handeld, thanks again.


All times are GMT -4. The time now is 09:00.

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