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

Print chat only to the admins


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Marchello
Senior Member
Join Date: Jan 2010
Old 01-23-2010 , 16:58   Print chat only to the admins
Reply With Quote #1

here's a plugin where in the end of it is a command:
Code:
PrintToChatAll("\x01[sonnzy]\x03Supply is loaded");
Since, the author doesn't respond I decided to take the lead on myself.
So, I just need to edit this one sentence, but what commands are responsible for printing a message for a specific flag (so only the admins with this flag will see it)?

Already looked up here.

Last edited by Marchello; 02-03-2010 at 05:07.
Marchello is offline
Antithasys
Moderator
Join Date: Apr 2008
Old 01-23-2010 , 17:03   Re: Print chat only to the admins
Reply With Quote #2

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.
__________________
[my plugins]

When you think about asking a question... consider what have you tried?
Antithasys is offline
Marchello
Senior Member
Join Date: Jan 2010
Old 01-24-2010 , 08:36   Re: Print chat only to the admins
Reply With Quote #3

Antithasys, did like this:
(the whole code)
Code:
#include <sourcemod>
#include <sdktools>
#define PLUGIN_VERSION "0.9.1"

public Plugin:myinfo = 
{
	name = "multiplayer",
	author = "sonnzy",
	description = "Allow more than 4 players to join COOP game",
	version = PLUGIN_VERSION,
	url = ""
};

new Handle:surv_l;
new Handle:z_l ;

public OnPluginStart()
{
	surv_l = FindConVar("survivor_limit");
	z_l = FindConVar("z_max_player_zombies");
	RegConsoleCmd("sm_joingame",AddPlayer, "Attempt to join Survivors");
	//RegConsoleCmd("sm_addbot",CreateOneBot, "Create one bot to take over");
	//RegConsoleCmd("sm_launcher",launcher);
	//RegConsoleCmd("sm_machete",machete);
	CreateConVar("multiplayer_version", PLUGIN_VERSION,"version",FCVAR_PLUGIN);

	HookEvent("round_start", Event_RoundStart);
	HookEvent("round_start", Event_RoundStart);
}

public Action:Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
	SetConVarBounds(surv_l , ConVarBound_Upper, true, 20.0);
	SetConVarBounds(z_l , ConVarBound_Upper, true, 20.0);
	
	//ServerCommand("exec server");
	CreateTimer(3.0, UpdateCounts, 0);
}

public bool:OnClientConnect(client, String:rejectmsg[], maxlen)   
{
	if(GetClientCount(true) < GetConVarInt(surv_l)) ServerCommand("sb_add");
	return true;
}

public OnMapEnd()
{
	for(new i = 1; i <= MaxClients; ++i)
	{
		if(IsClientInGame(i))
			if(IsFakeClient(i) && !IsClientInKickQueue(i)){
				KickClient(i);
			}
	}
}

public Action:AddPlayer(client, args)
{
	LogAction(0, -1, "DEBUG:addplayer");
	if(IsClientInGame(client))
	{ 
		FakeClientCommand(client, "jointeam 2");
	}
	return Plugin_Handled;
}

