Пример #1
0
	e_command_result sv_admin_add(void*, commands::CArgParser& args, COutStream& out)
	{
		std::string hash = args.ReadPlayerOrHash();
		std::string name = args.ReadString();
		int level = args.ReadInt();

		result_t result = add(hash, name, level);
		switch (result)
		{
		case E_HASH_INUSE:
			{
				out << L"That hash is already in use." << endl;
			} break;
		case E_NAME_INUSE:
			{
				out << L"That name is already in use." << endl;
			} break;
		case E_LEVEL_NOT_EXIST:
			{
				out << level << L" is not a valid access level." << endl;
			} break;
		default:
			{
				if (!SaveAdminList(out)) {
					out << name << " will be an admin until the server restarts, because the file wasn't saved." << endl;
				} else {
					out << name << " can now use admin at level " << level << endl;
					MarkPlayerAdmin(hash, true);
				}
			} break;
		}
		return e_command_result::kProcessed;
	}
Пример #2
0
	e_command_result sv_script_load(void*, 
		commands::CArgParser& args, COutStream& out)
	{
		std::string script = args.ReadString();
		bool persistent = false;
		if (args.size() == 2) persistent = args.ReadBool();
		
		if (g_Scripts->OpenScript(script.c_str(), persistent))
			out << script << " has been loaded." << endl;
		else
			out << script << " couldn't be loaded." << endl;
		return e_command_result::kProcessed;
	}
Пример #3
0
	e_command_result sv_script_reload(void*, 
		commands::CArgParser& args, COutStream& out)
	{
		if (args.size() == 1) {
			std::string script = args.ReadString();

			if (g_Scripts->ReloadScript(script))
				out << script << " has been reloaded." << endl;
			else
				out << script << " isn't currently loaded." << endl;
		} else {
			g_Scripts->ReloadScripts(true);
			out << "All scripts have been reloaded." << endl;
		}
		return e_command_result::kProcessed;
	}
Пример #4
0
	e_command_result sv_public(void*, commands::CArgParser& args, COutStream& out)
	{
		// sv_public only actually works before the server starts, but meh
		bool enable = args.ReadBool();
		if (!enable) challenge_admins = false;
		return e_command_result::kGiveToHalo;
	}
Пример #5
0
	e_command_result sv_mapvote_add(void*, 
		commands::CArgParser& args, COutStream& out)
	{
		s_mapvote_entry entry;
		entry.game_info.map = args.ReadString();
		entry.game_info.gametype = args.ReadWideString();
		entry.desc = args.ReadString();

		for (size_t x = 3; x < args.size(); x++)
			entry.game_info.scripts.push_back(args.ReadString());
		
		if (!maploader::ValidateUserInput(entry.game_info, out))
			return e_command_result::kProcessed;
		
		mapvote_list.push_back(entry);
		return e_command_result::kProcessed;
	}
Пример #6
0
	e_command_result sv_mapvote_del(void*, 
		commands::CArgParser& args, COutStream& out)
	{
		size_t index = args.ReadUInt(1, mapvote_list.size());
		mapvote_list.erase(mapvote_list.begin() + index-1);
		if (!mapvote_list.size()) {
			out << "No more votable maps. Map voting disabled." << endl;
			mapvote_enabled = false;
		}
		return e_command_result::kProcessed;
	}
Пример #7
0
	e_command_result sv_mapvote_size(void*,
		commands::CArgParser& args, COutStream& out)
	{
		if (mapvote_in_progress)
			out << "You must wait until the current vote has finished." << endl;
		else {
			mapvote_option_count = args.ReadUInt(2);
			out << "Only " << (int)mapvote_option_count << " options will be displayed." << endl;
		}
		return e_command_result::kProcessed;
	}
Пример #8
0
	e_command_result sv_mapvote(void*, 
		commands::CArgParser& args, COutStream& out)
	{
		bool enable = args.ReadBool();
		if (enable && !mapvote_list.size()) {
			out << "You need to add some options before enabling, see sv_mapvote_add." << endl;
			return e_command_result::kProcessed;
		}
		mapvote_enabled = enable;
		out << "Map voting has been " << (mapvote_enabled ? "enabled" : "disabled")
			<< endl;
		return e_command_result::kProcessed;
	}
Пример #9
0
	e_command_result sv_kickafk(void*, 
		commands::CArgParser& args, COutStream& out)
	{
		CAFKDetection::max_duration = args.ReadUInt();

		if (CAFKDetection::max_duration)
			out << "Inactive players will be kicked after " << 
			CAFKDetection::max_duration << " minutes(s)" << endl;
		else
			out << "Inactive players will no longer be kicked." << endl;

		return e_command_result::kProcessed;
	}
Пример #10
0
	e_command_result sv_admin_del(void*, commands::CArgParser& args, COutStream& out)
	{
		std::string name = args.ReadString();
		admin::s_admin* admin;
		
		if (admin::find_admin_by_name(name, &admin)) {
			std::string hash = admin->hash;
			admin::remove(hash);
			if (!SaveAdminList(out)) {
				out << name << " will still be an until once the server restarts because the file wasn't saved." << endl;
			} else {
				out << name << " is no longer an admin. " << endl;
				MarkPlayerAdmin(hash, false);
			}
		} else out << name << " isn't an admin." << endl;

		return e_command_result::kProcessed;
	}
Пример #11
0
	e_command_result sv_script_unload(void*, 
		commands::CArgParser& args, COutStream& out)
	{
		g_Scripts->CloseScript(args.ReadString().c_str());
		return e_command_result::kProcessed;
	}
Пример #12
0
	e_command_result sv_admin_check(void*, commands::CArgParser& args, COutStream& out)
	{
		challenge_admins = args.ReadBool();
		out << "admin challenging is " << (challenge_admins ? "enabled" : "disabled") << endl;
		return e_command_result::kProcessed;
	}