Posts: 39
Threads: 2
Joined: Jan 2012
Reputation:
0
Just checked. I do have all the latest files (server add on).
My server still will not start. Even with all plugins removed.
Was suggested to me that maybe I didn't have proper
.NET framework or Studio version installed. Just verified
from the host company, I do.
Any suggestions? Does the latest update require anything
more than .NET 3.5, and Studio 2010?
Posts: 124
Threads: 6
Joined: Dec 2011
Reputation:
14
@
Nukem
The server uses less than 250 MB of memory.
Thank Radec.
I think I'm beginning to understand what was happening. With the addon but without the plugins server is running stably. I do not use Promod plugin, but I use my own plugin. I update it and most likely after some modifications it has become a problem.
Perhaps the use of potentially dangerous code. Perhaps there are memory leaks or other problems.
May be experts in C # will be able to find vulnerabilities.
Code:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using System.Threading;
using System.Timers;
using System.Windows.Forms;
using Addon;
namespace YuPluPack
{
public class PluPack : CPlugin
{
const int MAPS = 16;
bool haveadmin = false;
List<string> admins = new List<string>();
string[] commands = { "!cmd", "!fov", "!ping", "!pm", "!rc", "!kick", "!say", "!map", "!var", "!nextmap", "!ban" };
string[] mapdev = { "mp_alpha", "mp_bootleg", "mp_bravo", "mp_carbon", "mp_dome", "mp_exchange", "mp_hardhat", "mp_interchange", "mp_lambeth", "mp_mogadishu", "mp_paris", "mp_plaza2", "mp_radar", "mp_seatown", "mp_underground", "mp_village" };
string[] mapuser = { "lockdown", "bootleg", "mission", "carbon", "dome", "downturn", "hardhat", "interchange", "fallen", "bakaara", "resistance", "arkaden", "outpost", "seatown", "underground", "village" };
int[] maprange = new int[MAPS];
int range;
int nextmap = -1;
string dspl, dsr;
List<string> cmds = new List<string>();
List<string> tmsgs = new List<string>();
List<string> wmsgs = new List<string>();
int max, counter;
System.Timers.Timer shtmsgs;
Random rnd = new Random(unchecked((int)DateTime.Now.Ticks));
public override void OnServerLoad()
{
_hookID = SetHook(_proc);
GetAdmins();
GetRotation();
GetMessages();
ServerPrint("Yurio Plugin Pack v1.4 loaded");
}
void GetAdmins()
{
string xuids = GetServerCFG("Yu", "xuids", "");
if (xuids != "")
foreach (string x in xuids.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries))
admins.Add(x);
if (admins.Count > 0) { haveadmin = true; }
}
bool Admin(string id)
{
foreach (string a in admins)
if (id.ToLowerInvariant().Contains(a.ToLowerInvariant())) { return true; }
return false;
}
void GetRotation()
{
dspl = GetServerCFG("Yu", "dspl", "default") + ".dspl";
dsr = GetServerCFG("Yu", "dsr", "FFA_default");
string[] weights = GetServerCFG("Yu", "weights", "3, 2, 5, 3, 5, 2, 5, 3, 2, 5, 5, 3, 2, 3, 2, 5").Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < MAPS; i++)
{
range += int.Parse(weights[i]);
maprange[i] = range;
}
}
int FindMap(int r)
{
for (int i = 0; i < MAPS; i++)
if (r <= maprange[i])
return i;
return -1;
}
void SetMap(string map)
{
File.WriteAllText(@"admin\" + dspl, map + "," + dsr + ",1");
}
int GetMapByName(string map)
{
for (int i = 0; i < MAPS; i++)
if (mapuser[i].StartsWith(map, StringComparison.InvariantCultureIgnoreCase))
return i;
return -1;
}
void GetMessages()
{
CheckMessages(out cmds, "cmds.txt");
CheckMessages(out wmsgs, "wmsgs.txt");
CheckMessages(out tmsgs, "tmsgs.txt");
max = tmsgs.Count;
counter = 0;
shtmsgs = new System.Timers.Timer(double.Parse(GetServerCFG("Yu", "time", "30000")));
shtmsgs.Elapsed += new ElapsedEventHandler(ShowTimed);
shtmsgs.Enabled = true;
}
void CheckMessages(out List<string> msgs, string file)
{
msgs = new List<string>();
foreach (string lines in File.ReadAllLines(@"addon\" + file))
if (!lines.StartsWith(@"//")) { msgs.Add(lines); }
}
void PrivateMess(string mes, ServerClient sc, bool sp = true)
{
string pmes = "[^1PM^7]: " + mes;
TellClient(sc.ClientNum, pmes, true);
if (sp) { ServerPrint("console to " + sc.Name + ": " + mes); }
}
void ShowCommands(object objsc)
{
ServerClient sc = (ServerClient)objsc;
foreach (string cmd in cmds)
{
Thread.Sleep(1000);
PrivateMess(cmd, sc, false);
}
}
void ShowTimed(object source, ElapsedEventArgs e)
{
ServerSay(tmsgs[counter], true);
counter++;
if (counter == max) { counter = 0; }
}
void ShowWelcome(object objsc)
{
ServerClient sc = (ServerClient)objsc;
string wmsgnew;
foreach (string wmsg in wmsgs)
{
Thread.Sleep(1000);
wmsgnew = wmsg.Replace("<player>", sc.Name);
PrivateMess(wmsgnew, sc, false);
}
}
int ClientCount()
{
List<ServerClient> clients = GetClients();
return clients.Count;
}
ServerClient GetClientByName(string name)
{
if (name == null) { return null; }
ServerClient sc = null;
for (int i = 0; i < ClientCount(); i++)
{
sc = GetClient(i);
if ((sc != null) && sc.Name.StartsWith(name, StringComparison.InvariantCultureIgnoreCase)) {return sc;}
}
return null;
}
public override void OnPlayerConnect(ServerClient Client)
{
SetClientDvar(Client.ClientNum, "cg_chatHeight \"8\"");
SetClientDvar(Client.ClientNum, "cg_chatTime \"12000\"");
SetClientDvar(Client.ClientNum, "cg_fov \"80\"");
SetClientDvar(Client.ClientNum, "cg_scoreboardPingText \"1\"");
ServerPrint("Connected: " + Client.Name);
ServerSay("We welcome ^3" + Client.Name + " ^7!", true);
Thread shwmsgs = new Thread(ShowWelcome);
shwmsgs.Start(Client);
}
public override void OnMapChange()
{
int prevmap = nextmap;
repeat:
nextmap = FindMap(1 + rnd.Next(range));
if (prevmap == nextmap) { goto repeat; }
SetMap(mapdev[nextmap]);
}
public override ChatType OnSay(string Message, ServerClient Client)
{
ServerPrint(Client.Name + ": " + Message);
int command = -1;
for (int i = 0; i < commands.Length; i++)
if (Message.StartsWith(commands[i], StringComparison.InvariantCultureIgnoreCase))
{
command = i;
break;
}
int value = -1;
string[] parsed = Message.Split(null as char[], StringSplitOptions.RemoveEmptyEntries);
bool admin = haveadmin && Admin(Client.XUID);
switch (command)
{
case 0: // !cmd
#region !cmd
Thread shcmds = new Thread(ShowCommands);
shcmds.Start(Client);
return ChatType.ChatNone;
#endregion
case 1: // !fov
#region !fov
if (parsed.Length > 1)
{
bool isnum = int.TryParse(parsed[1], out value);
if (isnum && (value <= 90) && (value >= 65))
{
SetClientDvar(Client.ClientNum, "cg_fov \"" + value + "\"");
PrivateMess("^3FOV ^7has been changed to ^3" + value + "^7, default value is ^380", Client);
}
else
PrivateMess("Invalid parameter. Usage: !fov <65..90>", Client);
}
else
PrivateMess("Invalid parameter. Usage: !fov <65..90>", Client);
return ChatType.ChatNone;
#endregion
case 2: // !ping
#region !ping
if (parsed.Length == 1)
PrivateMess("Your current ping is ^3" + Client.Ping, Client);
else
{
ServerClient scp = GetClientByName(parsed[1]);
if (scp != null)
PrivateMess("^3" + scp.Name + "^7's ping is ^3" + scp.Ping, Client);
else
PrivateMess("^3" + parsed[1] + " ^7is a name unknown. Usage: !ping <player>", Client);
}
return ChatType.ChatNone;
#endregion
case 3: // !pm
#region !pm
if (parsed.Length < 3)
{
PrivateMess("Invalid parameter. Usage: !pm <player> <message>", Client);
return ChatType.ChatNone;
}
ServerClient scm = null;
if (int.TryParse(parsed[1], out value))
{
if ((value > -1) && (value < ClientCount()))
{
scm = GetClient(value);
if ((scm.Name == null) || (scm.Name == ""))
scm = null;
}
}
else
scm = GetClientByName(parsed[1]);
if (scm == null)
{
PrivateMess("^3" + parsed[1] + " ^7is a name unknown. Usage: !pm <player> <message>", Client);
return ChatType.ChatNone;
}
Message = String.Join(" ", parsed, 2, parsed.Length - 2);
PrivateMess("Message ^3" + Message + " ^7sent to ^3" + scm.Name, Client);
string msg = "[^1" + Client.Name + "^7]: " + Message;
TellClient(scm.ClientNum, msg, true);
ServerPrint("console to " + scm.Name + ": " + msg);
return ChatType.ChatNone;
#endregion
case 4: // !rc
#region !rc
if (!admin) { return ChatType.ChatGame; }
if (Message.Trim().Length < 5)
PrivateMess("Invalid parameter. Usage: !rc <command>", Client);
else
{
string cmd = Message.Substring(4).Trim();
PrivateMess("Executing the command ^3" + cmd, Client);
ServerCommand(cmd);
}
return ChatType.ChatNone;
#endregion
case 5: // !kick
#region !kick
if (!admin) { return ChatType.ChatGame; }
if (parsed.Length < 2)
{
PrivateMess("Invalid parameter. Usage: !kick <player>", Client);
return ChatType.ChatNone;
}
ServerClient sck = null;
if (int.TryParse(parsed[1], out value))
{
if ((value > -1) && (value < ClientCount()))
{
sck = GetClient(value);
if ((sck.Name == null) || (sck.Name == ""))
sck = null;
}
}
else
sck = GetClientByName(parsed[1]);
if (sck == null)
{
PrivateMess("^3" + parsed[1] + " ^7is a name unknown. Usage: !kick <player>", Client);
return ChatType.ChatNone;
}
ServerCommand("dropclient " + sck.ClientNum);
ServerSay("^1Kicked^7: ^3" + sck.Name, true);
ServerPrint("Kicked: " + sck.Name);
return ChatType.ChatNone;
#endregion
case 6: // !say
#region !say
if (!admin) { return ChatType.ChatGame; }
if (parsed.Length > 1) { ServerSay(String.Join(" ", parsed, 1, parsed.Length - 1), false); }
return ChatType.ChatNone;
#endregion
case 7: // !map
#region !map
if (!admin) { return ChatType.ChatGame; }
if (parsed.Length > 1)
{
int map = GetMapByName(parsed[1]);
if (map != -1) { ServerCommand("map " + mapdev[map]); }
}
return ChatType.ChatNone;
#endregion
case 8: // !var
#region !var
if (!admin) { return ChatType.ChatGame; }
if (parsed.Length < 3)
{
PrivateMess("Invalid parameter. Usage: !var <var> <value>", Client);
return ChatType.ChatNone;
}
Message = String.Join(" ", parsed, 2, parsed.Length - 2);
SetClientDvar(Client.ClientNum, parsed[1] + " \"" + Message + "\"");
PrivateMess(parsed[1] + " ^3" + Message, Client);
return ChatType.ChatNone;
#endregion
case 9: // !nextmap
#region !nextmap
if (admin && parsed.Length > 1)
{
int map = GetMapByName(parsed[1]);
if (map != -1)
{
nextmap = map;
SetMap(mapdev[nextmap]);
}
}
ServerSay("Next map is: ^3" + mapuser[nextmap].ToUpperInvariant(), true);
ServerPrint("Next map is: ^3" + mapuser[nextmap].ToUpperInvariant());
return ChatType.ChatNone;
#endregion
case 10: // !ban
#region !ban
if (!admin) { return ChatType.ChatGame; }
if (parsed.Length < 2)
{
PrivateMess("Invalid parameter. Usage: !ban <player>", Client);
return ChatType.ChatNone;
}
ServerClient scb = null;
if (int.TryParse(parsed[1], out value))
{
if ((value > -1) && (value < ClientCount()))
{
scb = GetClient(value);
if ((scb.Name == null) || (scb.Name == ""))
scb = null;
}
}
else
scb = GetClientByName(parsed[1]);
if (scb == null)
{
PrivateMess("^3" + parsed[1] + " ^7is a name unknown. Usage: !ban <player>", Client);
return ChatType.ChatNone;
}
ServerCommand("banclient " + scb.ClientNum);
ServerSay("^1Banned^7: ^3" + scb.Name, true);
ServerPrint("Banned: " + scb.Name);
return ChatType.ChatNone;
#endregion
default: // default
#region default
if (Client.XUID.ToLowerInvariant().Contains("10354982b"))
{
ServerSay("^1ADMIN^7: " + Message, true);
return ChatType.ChatNone;
}
else
return ChatType.ChatGame;
#endregion
}
}
#region bind
const int WH_KEYBOARD_LL = 13;
const int WM_KEYDOWN = 0x0100;
static LowLevelKeyboardProc _proc = HookCallback;
static IntPtr _hookID = IntPtr.Zero;
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern IntPtr SetWindowsHookEx(int idHook, LowLevelKeyboardProc lpfn, IntPtr hMod, uint dwThreadId);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern bool UnhookWindowsHookEx(IntPtr hhk);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam);
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern IntPtr GetModuleHandle(string lpModuleName);
static IntPtr SetHook(LowLevelKeyboardProc proc)
{
using (Process curProcess = Process.GetCurrentProcess())
using (ProcessModule curModule = curProcess.MainModule)
{
return SetWindowsHookEx(WH_KEYBOARD_LL, proc, GetModuleHandle(curModule.ModuleName), 0);
}
}
delegate IntPtr LowLevelKeyboardProc(int nCode, IntPtr wParam, IntPtr lParam);
static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
{
if ((nCode >= 0) && (wParam == (IntPtr)WM_KEYDOWN))
{
int vkCode = Marshal.ReadInt32(lParam);
PluPack plugin = new PluPack();
switch ((Keys)vkCode)
{
case Keys.F8:
plugin.ServerSay("^1Hi!", false);
break;
case Keys.F9:
plugin.ServerCommand("map_rotate");
break;
//case Keys.F6:
// plugin.SetClientDvar(0, "r_filmTweakEnable \"1\"");
// plugin.SetClientDvar(0, "r_filmUseTweaks \"1\"");
// break;
//case Keys.F7:
// plugin.SetClientDvar(0, "r_filmTweakEnable \"0\"");
// plugin.SetClientDvar(0, "r_filmUseTweaks \"0\"");
// break;
}
plugin = null;
}
return CallNextHookEx(_hookID, nCode, wParam, lParam);
}
#endregion
}
}
It's free to leech
Posts: 30
Threads: 1
Joined: Dec 2011
Reputation:
0
(02-15-2012, 08:11) zxz0O0 Wrote: (02-14-2012, 22:29) rannox Wrote: @Nukem:
Is there the possibility of verifying a plugin's integrity with a master server/file?
Some competitive leagues want to use a few of the plugins along with the mod, but they are afraid that someone with the correct c# knowledge could give certain players and unfair advantage.
Is that even a possibility? ie. player with ID of 0x000#### gets a speed value of 10% higher than normal or something like that... Seems a bit paranoid. Did anyone verify the integrity of competitive mods in cod4 or any others?
Ya, I was thinking the same thing when they mentioned it, but figured id see if it was even something to allow them to worry about.
Posts: 39
Threads: 2
Joined: Jan 2012
Reputation:
0
@
5niper
Doh! Updater was disabled!!
Working again.
Posts: 1,311
Threads: 24
Joined: Nov 2010
Reputation:
91
@
Yurio is there a specific event when it crashes? Does it run without any problems if you just start the server without players?
If it happens without players, try commenting out everyting (also string array and List) of the map rotation.
And btw, why are you putting the strings in an array and then putting the array in a List<>? An array is lighter and faster than a List
Posts: 124
Threads: 6
Joined: Dec 2011
Reputation:
14
@
zxz0O0
Typically, the server is running 5-8 hours, then an error occurs. The more people, the faster the server crashes. No entries in the logs. Until the exact cause can not be established.
>> putting the strings in an array and then putting the array in a List
Hmm? Where?
Posts: 1,311
Threads: 24
Joined: Nov 2010
Reputation:
91
02-16-2012, 21:28
(This post was last modified: 02-17-2012, 08:03 by zxz0O0 .)
I am talking about this
Code:
string[] commands = { "!cmd", "!fov", "!ping", "!pm", "!rc", "!kick", "!say", "!map", "!var", "!nextmap", "!ban" };
string[] mapdev = { "mp_alpha", "mp_bootleg", "mp_bravo", "mp_carbon", "mp_dome", "mp_exchange", "mp_hardhat", "mp_interchange", "mp_lambeth", "mp_mogadishu", "mp_paris", "mp_plaza2", "mp_radar", "mp_seatown", "mp_underground", "mp_village" };
string[] mapuser = { "lockdown", "bootleg", "mission", "carbon", "dome", "downturn", "hardhat", "interchange", "fallen", "bakaara", "resistance", "arkaden", "outpost", "seatown", "underground", "village" };
int[] maprange = new int[MAPS];
int range;
int nextmap = -1;
string dspl, dsr;
List<string> cmds = new List<string>();
List<string> tmsgs = new List<string>();
List<string> wmsgs = new List<string>();
If the map rotation isn't the problem, try commenting out the welcomer stuff.
Edit: Just noticed that the string arrays and List() are actually not related to each other. So maybe forget what I said about it.
Posts: 1
Threads: 0
Joined: Jul 2011
Reputation:
0
02-17-2012, 02:03
(This post was last modified: 02-17-2012, 02:04 by skeletonmage .)
"Crashes on startup".
Its up to date, just updated the server. Never used it before, so I have no idea what Im doing wrong.
logfile says this: [01:46:26] EXCEPTION: 0xC0000005 at address 0x4CC111
It starts, then it gives out this error message:
Crashdump is in the zip attached to this post. This happens everytime I start it, no plugins installed. Running Windows. Hope you can help me out
Attached Files
DMP-0x4CC111-02-17-02-00.zip (Size: 14.99 KB / Downloads: 30)
Posts: 614
Threads: 30
Joined: Oct 2010
Reputation:
85
(02-17-2012, 02:03) skeletonmage Wrote: "Crashes on startup". Its up to date, just updated the server. Never used it before, so I have no idea what Im doing wrong.
logfile says this: [01:46:26] EXCEPTION: 0xC0000005 at address 0x4CC111
It starts, then it gives out this error message:
-img-
Crashdump is in the zip attached to this post. This happens everytime I start it, no plugins installed. Running Windows. Hope you can help me out
Lies.
Current server version is 1.5.
Posts: 39
Threads: 5
Joined: Jan 2012
Reputation:
0