Raised This Month: $ Target: $400
 0% 

Print chat only to the admins


Post New Thread Reply   
 
Thread Tools Display Modes
napster_10
Senior Member
Join Date: May 2016
Old 11-17-2018 , 12:30   Re: Print chat only to the admins
Reply With Quote #21

Quote:
Originally Posted by Antithasys View Post
PHP Code:
stock PrintToAdmins(const String:message[], const String:flags[])
{
    for (new 
1<= MaxClientsx++)
    {
        if (
IsValidClient(x) && IsValidAdmin(xflags))
        {
            
PrintToChat(xmessage);
        }
    }
}

stock bool:IsValidClient(clientbool:nobots true)

    if (
client <= || client MaxClients || !IsClientConnected(client) || (nobots && IsFakeClient(client)))
    { 
      return 
false
    } 
    return 
IsClientInGame(client); 
}

stock bool:IsValidAdmin(client, const String:flags[])
{
    new 
ibFlags ReadFlagString(flags);
    if ((
GetUserFlagBits(client) & ibFlags) == ibFlags)
    {
        return 
true;
    }
    if (
GetUserFlagBits(client) & ADMFLAG_ROOT)
    {
        return 
true;
    }
    return 
false;

Usage:
PHP Code:
PrintToAdmins(messageflags); 
Where message = the message you want to send and
flags = the char admin flags like "z" or "a" etc.
hi im trying to use this code but i get this error
Code:
error 147: new-style declarations are required
can someone help?

Last edited by napster_10; 11-17-2018 at 12:31.
napster_10 is offline
Whai
Senior Member
Join Date: Jul 2018
Old 11-17-2018 , 12:46   Re: Print chat only to the admins
Reply With Quote #22

Quote:
Originally Posted by napster_10 View Post
hi im trying to use this code but i get this error
Code:
error 147: new-style declarations are required
can someone help?
PHP Code:
stock void PrintToAdmins(const char[] message, const char[] flags)
{
    for (
int x 1<= MaxClientsx++)
    {
        if (
IsValidClient(x) && IsValidAdmin(xflags))
        {
            
PrintToChat(xmessage);
        }
    }
}

stock bool IsValidClient(int clientbool nobots true)

    if (
client <= || client MaxClients || !IsClientConnected(client) || (nobots && IsFakeClient(client)))
    { 
      return 
false
    } 
    return 
IsClientInGame(client); 
}

stock bool IsValidAdmin(int client, const char[] flags)
{
    
int ibFlags ReadFlagString(flags);
    if ((
GetUserFlagBits(client) & ibFlags) == ibFlags)
    {
        return 
true;
    }
    if (
GetUserFlagBits(client) & ADMFLAG_ROOT)
    {
        return 
true;
    }
    return 
false;

You are using old synthax but you added at the begin of your plugin "#pragma newdecls required"

That means you have to only use new synthax
__________________
Whai is offline
napster_10
Senior Member
Join Date: May 2016
Old 11-17-2018 , 13:09   Re: Print chat only to the admins
Reply With Quote #23

eehm dont know how to do new syntax im knub xD

but i have another question

when i use this
Code:
ReplyToCommand(client, "[SM] SourceTV is now recording...");
on command tv_record ...

will then everyone on server see this massage in chat or only the one who used the command?
napster_10 is offline
Papero
Veteran Member
Join Date: Aug 2016
Location: Italy
Old 11-17-2018 , 13:57   Re: Print chat only to the admins
Reply With Quote #24

Quote:
Originally Posted by napster_10 View Post
eehm dont know how to do new syntax im knub xD

but i have another question

when i use this
Code:
ReplyToCommand(client, "[SM] SourceTV is now recording...");
on command tv_record ...

will then everyone on server see this massage in chat or only the ones who used the command?
Just the user who issue the command: https://sm.alliedmods.net/new-api/co...ReplyToCommand
__________________
My Plugins
SPCode


Steam: hexer504
Telegram: Hexah
Discord: Hexah#6903

If you like my work you can donate here!

Last edited by Papero; 11-17-2018 at 13:57.
Papero is offline
Whai
Senior Member
Join Date: Jul 2018
Old 11-17-2018 , 13:58   Re: Print chat only to the admins
Reply With Quote #25

From this Api Reference about ReplyToCommand Synthax
There is this :
Quote:

ReplyToCommand Function

____________________________________________


Reples to a message in a command.

A client index of 0 will use PrintToServer(). If the command was from the console, PrintToConsole() is used. If the command was from chat, PrintToChat() is used.


Code:
void ReplyToCommand(int client, const char[] format, any... ...)

Parameters

int client
  • Client index, or 0 for server.

const char[] format
  • Formatting rules.

any... ...
  • Variable number of format parameters.

Errors
If the client is not connected or invalid.
or from console.inc :
Quote:
/**
* Reples to a message in a command.
*
* A client index of 0 will use PrintToServer().
* If the command was from the console, PrintToConsole() is used.
* If the command was from chat, PrintToChat() is used.
*
* @param client Client index, or 0 for server.
* @param format Formatting rules.
* @param ... Variable number of format parameters.
* @error If the client is not connected or invalid.
*/

native void ReplyToCommand(int client, const char[] format, any ...);
That means the client (in your case) who issued the command will get this message
__________________

Last edited by Whai; 11-17-2018 at 14:10.
Whai is offline
napster_10
Senior Member
Join Date: May 2016
Old 11-17-2018 , 15:17   Re: Print chat only to the admins
Reply With Quote #26

thx guys problem solved -> actually was not even a problem
napster_10 is offline
foxhound27
AlliedModders Donor
Join Date: Sep 2019
Location: Argentina
Old 03-03-2020 , 16:05   Re: Print chat only to the admins
Reply With Quote #27

PHP Code:
int PrintToAdmins(char[] format) {

    
char buffer[1024];
    
VFormat(buffersizeof(buffer), format2);
    for (
int i 1<= MaxClientsi++) {
        if (
IsClientConnected(i) && IsClientInGame(i)) {
            
int admin GetUserFlagBits(i);
            if (
admin != && admin 1) {

                
PrintToChat(i"\x04[\x03%s\x04]"buffer);
            }
        }
    }

this better
foxhound27 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 06:35.


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