public Action:UpdateCounts(Handle:timer)
{

	stock PrintToAdmins(const String:supply is loaded[], const String:z[]) 
{ 
    for (new x = 1; x <= MaxClients; x++) 
    { 
        if (IsValidClient(x) && IsValidAdmin(x, flags)) 
        { 
            PrintToChat(x, message); 
        } 
    } 
} 

stock bool:IsValidClient(client, bool:nobots = true) 
{  
    if (client <= 0 || 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; 
}
	
	// update fixed item spawn counts to handle 8 players
	// These only update item spawns found in starting area/saferooms
	UpdateEntCount("weapon_autoshotgun_spawn","17");
	UpdateEntCount("weapon_hunting_rifle_spawn","17");
	UpdateEntCount("weapon_pistol_spawn","17");
	UpdateEntCount("weapon_pistol_magnum_spawn","17");
	UpdateEntCount("weapon_pumpshotgun_spawn","17");
	UpdateEntCount("weapon_rifle_spawn","17");
	UpdateEntCount("weapon_rifle_ak47_spawn","17");
	UpdateEntCount("weapon_rifle_desert_spawn","17");
	UpdateEntCount("weapon_rifle_sg552_spawn","17");
	UpdateEntCount("weapon_shotgun_chrome_spawn","17");
	UpdateEntCount("weapon_shotgun_spas_spawn","17");
	UpdateEntCount("weapon_smg_spawn","17");
	UpdateEntCount("weapon_smg_mp5_spawn","17");
	UpdateEntCount("weapon_smg_silenced_spawn","17");
	UpdateEntCount("weapon_sniper_awp_spawn","17");
	UpdateEntCount("weapon_sniper_military_spawn","17");
	UpdateEntCount("weapon_sniper_scout_spawn","17");
	UpdateEntCount("weapon_grenade_launcher_spawn", "17");

	UpdateEntCount("weapon_chainsaw_spawn", "4");
	UpdateEntCount("weapon_defibrillator_spawn", "1"); //


	
	// pistol spawns come in two flavors stacks of 5, or multiple singles props
	UpdateEntCount("weapon_pistol_spawn", "16"); // defaults 1/4/5
	
	// StripAndChangeServerConVarInt("director_pain_pill_density", 12);  // default 6
	return Plugin_Handled;
}

public UpdateEntCount(const String:entname[], const String:count[])
{
	// LogAction(0, -1, "DEBUG:updateentcount 段落");
	new edict_index = FindEntityByClassname(-1, entname);
	
	while(edict_index != -1)
	{
		DispatchKeyValue(edict_index, "count", count);
		edict_index = FindEntityByClassname(edict_index, entname);
	}
}
(just replaced the line: PrintToChatAll("\x01[sonnzy]\x03Supply is loaded"); with your code)
What's wrong? I got this error:


Also I get this error on every plugin if I just open it with the notepad and press "ctrl + s"


But I don't get this error if I open with the wordpad.

Last edited by Marchello; 01-25-2010 at 10:30.
Marchello is offline
Antithasys
Moderator
Join Date: Apr 2008
Old 01-24-2010 , 14:45   Re: Print chat only to the admins
Reply With Quote #4

Well you just pasted that code in the middle of your timer callback and changed one of the params to a spaced variable. Of course it wont work. You dont even call the function from your code or anything.

I have no idea what you are doing... but I will at least paste the code into yours correctly.

Here:
PHP Code:
#include <sourcemod>
#include <sdktools>
#define PLUGIN_VERSION "0.9.1"

public Plugin:myinfo 
{
    
name "multiplayer",
    
author "sonnzy",
    
description "Allow more than 4 players to join COOP game",
    
version PLUGIN_VERSION,
    
url ""
};

new 
Handle:surv_l;
new 
Handle:z_l ;

public 
OnPluginStart()
{
    
surv_l FindConVar("survivor_limit");
    
z_l FindConVar("z_max_player_zombies");
    
RegConsoleCmd("sm_joingame",AddPlayer"Attempt to join Survivors");
    
//RegConsoleCmd("sm_addbot",CreateOneBot, "Create one bot to take over");
    //RegConsoleCmd("sm_launcher",launcher);
    //RegConsoleCmd("sm_machete",machete);
    
CreateConVar("multiplayer_version"PLUGIN_VERSION,"version",FCVAR_PLUGIN);

    
HookEvent("round_start"Event_RoundStart);
    
HookEvent("round_start"Event_RoundStart);
}

public 
Action:Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    
SetConVarBounds(surv_l ConVarBound_Uppertrue20.0);
    
SetConVarBounds(z_l ConVarBound_Uppertrue20.0);
    
    
//ServerCommand("exec server");
    
CreateTimer(3.0UpdateCounts0);
}

public 
bool:OnClientConnect(clientString:rejectmsg[], maxlen)   
{
    if(
GetClientCount(true) < GetConVarInt(surv_l)) ServerCommand("sb_add");
    return 
true;
}

public 
OnMapEnd()
{
    for(new 
1<= MaxClients; ++i)
    {
        if(
IsClientInGame(i))
        if(
IsFakeClient(i) && !IsClientInKickQueue(i)){
            
KickClient(i);
        }
    }
}

public 
Action:AddPlayer(clientargs)
{
    
LogAction(0, -1"DEBUG:addplayer");
    if(
IsClientInGame(client))
    { 
        
FakeClientCommand(client"jointeam 2");
    }
    return 
Plugin_Handled;
}

