Raised This Month: $51 Target: $400
 12% 

stock print


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Sanjay Singh
Veteran Member
Join Date: Sep 2016
Old 01-08-2020 , 07:58   stock print
Reply With Quote #1

I am trying to print a specific message to all admins only.
so is this possible to use like without using full colorchat stock becuz 1.9.0 already includes colorchat
client_print_color

PHP Code:
print_admin(00"Hi %s You're Admin"name)

stock print_admin(id, const msg[])
{
    new 
iPlayers[32], iPnumiPlayer
    get_players
(iPlayersiPnum)

    for(new 
0iPnumi++)
    {
        
iPlayer iPlayers[i]
        
        if(
get_user_flags(iPlayer) & ADMIN_CHAT)
            
client_print_color(iPlayer0msg)
    } 

__________________
Sanjay Singh is offline
Send a message via AIM to Sanjay Singh
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 01-08-2020 , 10:00   Re: stock print
Reply With Quote #2

1. You defined the function with 2 arguments, but you're using 4.

2. Why do you need an "id" parameter in the function if it's going to send the message to a group of players?

3. You're missing "vformat".

4. You probably don't need the "stock" tag.
__________________

Last edited by OciXCrom; 01-08-2020 at 10:00.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Sanjay Singh
Veteran Member
Join Date: Sep 2016
Old 01-08-2020 , 10:36   Re: stock print
Reply With Quote #3

Quote:
Originally Posted by OciXCrom View Post
1. You defined the function with 2 arguments, but you're using 4.

2. Why do you need an "id" parameter in the function if it's going to send the message to a group of players?

3. You're missing "vformat".

4. You probably don't need the "stock" tag.
like this?
PHP Code:
print_admin(const id, const input[], any:...)
{
    new 
count 1players[32];
    static 
msg[191];
    
vformat(msg190input3);
    
    if(
id)
        
players[0] = id;
    else
        
get_players(playerscount"ch");
    
    for (new 
0counti++)
    {
        
players[i]
        if(
is_user_admin(x))
        
client_print_color(x0msg)
    }

__________________

Last edited by Sanjay Singh; 01-08-2020 at 10:41.
Sanjay Singh is offline
Send a message via AIM to Sanjay Singh
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 01-09-2020 , 08:32   Re: stock print
Reply With Quote #4

You can try this:
PHP Code:
    stock print_admin(const id, const input[], any:...)
    {
        new 
count 1players[32]
        static 
msg[191]
        
vformat(msg190input3)
        
        
replace_all(msg190"!g""^4"// Green Color
        
replace_all(msg190"!y""^1"// Default Color
        
replace_all(msg190"!team""^3"// Team Color
        
replace_all(msg190"!team2""^0"// Team2 Color
        
        
if (idplayers[0] = id; else get_players(playerscount"ch")
        {
            for (new 
0counti++)
            {
                if (
is_user_connected(players[i]))
                {
                    
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("SayText"), _players[i])
                    
write_byte(players[i]);
                    
write_string(msg);
                    
message_end();
                }
            }
        }
    } 
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]
Shadows Adi is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 01-09-2020 , 13:35   Re: stock print
Reply With Quote #5

@Shadows Adi - read the first post again.

PHP Code:
// You don't need an "id" parameter - you're sending the message to a GROUP of players.
print_admin(const id, const input[], any:...)
{
    
// Why is count = 1?
    
new count 1players[32];
    static 
msg[191];

    
// Use charsmax(msg) instead of 190.
    
vformat(msg190input3);
    
    
// Again not needed - only get_players() should stay.
    
if(id)
        
players[0] = id;
    else
        
get_players(playerscount"ch");
    
    for (new 
0counti++)
    {
        
players[i]

        
// Indentation or { brackets } after the check would be nice.
        
if(is_user_admin(x))
        
        
// Don't use "magic numbers". The second argument should be "print_team_default", not 0.
        
client_print_color(x0msg)
    }

Try to think what you're doing. If you went line by line through the code, you probably could have figured it out.
You simply need to send a message to all admins, so there's no "id" involved at all - the player sending the message (if existant) is not relevant.
__________________

Last edited by OciXCrom; 01-09-2020 at 13:38.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Natsheh
Veteran Member
Join Date: Sep 2012
Old 01-09-2020 , 13:51   Re: stock print
Reply With Quote #6

Well he actually needs the parameter id? Don't he?
Let's call it instead sender.
PHP Code:
print_to_admins(const id, const input[], any:...)
{
    
// Why is count = 1?
    
new countplayers[32], szName[32];
    static 
msg[192];

    
// Use charsmax(msg) instead of 190.
    
vformat(msg191input3);
    
    
// Again not needed - only get_players() should stay.
    
get_players(playerscount"ch");
    
get_user_name(idszName31);
    
    for (new 
0counti++)
    {
        
players[i]

        
// Indentation or { brackets } after the check would be nice.
        
if(is_user_admin(x))
        
        
// Don't use "magic numbers". The second argument should be "print_team_default", not 0.
        
client_print_color(x0"(ADMINS) %s: %s"szNamemsg)
    }

Assuming thats why he needs the parameter id.

Also follow the guidance to get fully code optimization.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 01-09-2020 , 14:06   Re: stock print
Reply With Quote #7

He never mentioned that he wants to use the sender's name anywhere, so I'm working with the information he provided.
__________________

Last edited by OciXCrom; 01-09-2020 at 14:07.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Sanjay Singh
Veteran Member
Join Date: Sep 2016
Old 01-09-2020 , 16:04   Re: stock print
Reply With Quote #8

I dont want to show sender, it should work like normal msg to all who have accsss flags.
__________________
Sanjay Singh is offline
Send a message via AIM to Sanjay Singh
Natsheh
Veteran Member
Join Date: Sep 2012
Old 01-10-2020 , 04:38   Re: stock print
Reply With Quote #9

Well your example here is wrong

"Hi %s You're Admin"

It clarify that you only need 1 receiver
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Sanjay Singh
Veteran Member
Join Date: Sep 2016
Old 01-10-2020 , 06:37   Re: stock print
Reply With Quote #10

Quote:
Originally Posted by Natsheh View Post
Well your example here is wrong

"Hi %s You're Admin"

It clarify that you only need 1 receiver
Actually I want it to be work like both types if possible.

like if am using like this
PHP Code:
print_color(0"ADMIN type /help for commands")
this will print to all admins 
But what if i want to add their names to in that
PHP Code:
print_color(0"ADMIN %s type /help for commands"adminname
I don't want to show the sender but I want the receiver name in the chat.
__________________

Last edited by Sanjay Singh; 01-10-2020 at 06:40.
Sanjay Singh is offline
Send a message via AIM to Sanjay Singh
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 15:01.


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