Esempio n. 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;
	}
Esempio n. 2
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;
	}
Esempio n. 3
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;
	}
Esempio n. 4
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;
	}
Esempio n. 5
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;
	}
Esempio n. 6
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;
	}