public 
Action:UpdateCounts(Handle:timer)
{
    
    
// update fixed item spawn counts to handle 8 players
    // These only update item spawns found in starting area/saferooms
    
UpdateEntCount("weapon_autoshotgun_spawn","17");
    
UpdateEntCount("weapon_hunting_rifle_spawn","17");
    
UpdateEntCount("weapon_pistol_spawn","17");
    
UpdateEntCount("weapon_pistol_magnum_spawn","17");
    
UpdateEntCount("weapon_pumpshotgun_spawn","17");
    
UpdateEntCount("weapon_rifle_spawn","17");
    
UpdateEntCount("weapon_rifle_ak47_spawn","17");
    
UpdateEntCount("weapon_rifle_desert_spawn","17");
    
UpdateEntCount("weapon_rifle_sg552_spawn","17");
    
UpdateEntCount("weapon_shotgun_chrome_spawn","17");
    
UpdateEntCount("weapon_shotgun_spas_spawn","17");
    
UpdateEntCount("weapon_smg_spawn","17");
    
UpdateEntCount("weapon_smg_mp5_spawn","17");
    
UpdateEntCount("weapon_smg_silenced_spawn","17");
    
UpdateEntCount("weapon_sniper_awp_spawn","17");
    
UpdateEntCount("weapon_sniper_military_spawn","17");
    
UpdateEntCount("weapon_sniper_scout_spawn","17");
    
UpdateEntCount("weapon_grenade_launcher_spawn""17");

    
UpdateEntCount("weapon_chainsaw_spawn""4");
    
UpdateEntCount("weapon_defibrillator_spawn""1"); //


    
    // pistol spawns come in two flavors stacks of 5, or multiple singles props
    
UpdateEntCount("weapon_pistol_spawn""16"); // defaults 1/4/5
    
    // StripAndChangeServerConVarInt("director_pain_pill_density", 12);  // default 6
    
return Plugin_Handled;
}

stock PrintToAdmins(const String:message[], const String:z[]) 

    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
}

