Senior Member
|
01-26-2010
, 02:46
Re: Print chat only to the admins
|
#8
|
Greyscale, thx.
Quote:
Originally Posted by Greyscale
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.
|
|