Raised This Month: $ Target: $400
 0% 

Print chat only to the admins


Post New Thread Reply   
 
Thread Tools Display Modes
Marchello
Senior Member
Join Date: Jan 2010
Old 01-26-2010 , 04:47   Re: Print chat only to the admins
Reply With Quote #11

Quote:
Originally Posted by Greyscale View Post
In stock PrintToAdmins, change const String:z[] to const String:flags[]

Marchello is offline
Antithasys
Moderator
Join Date: Apr 2008
Old 01-26-2010 , 04:49   Re: Print chat only to the admins
Reply With Quote #12

That is a warning meaning you do not use the same indent style throughout your plugin. It is ment to give you a heads up and possibly suggest that you did not indent your code properly.

Most of the time it means you did spaces instead of tabs, or vice versa. It can be picky sometimes.
__________________
[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-26-2010 , 05:00   Re: Print chat only to the admins
Reply With Quote #13

well, here's the 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) 
{ 
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", "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:flags[])  
{  
    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); 
    } 
}
what's wrong? I did exact the same y'all told me.
Marchello is offline
Antithasys
Moderator
Join Date: Apr 2008
Old 01-26-2010 , 05:12   Re: Print chat only to the admins
Reply With Quote #14

Nothing may be wrong. The warning could simply be that... a warning. It's entirely possible that you copying and pasting the code into your file created the indent mismatch.

I would goto that line and replace the indentation with a tab and recompile.
__________________
[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-26-2010 , 05:46   Re: Print chat only to the admins
Reply With Quote #15

Well I pressed the tab and it did move to the right, but the error still appeared.
Marchello is offline
Antithasys
Moderator
Join Date: Apr 2008
Old 01-26-2010 , 05:56   Re: Print chat only to the admins
Reply With Quote #16

It's not an error... its a warning. I am betting it will work just fine. Try the line above and below the one mentioned... just tab out your {}'s and code.

If you are using Notepad++ you can goto TextFx->TextFx Edit->Reindent C++ Code to reindent all your code at once.
__________________
[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-26-2010 , 12:14   Re: Print chat only to the admins
Reply With Quote #17

Quote:
Originally Posted by Antithasys View Post
It's not an error... its a warning. I am betting it will work just fine. Try the line above and below the one mentioned... just tab out your {}'s and 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)
{									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:flags[])  
{  
	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); 
	} 
}
Quote:
Originally Posted by Antithasys View Post
If you are using Notepad++ you can goto TextFx->TextFx Edit->Reindent C++ Code to reindent all your code at once.

Marchello is offline
DaFox
Senior Member
Join Date: Mar 2005
Old 01-26-2010 , 19:44   Re: Print chat only to the admins
Reply With Quote #18

The warning lies here: (line 71ish as it says)
PHP Code:
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"); 
I'm sure you can see whats wrong there.
__________________
Quote:
Originally Posted by Peoples Army
your from Finland? what country is that in?
DaFox is offline
Greyscale
SourceMod Plugin Approver
Join Date: Dec 2007
Location: strYoMommasHouse[you];
Old 01-26-2010 , 22:28   Re: Print chat only to the admins
Reply With Quote #19

lmao@page 2
__________________
Greyscale is offline
Marchello
Senior Member
Join Date: Jan 2010
Old 02-03-2010 , 04:28   Re: Print chat only to the admins
Reply With Quote #20

Quote:
Originally Posted by DaFox View Post
The warning lies here: (line 71ish as it says)
PHP Code:
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"); 
I'm sure you can see whats wrong there.
But what's wrong there?

If I just delete the whole line: "PrintToAdmins("Supply is loaded", "z");"
it will be compiled without the error.

UPD:
right now it was compiled without the error! Yay!
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:flags[])  
{  
	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; 02-03-2010 at 05:16.
Marchello 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 17:11.


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