public 
UpdateEntCount(const String:entname[], const String:count[])
{
    
// LogAction(0, -1, "DEBUG:updateentcount ??");
    
new edict_index FindEntityByClassname(-1entname);
    
    while(
edict_index != -1)
    {
        
DispatchKeyValue(edict_index"count"count);
        
edict_index FindEntityByClassname(edict_indexentname);
    }

__________________
[my plugins]

When you think about asking a question... consider what have you tried?
Antithasys is offline
Marchello
Senior Member
Join Date: Jan 2010
Old 01-25-2010 , 10:30   Re: Print chat only to the admins
Reply With Quote #5

Hm.. I'm an admin with "z" flag and nothing was messaged to me, anyway, thx a lot.
Marchello is offline
icequeenzz
Member
Join Date: May 2008
Old 01-25-2010 , 12:57   Re: Print chat only to the admins
Reply With Quote #6

Quote:
Originally Posted by Marchello View Post
Hm.. I'm an admin with "z" flag and nothing was messaged to me, anyway, thx a lot.
ofcourse not, you need to add PrintToAdmins(<message etc>)
somewhere where you want to place it (where it must be executed)
__________________

icequeenzz is offline
Greyscale
SourceMod Plugin Approver
Join Date: Dec 2007
Location: strYoMommasHouse[you];
Old 01-25-2010 , 15:05   Re: Print chat only to the admins
Reply With Quote #7

lol, go easy on him, hes not a coder hes just trying to do what the author of the plugin isn't around to do.


PHP Code:
PrintToAdmins("Supply is loaded""z"); 
Copy this line of code above right AFTER this in antithasys's code:

PHP Code:
public Action:UpdateCounts(Handle:timer

__________________
Greyscale is offline
Marchello
Senior Member
Join Date: Jan 2010
Old 01-26-2010 , 02:46   Re: Print chat only to the admins
Reply With Quote #8

Greyscale, thx.
Quote:
Originally Posted by Greyscale View Post
lol, go easy on him, hes not a coder hes just trying to do what the author of the plugin isn't around to do.
Well, I at least have basic knowledge of Pascal...


oh no, I got this

Code:
#include <sourcemod> 
#include <sdktools> 
#define PLUGIN_VERSION "0.9.1" 

public Plugin:myinfo =  
{ 
    name = "multiplayer", 
    author = "sonnzy", 
    description = "Allow more than 4 players to join COOP game", 
    version = PLUGIN_VERSION, 
    url = "" 
}; 

new Handle:surv_l; 
new Handle:z_l ; 

public OnPluginStart() 
{ 
    surv_l = FindConVar("survivor_limit"); 
    z_l = FindConVar("z_max_player_zombies"); 
    RegConsoleCmd("sm_joingame",AddPlayer, "Attempt to join Survivors"); 
    //RegConsoleCmd("sm_addbot",CreateOneBot, "Create one bot to take over"); 
    //RegConsoleCmd("sm_launcher",launcher); 
    //RegConsoleCmd("sm_machete",machete); 
    CreateConVar("multiplayer_version", PLUGIN_VERSION,"version",FCVAR_PLUGIN); 

    HookEvent("round_start", Event_RoundStart); 
    HookEvent("round_start", Event_RoundStart); 
} 

public Action:Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast) 
{ 
    SetConVarBounds(surv_l , ConVarBound_Upper, true, 20.0); 
    SetConVarBounds(z_l , ConVarBound_Upper, true, 20.0); 
     
    //ServerCommand("exec server"); 
    CreateTimer(3.0, UpdateCounts, 0); 
} 

public bool:OnClientConnect(client, String:rejectmsg[], maxlen)    
{ 
    if(GetClientCount(true) < GetConVarInt(surv_l)) ServerCommand("sb_add"); 
    return true; 
} 

public OnMapEnd() 
{ 
    for(new i = 1; i <= MaxClients; ++i) 
    { 
        if(IsClientInGame(i)) 
        if(IsFakeClient(i) && !IsClientInKickQueue(i)){ 
            KickClient(i); 
        } 
    } 
} 

public Action:AddPlayer(client, args) 
{ 
    LogAction(0, -1, "DEBUG:addplayer"); 
    if(IsClientInGame(client)) 
    {  
        FakeClientCommand(client, "jointeam 2"); 
    } 
    return Plugin_Handled; 
} 

public Action:UpdateCounts(Handle:timer) 
{ 
     PrintToAdmins("Supply is loaded", "z");
    // update fixed item spawn counts to handle 8 players 
    // These only update item spawns found in starting area/saferooms 
    UpdateEntCount("weapon_autoshotgun_spawn","17"); 
    UpdateEntCount("weapon_hunting_rifle_spawn","17"); 
    UpdateEntCount("weapon_pistol_spawn","17"); 
    UpdateEntCount("weapon_pistol_magnum_spawn","17"); 
    UpdateEntCount("weapon_pumpshotgun_spawn","17"); 
    UpdateEntCount("weapon_rifle_spawn","17"); 
    UpdateEntCount("weapon_rifle_ak47_spawn","17"); 
    UpdateEntCount("weapon_rifle_desert_spawn","17"); 
    UpdateEntCount("weapon_rifle_sg552_spawn","17"); 
    UpdateEntCount("weapon_shotgun_chrome_spawn","17"); 
    UpdateEntCount("weapon_shotgun_spas_spawn","17"); 
    UpdateEntCount("weapon_smg_spawn","17"); 
    UpdateEntCount("weapon_smg_mp5_spawn","17"); 
    UpdateEntCount("weapon_smg_silenced_spawn","17"); 
    UpdateEntCount("weapon_sniper_awp_spawn","17"); 
    UpdateEntCount("weapon_sniper_military_spawn","17"); 
    UpdateEntCount("weapon_sniper_scout_spawn","17"); 
    UpdateEntCount("weapon_grenade_launcher_spawn", "17"); 

    UpdateEntCount("weapon_chainsaw_spawn", "1"); 
    UpdateEntCount("weapon_defibrillator_spawn", "1"); // 


     
    // pistol spawns come in two flavors stacks of 5, or multiple singles props 
    UpdateEntCount("weapon_pistol_spawn", "16"); // defaults 1/4/5 
     
    // StripAndChangeServerConVarInt("director_pain_pill_density", 12);  // default 6 
    return Plugin_Handled; 
} 

stock PrintToAdmins(const String:message[], const String:z[])  
{  
    for (new x = 1; x <= MaxClients; x++)  
    {  
        if (IsValidClient(x) && IsValidAdmin(x, flags))  
        {  
            PrintToChat(x, message);  
        }  
    }  
}  

stock bool:IsValidClient(client, bool:nobots = true)  
{   
    if (client <= 0 || 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;  
} 

public UpdateEntCount(const String:entname[], const String:count[]) 
{ 
    // LogAction(0, -1, "DEBUG:updateentcount ??"); 
    new edict_index = FindEntityByClassname(-1, entname); 
     
    while(edict_index != -1) 
    { 
        DispatchKeyValue(edict_index, "count", count); 
        edict_index = FindEntityByClassname(edict_index, entname); 
    } 
}

Last edited by Marchello; 01-26-2010 at 02:50.
Marchello is offline
Greyscale
SourceMod Plugin Approver
Join Date: Dec 2007
Location: strYoMommasHouse[you];
Old 01-26-2010 , 03:01   Re: Print chat only to the admins
Reply With Quote #9

In stock PrintToAdmins, change const String:z[] to const String:flags[]
__________________
Greyscale is offline
Antithasys
Moderator
Join Date: Apr 2008
Old 01-26-2010 , 03:28   Re: Print chat only to the admins
Reply With Quote #10

I am only trying to be constructive when I say...

These are very basic things in programming. Function declarations and variable initializations could be argued are the foundation of any programming language. These are things that are constants throughout.

I would suggest you take some time to learn the very basics in programming as it could only help you.
__________________
[my plugins]

When you think about asking a question... consider what have you tried?
Antithasys 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 16:30.


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