Raised This Month: $32 Target: $400
 8% 

Print To All Admins


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
noodleboy347
AlliedModders Donor
Join Date: Mar 2009
Old 11-11-2009 , 17:35   Print To All Admins
Reply With Quote #1

How could I use PrintToChat and have it show up to all of the admins?
noodleboy347 is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 11-11-2009 , 20:01   Re: Print To All Admins
Reply With Quote #2

Simple version:
PHP Code:
stock PrintToAdmins(const String:sMessage[])
{
    for (new 
1<= MaxClientsi++)
    {
        if (
IsClientInGame(i))
        {
            new 
flags GetUserFlagBits(i);
            if (
flags ADMFLAG_GENERIC || flags ADMFLAG_ROOT)
            {
                
PrintToChat(isMessage);
            }
        }
    }

Using a stock I wrote:

PHP Code:
stock PrintToAdmins(const String:sMessage[])
{
    for (new 
1<= MaxClientsi++)
    {
        if (
IsClientInGame(i))
        {
            new 
flags GetUserFlagBits(i);
            if (
CheckAdminFlags(iADMFLAG_GENERIC))
            {
                
PrintToChat(isMessage);
            }
        }
    }
}

/**
 * Checks to see if a client has all of the specified admin flags
 *
 * @param client        Player's index.
 * @param flags            Flags to check for.
 * @return                True on admin having all flags, false otherwise.
 */
stock bool:CheckAdminFlags(clientflags)
{
    new 
AdminId:admin GetUserAdmin(client);
    if (
admin != INVALID_ADMIN_ID)
    {
        new 
countfound;
        for (new 
0<= 20i++)
        {
            if (
flags & (1<<i))
            {
                
count++;

                if (
GetAdminFlag(adminAdminFlag:i))
                {
                    
found++;
                }
            }
        }

        if (
count == found)
        {
            return 
true;
        }
    }

    return 
false;

bl4nk is offline
meng
Veteran Member
Join Date: Oct 2005
Location: us
Old 11-11-2009 , 22:11   Re: Print To All Admins
Reply With Quote #3

oops, nvm, listen to that guy ^^^

Last edited by meng; 11-11-2009 at 22:17.
meng is offline
Send a message via Yahoo to meng
FaTony
Veteran Member
Join Date: Aug 2008
Old 11-12-2009 , 09:38   Re: Print To All Admins
Reply With Quote #4

I'm using this:
PHP Code:
public InformAdmin (const String:rawmessage[], any:...)
{
    new 
String:message[MESSAGE_LENGTH];
    
VFormat(messageMESSAGE_LENGTHrawmessage2);
    new 
AdminId:id=INVALID_ADMIN_ID;
    
PrintToServer(message);
    new 
clients=GetClientCount();
    for (new 
i=1;i<=clients;i++) {
        if (
IsClientConnected(i)) {
            
id=GetUserAdmin(i);
            if (
id!=INVALID_ADMIN_ID) {
                
PrintToConsole(imessage);
                
PrintToChat(imessage);
                }
            }
        }

FaTony is offline
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: The Netherlands
Old 11-12-2009 , 10:42   Re: Print To All Admins
Reply With Quote #5

That's wrong FaTony, using GetClientCount() in a for-loop might leave out clients. Use MaxClients instead. Also a little more spacing to make it more readable wouldn't hurt
__________________
Advertisements | REST in Pawn - HTTP client for JSON REST APIs
Please do not PM me with questions. Post in the plugin thread.
DJ Tsunami is offline
exvel
SourceMod Donor
Join Date: Jun 2006
Location: Russia
Old 11-12-2009 , 14:07   Re: Print To All Admins
Reply With Quote #6

Quote:
Originally Posted by FaTony View Post
I'm using this:
PHP Code:
public InformAdmin (const String:rawmessage[], any:...)
{
    new 
String:message[MESSAGE_LENGTH];
    
VFormat(messageMESSAGE_LENGTHrawmessage2);
    new 
AdminId:id=INVALID_ADMIN_ID;
    
PrintToServer(message);
    new 
clients=GetClientCount();
    for (new 
i=1;i<=clients;i++) {
        if (
IsClientConnected(i)) {
            
id=GetUserAdmin(i);
            if (
id!=INVALID_ADMIN_ID) {
                
PrintToConsole(imessage);
                
PrintToChat(imessage);
                }
            }
        }

Use IsClientInGame instead of IsClientConnected. Or there may be erros.
__________________
For admins: My plugins

For developers: Colors library
exvel is offline
Send a message via ICQ to exvel
BrutalGoerge
AlliedModders Donor
Join Date: Jul 2007
Old 11-12-2009 , 14:24   Re: Print To All Admins
Reply With Quote #7

well i this it's better to look at people with root or ban, since i have admins with just a flag for reservation, or s flag for reskick immunity.
__________________
My Pluggies If you like, consider to me.
BrutalGoerge is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 11-12-2009 , 22:10   Re: Print To All Admins
Reply With Quote #8

Quote:
Originally Posted by BrutalGoerge View Post
well i this it's better to look at people with root or ban, since i have admins with just a flag for reservation, or s flag for reskick immunity.
That's why in my version I specified the b/z flags. Also with the second example I provided you could specify multiple flags and it would only fire if the clients had all of the flags. For example:

PHP Code:
if (CheckAdminFlags(clientADMFLAG_GENERIC|ADMFLAG_BAN|ADMFLAG_SLAY))
{
    
// do stuff

I also have a slightly modified version that makes it so if any of the specified admin flags are found on the client it will trigger, if you would like that.
bl4nk is offline
p3tsin
Senior Member
Join Date: Sep 2005
Location: Finland
Old 11-12-2009 , 22:54   Re: Print To All Admins
Reply With Quote #9

Quote:
Originally Posted by bl4nk View Post
Also with the second example I provided you could specify multiple flags and it would only fire if the clients had all of the flags. For example:

PHP Code:
if (CheckAdminFlags(clientADMFLAG_GENERIC|ADMFLAG_BAN|ADMFLAG_SLAY))
{
    
// do stuff

... isnt that the same as this?

PHP Code:
if((GetUserFlagBits(client) & ADMFLAG_GENERIC|ADMFLAG_BAN|ADMFLAG_SLAY) == ADMFLAG_GENERIC|ADMFLAG_BAN|ADMFLAG_SLAY) {
    
//do stuff

__________________
plop
p3tsin is offline
FaTony
Veteran Member
Join Date: Aug 2008
Old 11-13-2009 , 09:28   Re: Print To All Admins
Reply With Quote #10

Well my code was written in early 2008 when I was a complete noob in scripting. I'll fix it.

EDIT: Fixed.
PHP Code:
public InformAdmin (const String:rawmessage[], any:...)
{
    
decl String:message[MESSAGE_LENGTH];
    
VFormat(messageMESSAGE_LENGTHrawmessage2);
    new 
AdminId:id=INVALID_ADMIN_ID;
    
PrintToServer(message);
    for (new 
i=1;i<=MaxClients;i++) {
        if (
IsClientInGame(i)) {
            
id=GetUserAdmin(i);
            if (
id!=INVALID_ADMIN_ID) {
                
PrintToConsole(imessage);
                
PrintToChat(imessage);
                }
            }
        }


Last edited by FaTony; 11-13-2009 at 09:39.
FaTony is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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