Ejemplo n.º 1
0
	static void ReloadLoginIDBans()
	{
		// init variables
		char szDataPath[MAX_PATH];
		GetUserDataPath(szDataPath);
		string scAcctPath = string(szDataPath) + "\\Accts\\MultiPlayer\\loginidbans.ini";
		if (set_iPluginDebug)
			ConPrint(L"NOTICE: Loading Login ID bans from %s\n",stows(scAcctPath).c_str());

		INI_Reader ini;
		set_lstLoginIDBans.clear();
		if (ini.open(scAcctPath.c_str(), false))
		{
			while (ini.read_header())
			{
				while (ini.read_value())
				{
					set_lstLoginIDBans.push_back(Trim(ini.get_name_ptr()));
					if (set_iPluginDebug)
						ConPrint(L"NOTICE: Adding Login ID ban %s\n", stows(ini.get_name_ptr()).c_str());
				}
			}
			ini.close();
		}
		ConPrint(L"ID Bans [%u]\n",set_lstLoginIDBans.size());
	}
Ejemplo n.º 2
0
wstring CSocket::GetAdminName()
{
	wstring wscReturn = L"Socket connection (";
	wscReturn += stows(this->sIP);
	wscReturn += L":";
	wscReturn += stows(itos(this->iPort));
	wscReturn += L")";
	return wscReturn;
}
Ejemplo n.º 3
0
void __stdcall Update()//called on each tick (?) only cleans if specified interval has passed
{
	returncode = DEFAULT_RETURNCODE;
	if (((uint)time(0) - iLastUpCall) >= iCleanInterval)
	{
		conDebug(L"time math: " + stows(itos((uint)time(0))) + L" - " + stows(itos(iLastUpCall)) + L" > " + stows(itos(iCleanInterval)));
		CleanUpBounties();
		iLastUpCall = (uint)time(0);
	}
}
Ejemplo n.º 4
0
wstring FactoryModule::GetInfo(bool xml)
{
	wstring info;
	if (xml)
	{
		info += FACTORY_NAMES[type]; 
		info += L"</TEXT><PARA/><TEXT>      Pending " + stows(itos(build_queue.size())) + L" items</TEXT>";
		if (active_recipe.nickname)
		{
			info += L"<PARA/><TEXT>      Building " + active_recipe.infotext + L". Waiting for:</TEXT>";
		
			for (map<uint,uint>::iterator i = active_recipe.consumed_items.begin();
				i != active_recipe.consumed_items.end(); ++i)
			{
				uint good = i->first;
				uint quantity = i->second;
				
				const GoodInfo *gi = GoodList::find_by_id(good);
				if (gi)
				{
					info += L"<PARA/><TEXT>      - " + stows(itos(quantity)) + L"x " + HkGetWStringFromIDS(gi->iIDSName);
					if (quantity > 0 && base->HasMarketItem(good) < active_recipe.cooking_rate)
						info += L" [Out of stock]";
					info += L"</TEXT>";
				}
			}
		}
		info += L"<TEXT>";
	}
	else
	{
		info += FACTORY_NAMES[type];
		info += L" - Pending " + stows(itos(build_queue.size())) + L" items ";
		if (active_recipe.nickname)
		{
			info = L" - Building " + active_recipe.infotext + L". Waiting for:";
		
			for (map<uint,uint>::iterator i = active_recipe.consumed_items.begin();
				i != active_recipe.consumed_items.end(); ++i)
			{
				uint good = i->first;
				uint quantity = i->second;
				
				const GoodInfo *gi = GoodList::find_by_id(good);
				if (gi)
				{
					info += L" " + stows(itos(quantity)) + L"x " + HkGetWStringFromIDS(gi->iIDSName);
				}
			}
		}
	}

	return info;
}
Ejemplo n.º 5
0
/** Clean up old bounties **/
void CleanUpBounties()
{
	conDebug(L"attempting to clean up bounties");
	string File_FLHook_bounties = "..\\exe\\flhook_plugins\\bountytrackerbounties.cfg";

	INI_Reader ini;
		if (ini.open(File_FLHook_bounties.c_str(), false))
		{
			while (ini.read_header())
			{
				if (ini.is_header("bounty"))
				{
					while (ini.read_value())
					{
						if (ini.is_value("hit"))
						{
							wstring wscTargetName = stows(ini.get_value_string(0));
							//if bounty has expired
							if ((uint)time(0) - stoi(mapBountyTargets[wscTargetName].issueTime) > iBountyAge)
							{
								conDebug(L"removing " + wscTargetName);
								//find bounty
								BountyTargetInfo BTIc = mapBountyTargets[wscTargetName];
								//refund remaining credits to issuer
								HkAddCash(stows(BTIc.issuer), (stoi(BTIc.Cash) * stoi(BTIc.xTimes)));//issuer needs to be online(?)
								//notify issuer their bounty has been refunded

								//delete bounty
								deleteBountyCfg(BTIc);
							}
							//if target has changed name
							CAccount *caTargetAcc = HkGetAccountByCharname(wscTargetName);
							int iTargetAcc = stoi(HkGetAccountID(caTargetAcc));
							if (iTargetAcc == -1)
							{
								//find bounty
								BountyTargetInfo BTIc = mapBountyTargets[wscTargetName];
								//refund remaining credits to issuer
								HkAddCash(stows(BTIc.issuer), (stoi(BTIc.Cash) * stoi(BTIc.xTimes)));//issuer needs to be online(?)
								//notify issuer their bounty has been refunded

								//delete bounty
								deleteBountyCfg(BTIc);
							}
						}
					}
				}
			}
			ini.close();
		}
}
Ejemplo n.º 6
0
void PrintZones()
{
	zone_map_t set_mmapZones;
	ReadUniverse(set_mmapZones);

	ConPrint(L"Zone, Commodity, MinLoot, MaxLoot, Difficultly, PosX, PosY, PosZ, SizeX, SizeY, SizeZ, IdsName, IdsInfo, Bonus\n");
	for (zone_map_iter_t i=set_mmapZones.begin(); i!=set_mmapZones.end(); i++)
	{
		ConPrint(L"%s, %s, %d, %d, %d, %0.0f, %0.0f, %0.0f, %0.0f, %0.0f, %0.0f, %d, %d, %2.2f\n", 
			stows(i->second.zoneNick).c_str(), stows(i->second.lootNick).c_str(),
			i->second.iMinLoot, i->second.iMaxLoot, i->second.iLootDifficulty,
			i->second.pos.x,i->second.pos.y,i->second.pos.z,
			i->second.size.x,i->second.size.y,i->second.size.z);
	}
	ConPrint(L"Zones=%d\n",set_mmapZones.size());
}
Ejemplo n.º 7
0
void REP::LoadSettings()
{
	// The path to the configuration file.
	char szCurDir[MAX_PATH];
	GetCurrentDirectory(sizeof(szCurDir), szCurDir);
	string scPluginCfgFile = string(szCurDir) + "\\flhook_plugins\\alley_rep.cfg";

	INI_Reader ini;
	if (ini.open(scPluginCfgFile.c_str(), false))
	{
		while (ini.read_header())
			{
				if (ini.is_header("reputations"))
				{
					while (ini.read_value())
					{
						if (ini.is_value("rep"))
						{
							uint solarnick = CreateID(ini.get_value_string(0));
							const char* newrep = ini.get_value_string(1);

							ConPrint(L"DEBUG: Rep of %s is %s \n", stows(ini.get_value_string(0)).c_str(), stows(ini.get_value_string(1)).c_str());
							
							uint obj_rep_group;
							pub::Reputation::GetReputationGroup(obj_rep_group, newrep);
							pub::Reputation::SetAffiliation(solarnick, obj_rep_group);
						}
					}				
				}
			}
		ini.close();
	}
}
Ejemplo n.º 8
0
void BuildModule::LoadState(INI_Reader &ini)
{
	while (ini.read_value())
	{
		if (ini.is_value("build_type"))
		{
			build_type = ini.get_value_int(0);
		}
		else if (ini.is_value("produced_item"))
		{
			active_recipe.produced_item = ini.get_value_int(0);
		}
		else if (ini.is_value("cooking_rate"))
		{
			active_recipe.cooking_rate = ini.get_value_int(0);
		}
		else if (ini.is_value("infotext"))
		{
			active_recipe.infotext = stows(ini.get_value_string());
		}
		else if (ini.is_value("consumed"))
		{
			active_recipe.consumed_items[ini.get_value_int(0)] = ini.get_value_int(1);
		}
	}
}
Ejemplo n.º 9
0
void FactoryModule::LoadState(INI_Reader &ini)
{
	active_recipe.nickname = 0;
	while (ini.read_value())
	{
		if (ini.is_value("type"))
		{
			type = ini.get_value_int(0);
		}
		else if (ini.is_value("nickname"))
		{
			active_recipe.nickname = ini.get_value_int(0);
		}
		else if (ini.is_value("produced_item"))
		{
			active_recipe.produced_item = ini.get_value_int(0);
		}
		else if (ini.is_value("cooking_rate"))
		{
			active_recipe.cooking_rate = ini.get_value_int(0);
		}
		else if (ini.is_value("infotext"))
		{
			active_recipe.infotext = stows(ini.get_value_string());
		}
		else if (ini.is_value("consumed"))
		{
			active_recipe.consumed_items[ini.get_value_int(0)] = ini.get_value_int(1);
		}
		else if (ini.is_value("build_queue"))
		{
			build_queue.push_back(ini.get_value_int(0));
		}
	}
}
Ejemplo n.º 10
0
HK_ERROR HkGetAdmin(const wstring &wscCharname, wstring &wscRights)
{
	wscRights = L"";
	HK_GET_CLIENTID(iClientID, wscCharname);
	CAccount *acc;
	if(iClientID == -1) {
		flstr *str = CreateWString(wscCharname.c_str());
		acc = Players.FindAccountFromCharacterName(*str);
		FreeWString(str);
		if(!acc)
			return HKE_CHAR_DOES_NOT_EXIST;;
	} else {
		acc = Players.FindAccountFromClientID(iClientID);
	}

	wstring wscDir;
	HkGetAccountDirName(acc, wscDir);
	string scAdminFile = scAcctPath + wstos(wscDir) + "\\flhookadmin.ini";

	WIN32_FIND_DATA fd;
	HANDLE hFind = FindFirstFile(scAdminFile.c_str(), &fd);
	if(hFind == INVALID_HANDLE_VALUE)
		return HKE_PLAYER_NO_ADMIN;;

	FindClose(hFind);
	wscRights = stows(IniGetS(scAdminFile, "admin", "rights", ""));

	return HKE_OK;
}
Ejemplo n.º 11
0
void AP::LoadSettings()
{
	// The path to the configuration file.
	char szCurDir[MAX_PATH];
	GetCurrentDirectory(sizeof(szCurDir), szCurDir);
	string scPluginCfgFile = string(szCurDir) + "\\flhook_plugins\\alley_permissions.cfg";

	INI_Reader ini;
	if (ini.open(scPluginCfgFile.c_str(), false))
	{
		while (ini.read_header())
			{
				if (ini.is_header("angels"))
				{
					while (ini.read_value())
					{
						if (ini.is_value("permission"))
						{
							angels.push_back(stows(ini.get_value_string()));
						}
					}				
				}
				else if (ini.is_header("event"))
				{
					while (ini.read_value())
					{
						if (ini.is_value("permission"))
						{
							events.push_back(stows(ini.get_value_string()));
						}
					}	
				}
				else if (ini.is_header("bastillebase"))
				{
					while (ini.read_value())
					{
						if (ini.is_value("base"))
						{
							uint base = CreateID(ini.get_value_string());
							bastillebase[base] = base; 
						}
					}
				}
			}
		ini.close();
	}
}
Ejemplo n.º 12
0
wstring HkGetPlayerSystem(uint iClientID)
{
	uint iSystemID;
	pub::Player::GetSystem(iClientID, iSystemID);
	char szSystemname[1024] = "";
	pub::GetSystemNickname(szSystemname, sizeof(szSystemname), iSystemID);
	return stows(szSystemname);
}
Ejemplo n.º 13
0
HK_ERROR HkGetAccountDirName(CAccount *acc, wstring &wscDir)
{
	_GetFLName GetFLName = (_GetFLName)((char*)hModServer + 0x66370);

	char szDir[1024] = "";
	GetFLName(szDir, acc->wszAccID);
	wscDir = stows(szDir);
	return HKE_OK;
}
Ejemplo n.º 14
0
wstring BuildModule::GetInfo(bool xml)
{
	wstring info;
	if (xml)
	{
		info = L"<TEXT>Constructing " + active_recipe.infotext + L". Waiting for:</TEXT>";

		for (map<uint,uint>::iterator i = active_recipe.consumed_items.begin();
			i != active_recipe.consumed_items.end(); ++i)
		{
			uint good = i->first;
			uint quantity = i->second;
			
			const GoodInfo *gi = GoodList::find_by_id(good);
			if (gi)
			{
				info += L"<PARA/><TEXT>      - " + stows(itos(quantity)) + L"x " + HkGetWStringFromIDS(gi->iIDSName);
				if (base->HasMarketItem(good) < quantity)
					info += L" [Out of stock]";
				info += L"</TEXT>";
			}
		}
	}
	else
	{
		info = L"Constructing " + active_recipe.infotext + L". Waiting for: ";

		for (map<uint,uint>::iterator i = active_recipe.consumed_items.begin();
			i != active_recipe.consumed_items.end(); ++i)
		{
			uint good = i->first;
			uint quantity = i->second;
			
			const GoodInfo *gi = GoodList::find_by_id(good);
			if (gi)
			{
				info += stows(itos(quantity)) + L"x" + HkGetWStringFromIDS(gi->iIDSName) + L" ";
			}
		}
	}

	return info;
}
Ejemplo n.º 15
0
bool UserCmd_BountyView(uint iClientID, const wstring &wscCmd, const wstring &wscParam, const wchar_t *usage)
{
	if (!bPluginEnabled)
	{
		PrintUserCmdText(iClientID, L"BountyTracker is disabled.");
		return true;
	}

	// Get the parameters from the user command.
	wstring wscName = GetParam(wscParam, L' ', 0);
	wstring wscCash = GetParam(wscParam, L' ', 1);
	wstring wscxTimes = GetParam(wscParam, L' ', 2);

	if (wscName == L"")
	{
		PrintUserCmdText(iClientID, L"ERR invalid Parameters\n");
		return false;
	}
	if (HkGetAccountByCharname(wscName) == 0)
	{
		PrintUserCmdText(iClientID, L"ERR Player does not exist");
		return true;
	}
	BountyTargetInfo BTIv = mapBountyTargets[ToLower(wscName)];
	wstring PFwsTargetInfo;
	PFwsTargetInfo = L"Target: ";
	PFwsTargetInfo += ToLower(wscName);
	PFwsTargetInfo += L" Worth: ";
	PFwsTargetInfo += stows(BTIv.Cash);
	PFwsTargetInfo += L" Contracts Left: ";
	PFwsTargetInfo += stows(BTIv.xTimes);
	PFwsTargetInfo += L" Issuer: ";
	PFwsTargetInfo += stows(BTIv.issuer);
	PFwsTargetInfo += L" Issued: ";
	PFwsTargetInfo += stows(BTIv.issueTime);
	PrintUserCmdText(iClientID, PFwsTargetInfo);
	PrintUserCmdText(iClientID, L"OK");
	return true;
}
Ejemplo n.º 16
0
bool deleteBountyCfg(BountyTargetInfo BTI)
{
	string sActive;
	//load file
	loadfile("..\\exe\\flhook_plugins\\bountytrackerbounties.cfg");
	//remove strings
	if (BTI.active)
	{
		sActive = "true";
	}
	if (!BTI.active)
	{
		sActive = "false";
	}
	string item = "hit = " + BTI.Char + "," + BTI.Cash + "," + BTI.xTimes + "," + BTI.issuer + "," + sActive + "," + BTI.lastIssuer + "," + BTI.lastTime + "," + BTI.issueTime + "\n";//find this
	RemoveLinevsFile(item, Currentvsfile);
	//repalce file
	conDebug(L"replacing line " + stows(BTI.Char));
	ReplaceFileContents("..\\exe\\flhook_plugins\\bountytrackerbounties.cfg", Currentvsfile);
	return true;
}
Ejemplo n.º 17
0
HK_ERROR HkGetCharFileName(const wstring &wscCharname, wstring &wscFilename)
{
	static _GetFLName GetFLName = 0;
	if (!GetFLName)
		GetFLName = (_GetFLName)((char*)hModServer + 0x66370);

	char szBuf[1024] = "";

	HK_GET_CLIENTID(iClientID, wscCharname);
	if(iClientID != -1)
	{
		GetFLName(szBuf, Players.GetActiveCharacterName(iClientID));
	}
	else
	{
		GetFLName(szBuf, wscCharname.c_str());
	}

	wscFilename = stows(szBuf);
	return HKE_OK;
}
Ejemplo n.º 18
0
void __stdcall GFGoodSell(struct SGFGoodSellInfo const &gsi, unsigned int iClientID)
{
		returncode = DEFAULT_RETURNCODE;

		const GoodInfo *packageInfo = GoodList::find_by_id(gsi.iArchID);
		// check for equipments only
		if (packageInfo->iType == 1)
			{
				uint iBase;
				pub::Player::GetBase(iClientID, iBase);

				//in this case, it's more efficent to check if it's an item under watch first.
				for (map<uint, string>::iterator iter = mapACItems.begin(); iter!=mapACItems.end(); iter++)
				{
					if (iter->first == gsi.iArchID)
					{
						//PrintUserCmdText(iClientID, L"I have found commodity %s.", stows(iter->second).c_str());
						//We iterate through the base names to see if it's a non-POB base
							list<uint>::iterator i = mapACBases.begin();
							while (i != mapACBases.end())
							{
								if (*i == iBase)
								{
									wstring wscCharname = (const wchar_t*) Players.GetActiveCharacterName(iClientID);
									wstring wscBaseName = HkGetBaseNickByID(iBase);
									

									//PrintUserCmdText(iClientID, L"I have found this base, logging the purchase.");
									// check if this item is already under watch, if so increase amount by 1
									if (mapACSales[iClientID].items.find(gsi.iArchID) != mapACSales[iClientID].items.end())
									{
										++mapACSales[iClientID].items.find(gsi.iArchID)->second;
										//PrintUserCmdText(iClientID, L"DEBUG: I have logged %i sales.", mapACSales[iClientID].items.find(gsi.iArchID)->second);
										wstring wscMsgLog = L"<%sender> has sold <%item> to base <%basename> (Already recorded %isale sales of this item)";
										wscMsgLog = ReplaceStr(wscMsgLog, L"%sender", wscCharname.c_str());
										wscMsgLog = ReplaceStr(wscMsgLog, L"%basename", wscBaseName.c_str());
										wscMsgLog = ReplaceStr(wscMsgLog, L"%item", stows(iter->second).c_str());
										wscMsgLog = ReplaceStr(wscMsgLog, L"%isale", stows(itos(mapACSales[iClientID].items.find(gsi.iArchID)->second))).c_str();
										string scText = wstos(wscMsgLog);
										Logging("%s", scText.c_str());
										
									}
									else
									{
										mapACSales[iClientID].items[gsi.iArchID] = 1;
										wstring wscMsgLog = L"<%sender> has sold <%item> to base <%basename> (First sale)";
										wscMsgLog = ReplaceStr(wscMsgLog, L"%sender", wscCharname.c_str());
										wscMsgLog = ReplaceStr(wscMsgLog, L"%basename", wscBaseName.c_str());
										wscMsgLog = ReplaceStr(wscMsgLog, L"%item", stows(iter->second).c_str());
										string scText = wstos(wscMsgLog);
										Logging("%s", scText.c_str());
									}
									break;
								}
								i++;
							}
						break;
					}
				}
			}
}
Ejemplo n.º 19
0
void __stdcall GFGoodBuy(struct SGFGoodBuyInfo const &gbi, unsigned int iClientID)
	{
		returncode = DEFAULT_RETURNCODE;

			const GoodInfo *packageInfo = GoodList::find_by_id(gbi.iGoodID);
			/*
			if (packageInfo->iType == 0)
			{
			PrintUserCmdText(iClientID, L"This should be a commodity (equipment?) purchase");
			}
			*/
			if (packageInfo->iType == 1)
			{
			//PrintUserCmdText(iClientID, L"This should be an equipment (maybe?) purchase");
			uint iBase;
			pub::Player::GetBase(iClientID, iBase);
			bool aminiceitem = true;
			string itemname;
			int wearecool = 0;
			
				//in this case, it's more efficent to check if it's an item under watch first.

				for (map<uint, string>::iterator iter = mapACItems.begin(); iter!=mapACItems.end(); iter++)
				{
					if (iter->first == gbi.iGoodID)
					{
									//PrintUserCmdText(iClientID, L"I have found this commodity");
									//We iterate through the base names to see if it's a non-POB base
									list<uint>::iterator i = mapACBases.begin();
									while (i != mapACBases.end())
									{
										if (*i == iBase)
										{
											
												if (mapACSales[iClientID].items.find(gbi.iGoodID) != mapACSales[iClientID].items.end())
												{
														--mapACSales[iClientID].items.find(gbi.iGoodID)->second;
													
															//PrintUserCmdText(iClientID, L"DEBUG: I have found this sale, letting the purchase go through.");
															aminiceitem = true;
															wearecool = 1;

															wstring wscCharname = (const wchar_t*) Players.GetActiveCharacterName(iClientID);
															wstring wscBaseName = HkGetBaseNickByID(iBase);
															
															//PrintUserCmdText(iClientID, L"DEBUG: %i purchases left.", mapACSales[iClientID].items.find(gbi.iGoodID)->second);
															wstring wscMsgLog = L"<%sender> has bought back <%item> from base <%basename> (%isale purchases left)";
															wscMsgLog = ReplaceStr(wscMsgLog, L"%sender", wscCharname.c_str());
															wscMsgLog = ReplaceStr(wscMsgLog, L"%basename", wscBaseName.c_str());
															wscMsgLog = ReplaceStr(wscMsgLog, L"%item", stows(iter->second).c_str());
															wscMsgLog = ReplaceStr(wscMsgLog, L"%isale", stows(itos(mapACSales[iClientID].items.find(gbi.iGoodID)->second))).c_str();
															string scText = wstos(wscMsgLog);
															Logging("%s", scText.c_str());

															if (mapACSales[iClientID].items.find(gbi.iGoodID)->second == 0)
															{
																mapACSales[iClientID].items.erase(gbi.iGoodID);
																//PrintUserCmdText(iClientID, L"DEBUG: no purchases left");
															}

															break;
													
												}

											if (wearecool == 0)
											{
											//PrintUserCmdText(iClientID, L"DEBUG: I have found this base, not good");
											aminiceitem = false;
											itemname = iter->second;
											}
										}
										i++;
									}
					}

					if (aminiceitem == false)
					{
						returncode = SKIPPLUGINS_NOFUNCTIONCALL;
						wstring wscCharname = (const wchar_t*) Players.GetActiveCharacterName(iClientID);
							wstring wscBaseName = HkGetBaseNickByID(iBase);
							
							pub::Player::SendNNMessage(iClientID, pub::GetNicknameId("nnv_anomaly_detected"));
							wstring wscMsgU = L"MF: %name has been permabanned. (Type 2)";
							wscMsgU = ReplaceStr(wscMsgU, L"%name", wscCharname.c_str());

							HkMsgU(wscMsgU);

							wstring wscMsgLog = L"<%sender> was permabanned for attempting to buy an illegal item <%item> from base <%basename> (see DSAM)";
							wscMsgLog = ReplaceStr(wscMsgLog, L"%sender", wscCharname.c_str());
							wscMsgLog = ReplaceStr(wscMsgLog, L"%basename", wscBaseName.c_str());
							wscMsgLog = ReplaceStr(wscMsgLog, L"%item", stows(itemname).c_str());

							LogCheater(iClientID, wscMsgLog);
					}
				}
			}
			else if (packageInfo->iType == 3)
			{
					uint iBase;
					pub::Player::GetBase(iClientID, iBase);
					//PrintUserCmdText(iClientID, L"This should be a ship purchase");
					bool aminiceship = false;

					for (map<uint, list<uint>>::iterator iter = mapACShips.begin(); iter!=mapACShips.end(); iter++)
					{
						if (iter->first == iBase)
						{
							//PrintUserCmdText(iClientID, L"This should be a base");
							// we check if one of the three packages sold here is the correct one
							list<uint>::iterator i = iter->second.begin();
							while (i != iter->second.end())
							{
								if (*i == gbi.iGoodID)
								{
									//PrintUserCmdText(iClientID, L"I have found this ship");
									aminiceship = true;
									break;
								}
								i++;
							}								
						}
					}

					if (aminiceship == false)
					{
						wstring wscCharname = (const wchar_t*) Players.GetActiveCharacterName(iClientID);
						wstring wscBaseName = HkGetBaseNickByID(iBase);
						
						pub::Player::SendNNMessage(iClientID, pub::GetNicknameId("nnv_anomaly_detected"));
						wstring wscMsgU = L"MF: %name has been permabanned. (Type 1)";
						wscMsgU = ReplaceStr(wscMsgU, L"%name", wscCharname.c_str());

						HkMsgU(wscMsgU);

						wstring wscMsgLog = L"<%sender> was permabanned for attempting to buy an illegal ship from base <%basename> (see DSAM)";
						wscMsgLog = ReplaceStr(wscMsgLog, L"%sender", wscCharname.c_str());
						wscMsgLog = ReplaceStr(wscMsgLog, L"%basename", wscBaseName.c_str());

						LogCheater(iClientID, wscMsgLog);
					}
			}	




	}
Ejemplo n.º 20
0
	foreach(lstValues, INISECTIONVALUE, it4)
	{
		set_btJRestrict->Add(new DOCK_RESTRICTION(CreateID(it4->scKey.c_str()), CreateID((Trim(GetParam(it4->scValue, ',', 0))).c_str()), ToInt(Trim(GetParam(it4->scValue, ',', 1))), stows(Trim(GetParamToEnd(it4->scValue, ',', 2)))));
	}
Ejemplo n.º 21
0
	/// Set the move char code for all characters in the account
	void Rename::AdminCmd_SetAccMoveCode(CCmds* cmds, const wstring &wscCharname, const wstring &wscCode)
	{
		// Don't indicate an error if moving is disabled.
		if (!set_bEnableMoveChar)
			return;

		if (!(cmds->rights & RIGHT_SUPERADMIN))
		{
			cmds->Print(L"ERR No permission\n");
			return;
		}

		wstring wscDir;
		if (HkGetAccountDirName(wscCharname, wscDir)!=HKE_OK)
		{
			cmds->Print(L"ERR Charname not found\n");
			return;
		}

		if (wscCode.length()==0)
		{
			cmds->Print(L"ERR Code too small, set to none to clear.\n");
			return;
		}

		// Get the account path.
		char szDataPath[MAX_PATH];
		GetUserDataPath(szDataPath);
		string scPath = string(szDataPath) + "\\Accts\\MultiPlayer\\" + wstos(wscDir) + "\\*.fl";

		// Open the directory iterator.
		WIN32_FIND_DATA FindFileData; 
		HANDLE hFileFind = FindFirstFile(scPath.c_str(), &FindFileData);
		if (hFileFind==INVALID_HANDLE_VALUE)
		{
			cmds->Print(L"ERR Account directory not found\n");
			return;
		}

		// Iterate it
		do
		{
			string scCharfile = FindFileData.cFileName;
			string scMoveCodeFile = string(szDataPath) + "\\Accts\\MultiPlayer\\" + wstos(wscDir) + "\\"
				+ scCharfile.substr(0,scCharfile.size()-3) + "-movechar.ini";
			if (wscCode==L"none")
			{
				IniWriteW(scMoveCodeFile, "Settings", "Code", L"");
				cmds->Print(L"OK Movechar code cleared on "+stows(scCharfile)+L"\n");
			}
			else
			{
				IniWriteW(scMoveCodeFile, "Settings", "Code", wscCode);
				cmds->Print(L"OK Movechar code set to "+wscCode +L" on "+stows(scCharfile)+L"\n");
			}
		}
		while (FindNextFile(hFileFind, &FindFileData));
		FindClose(hFileFind); 

		cmds->Print(L"OK\n");
	}
Ejemplo n.º 22
0
void LoadSettings()
{
// init cfg filename
	char szCurDir[MAX_PATH];
	GetCurrentDirectory(sizeof(szCurDir), szCurDir);
	set_scCfgFile = szCurDir;
	
	// Use flhook.cfg if it is available. It is used in some installations (okay just cannon's)
	// to avoid FLErrorChecker whining retardly about ini entries it does not understand.
	if (_access(string(set_scCfgFile + "\\FLHook.cfg").c_str(), 0) != -1)
		set_scCfgFile += "\\FLHook.cfg";
	else
		set_scCfgFile += "\\FLHook.ini";


// General
	set_iAntiDockKill = IniGetI(set_scCfgFile, "General", "AntiDockKill", 0);
	set_bDieMsg = IniGetB(set_scCfgFile, "General", "EnableDieMsg", false);
	set_bDisableCharfileEncryption = IniGetB(set_scCfgFile, "General", "DisableCharfileEncryption", false);
	set_bChangeCruiseDisruptorBehaviour = IniGetB(set_scCfgFile, "General", "ChangeCruiseDisruptorBehaviour", false);
	set_iDisableNPCSpawns = IniGetI(set_scCfgFile, "General", "DisableNPCSpawns", 0);
	set_iAntiF1 = IniGetI(set_scCfgFile, "General", "AntiF1", 0);
	set_iDisconnectDelay = IniGetI(set_scCfgFile, "General", "DisconnectDelay", 0);
	set_iReservedSlots = IniGetI(set_scCfgFile, "General", "ReservedSlots", 0);
	set_fTorpMissileBaseDamageMultiplier = IniGetF(set_scCfgFile, "General", "TorpMissileBaseDamageMultiplier", 1.0f);
	set_iMaxGroupSize = IniGetI(set_scCfgFile, "General", "MaxGroupSize", 8);

// Log
	set_bDebug = IniGetB(set_scCfgFile, "Log", "Debug", false);
	set_iDebugMaxSize = IniGetI(set_scCfgFile, "Log", "DebugMaxSize", 100);
	set_iDebugMaxSize *= 1000;
	set_bLogConnects = IniGetB(set_scCfgFile, "Log", "LogConnects", false);
	set_bLogAdminCmds = IniGetB(set_scCfgFile, "Log", "LogAdminCommands", false);
	set_bLogSocketCmds = IniGetB(set_scCfgFile, "Log", "LogSocketCommands", false);
	set_bLogLocalSocketCmds = IniGetB(set_scCfgFile, "Log", "LogLocalSocketCommands", false);
	set_bLogUserCmds = IniGetB(set_scCfgFile, "Log", "LogUserCommands", false);
	set_bPerfTimer = IniGetB(set_scCfgFile, "Log", "LogPerformanceTimers", false);
	set_iTimerThreshold = IniGetI(set_scCfgFile, "Log", "TimerThreshold", 100);
	set_iTimerDebugThreshold = IniGetI(set_scCfgFile, "Log", "TimerDebugThreshold", 0);

// Kick
	set_iAntiBaseIdle = IniGetI(set_scCfgFile, "Kick", "AntiBaseIdle", 0);
	set_iAntiCharMenuIdle = IniGetI(set_scCfgFile, "Kick", "AntiCharMenuIdle", 0);


// Style
	set_wscDeathMsgStyle = stows(IniGetS(set_scCfgFile, "Style", "DeathMsgStyle", "0x19198C01"));
	set_wscDeathMsgStyleSys = stows(IniGetS(set_scCfgFile, "Style", "DeathMsgStyleSys", "0x1919BD01"));
	set_wscDeathMsgTextPlayerKill = stows(IniGetS(set_scCfgFile, "Style", "DeathMsgTextPlayerKill", "Death: %victim was killed by %killer (%type)"));
	set_wscDeathMsgTextSelfKill = stows(IniGetS(set_scCfgFile, "Style", "DeathMsgTextSelfKill", "Death: %victim killed himself (%type)"));
	set_wscDeathMsgTextNPC = stows(IniGetS(set_scCfgFile, "Style", "DeathMsgTextNPC", "Death: %victim was killed by an NPC"));
	set_wscDeathMsgTextSuicide = stows(IniGetS(set_scCfgFile, "Style", "DeathMsgTextSuicide", "Death: %victim committed suicide"));
	set_wscDeathMsgTextAdminKill = stows(IniGetS(set_scCfgFile, "Style", "DeathMsgTextAdminKill", "Death: %victim was killed by an admin"));

	set_wscKickMsg = stows(IniGetS(set_scCfgFile, "Style", "KickMsg", "<TRA data=\"0x0000FF10\" mask=\"-1\"/><TEXT>You will be kicked. Reason: %s</TEXT>"));
	set_iKickMsgPeriod = IniGetI(set_scCfgFile, "Style", "KickMsgPeriod", 5000);
	set_wscUserCmdStyle = stows(IniGetS(set_scCfgFile, "Style", "UserCmdStyle", "0x00FF0090"));
	set_wscAdminCmdStyle = stows(IniGetS(set_scCfgFile, "Style", "AdminCmdStyle", "0x00FF0090"));

// Socket
	set_bSocketActivated = IniGetB(set_scCfgFile, "Socket", "Activated", false);
	set_iPort = IniGetI(set_scCfgFile, "Socket", "Port", 0);
	set_iWPort = IniGetI(set_scCfgFile, "Socket", "WPort", 0);
	set_iEPort = IniGetI(set_scCfgFile, "Socket", "EPort", 0);
	set_iEWPort = IniGetI(set_scCfgFile, "Socket", "EWPort", 0);
	string scEncryptKey = IniGetS(set_scCfgFile, "Socket", "Key", "");
	if(scEncryptKey.length())
	{
		if(!set_BF_CTX)
			set_BF_CTX = (BLOWFISH_CTX*)malloc(sizeof(BLOWFISH_CTX));
		Blowfish_Init(set_BF_CTX, (unsigned char *)scEncryptKey.data(), (int)scEncryptKey.length());
	}

// UserCommands
	set_bUserCmdSetDieMsg = IniGetB(set_scCfgFile, "UserCommands", "SetDieMsg", false);
	set_bUserCmdSetDieMsgSize = IniGetB(set_scCfgFile, "UserCommands", "SetDieMsgSize", false);
	set_bUserCmdSetChatFont = IniGetB(set_scCfgFile, "UserCommands", "SetChatFont", false);
	set_bUserCmdIgnore = IniGetB(set_scCfgFile, "UserCommands", "Ignore", false);
	set_iUserCmdMaxIgnoreList = IniGetI(set_scCfgFile, "UserCommands", "MaxIgnoreListEntries", 30);
	set_bAutoBuy = IniGetB(set_scCfgFile, "UserCommands", "AutoBuy", false);
	set_bUserCmdHelp = IniGetB(set_scCfgFile, "UserCommands", "Help", false);
	set_bDefaultLocalChat = IniGetB(set_scCfgFile, "UserCommands", "DefaultLocalChat", false);

// NoPVP
	set_lstNoPVPSystems.clear();
	for(uint i = 0;; i++)
	{
		char szBuf[64];
		sprintf(szBuf, "System%u", i);
		string scSystem = IniGetS(set_scCfgFile, "NoPVP", szBuf, "");

		if(!scSystem.length())
			break;

		uint iSystemID;
		pub::GetSystemID(iSystemID, scSystem.c_str());
		set_lstNoPVPSystems.push_back(iSystemID);
	}

// read chat suppress
	set_lstChatSuppress.clear();
	for(uint i = 0;; i++)
	{
		char szBuf[64];
		sprintf(szBuf, "Suppress%u", i);
		string scSuppress = IniGetS(set_scCfgFile, "Chat", szBuf, "");

		if(!scSuppress.length())
			break;

		set_lstChatSuppress.push_back(stows(scSuppress));
	}

// MultiKillMessages
	set_MKM_bActivated = IniGetB(set_scCfgFile, "MultiKillMessages", "Activated", false);
	set_MKM_wscStyle = stows(IniGetS(set_scCfgFile, "MultiKillMessages", "Style", "0x1919BD01"));

	set_MKM_lstMessages.clear();
	list<INISECTIONVALUE> lstValues;
	IniGetSection(set_scCfgFile, "MultiKillMessages", lstValues);
	foreach(lstValues, INISECTIONVALUE, it)
	{
		if(!atoi(it->scKey.c_str()))
			continue;

		MULTIKILLMESSAGE mkm;
		mkm.iKillsInARow = atoi(it->scKey.c_str());
		mkm.wscMessage = stows(it->scValue);
		set_MKM_lstMessages.push_back(mkm);
	}

// bans
	set_bBanAccountOnMatch = IniGetB(set_scCfgFile, "Bans", "BanAccountOnMatch", false);
	set_lstBans.clear();
	IniGetSection(set_scCfgFile, "Bans", lstValues);
	if(!lstValues.empty())
	{
		lstValues.pop_front();
		foreach(lstValues, INISECTIONVALUE, itisv)
			set_lstBans.push_back(stows(itisv->scKey));
	}

// help
	HkAddHelpEntry( L"/set diemsg", L"<visibility>", L"Sets your death message's visibility. Options: all, system, self, none.", L"", get_bUserCmdSetDieMsg );
	HkAddHelpEntry( L"/set diemsgsize", L"<size>", L"Sets your death message's text size. Options: small, default.", L"", get_bUserCmdSetDieMsgSize );
	HkAddHelpEntry( L"/set chatfont", L"<size> <style>", L"Sets your chat messages' font. Options are small, default or big for <size> and default, bold, italic or underline for <style>.", L"", get_bUserCmdSetChatFont );
	HkAddHelpEntry( L"/ignore", L"<charname> [<flags>]", L"Ignores all messages from the given character.", L"The possible flags are:\n p - only affect private chat\n i - <charname> may match partially\nExamples:\n\"/ignore SomeDude\" ignores all chatmessages from SomeDude\n\"/ignore PlayerX p\" ignores all private-chatmessages from PlayerX\n\"/ignore idiot i\" ignores all chatmessages from players whose charname contain \"idiot\" (e.g. \"[XYZ]IDIOT\", \"MrIdiot\", etc)\n\"/ignore Fool pi\" ignores all private-chatmessages from players whose charname contain \"fool\"", get_bUserCmdIgnore );
	HkAddHelpEntry( L"/ignoreid", L"<client-id> [<flags>]", L"Ignores all messages from the character with the associated client ID (see /id). Use the p flag to only affect private chat.", L"", get_bUserCmdIgnore );
	HkAddHelpEntry( L"/ignorelist", L"", L"Displays all currently ignored characters.", L"", get_bUserCmdIgnore );
	HkAddHelpEntry( L"/delignore", L"<id> [<id2> <id3> ...]", L"Removes the characters with the associated ignore ID (see /ignorelist) from the ignore list. * deletes all.", L"", get_bUserCmdIgnore );
	HkAddHelpEntry( L"/autobuy", L"<param> [<on/off>]", L"Auomatically buys the given elements upon docking. See detailed help for more information.", L"<param> can take one of the following values:\tinfo - display current autobuy-settings\n\tmissiles - enable/disable autobuy for missiles\n\ttorps - enable/disable autobuy for torpedos\n\tmines - enable/disable autobuy for mines\n\tcd - enable/disable autobuy for cruise disruptors\n\tcm - enable/disable autobuy for countermeasures\n\treload - enable/disable autobuy for nanobots/shield batteries\n\tall - enable/disable autobuy for all of the above\nExamples:\n\"/autobuy missiles on\" enable autobuy for missiles\n\"/autobuy all off\" completely disable autobuy\n\"/autobuy info\" show autobuy info", get_bAutoBuy );
	HkAddHelpEntry( L"/ids", L"", L"Lists all characters with their respective client IDs.", L"", get_bTrue );
	HkAddHelpEntry( L"/id", L"", L"Gives your own client ID.", L"", get_bTrue );
	HkAddHelpEntry( L"/i$", L"<client-id>", L"Invites the given client ID.", L"", get_bTrue );
	HkAddHelpEntry( L"/invite$", L"<client-id>", L"Invites the given client ID.", L"", get_bTrue );
	HkAddHelpEntry( L"/credits", L"", L"Displays FLHook's credits.", L"", get_bTrue );
	HkAddHelpEntry( L"/help", L"[<command>]", L"Displays the help screen. Giving a <command> gives detailed info for that command.", L"", get_bTrue );

	set_bLoadedSettings = true;
}
Ejemplo n.º 23
0
void HkGetPlayerIP(uint iClientID, wstring &wscIP)
{
	wscIP = L"";
	CDPClientProxy *cdpClient = g_cClientProxyArray[iClientID - 1];
	if(!cdpClient)
		return;

	// get ip
	char *szP1;
	char *szIDirectPlay8Address;
	wchar_t wszHostname[] = L"hostname";
	memcpy(&szP1, (char*)cdpSrv + 4, 4);

	wchar_t wszIP[1024] = L"";
	long lSize = sizeof(wszIP);
	long lDataType = 1;
	__asm
	{
		push 0			; dwFlags
		lea edx, szIDirectPlay8Address
		push edx		; pAddress 
		mov edx, [cdpClient]
		mov edx, [edx+8]
		push edx		; dpnid
		mov eax, [szP1]
		push eax
		mov ecx, [eax]
		call dword ptr[ecx + 0x28]	; GetClientAddress
		cmp eax, 0
		jnz some_error

		lea eax, lDataType
		push eax
		lea eax, lSize
		push eax
		lea eax, wszIP
		push eax
		lea eax, wszHostname
		push eax
		mov ecx, [szIDirectPlay8Address]
		push ecx
		mov ecx, [ecx]
		call dword ptr[ecx+0x40] ; GetComponentByName

		mov ecx, [szIDirectPlay8Address]
		push ecx
		mov ecx, [ecx]
		call dword ptr[ecx+0x08] ; Release
some_error:
	}

	wscIP = wszIP;
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////

HK_ERROR HkGetPlayerInfo(const wstring &wscCharname, HKPLAYERINFO &pi, bool bAlsoCharmenu)
{
	HK_GET_CLIENTID(iClientID, wscCharname);

	if(iClientID == -1 || (HkIsInCharSelectMenu(iClientID) && !bAlsoCharmenu))
		return HKE_PLAYER_NOT_LOGGED_IN; // not on server

	const wchar_t *wszActiveCharname = (wchar_t*)Players.GetActiveCharacterName(iClientID);

	pi.iClientID = iClientID;
	pi.wscCharname = wszActiveCharname ? wszActiveCharname : L"";
	pi.wscBase = pi.wscSystem = L"";

	uint iBase = 0;
	uint iSystem = 0;
	pub::Player::GetBase(iClientID, iBase);
	pub::Player::GetSystem(iClientID, iSystem);
	pub::Player::GetShip(iClientID, pi.iShip);

	if(iBase)
	{
		char szBasename[1024] = "";
		pub::GetBaseNickname(szBasename, sizeof(szBasename), iBase);
		pi.wscBase = stows(szBasename);
	}

	if(iSystem)
	{
		char szSystemname[1024] = "";
		pub::GetSystemNickname(szSystemname, sizeof(szSystemname), iSystem);
		pi.wscSystem = stows(szSystemname);
		pi.iSystem = iSystem;
	}

	// get ping
	DPN_CONNECTION_INFO ci;
	HkGetConnectionStats(iClientID,ci);
	pi.ci = ci;

	// get ip
	HkGetPlayerIP(iClientID, pi.wscIP);

	pi.wscHostname = ClientInfo[iClientID].wscHostname;

	return HKE_OK;
}
Ejemplo n.º 24
0
bool UserCmd_BountyAddTo(uint iClientID, const wstring &wscCmd, const wstring &wscParam, const wchar_t *usage)
{
	if (!bPluginEnabled)
	{
		PrintUserCmdText(iClientID, L"BountyTracker is disabled.");
		return true;
	}

	// Get the parameters from the user command.
	wstring wscName = GetParam(wscParam, L' ', 0);
	wstring wscCash = GetParam(wscParam, L' ', 1);
	wstring wscxTimes = GetParam(wscParam, L' ', 2);
	wscCash = ReplaceStr(wscCash, L".", L"");
	wscCash = ReplaceStr(wscCash, L",", L"");
	wscCash = ReplaceStr(wscCash, L"$", L"");
	wscCash = ReplaceStr(wscCash, L"e6", L"000000");

	if (wscName == L"")
	{
		PrintUserCmdText(iClientID, L"ERR invalid name\n");
		return false;
	}
	if (HkGetAccountByCharname(wscName) == 0)
	{
		PrintUserCmdText(iClientID, L"ERR Player does not exist");
		return true;
	}
	if (wscCash == L"")
	{
		PrintUserCmdText(iClientID, L"ERR invalid cash amount\n");
		return false;
	}
	if (stoi(wscCash) < 1000000)
	{
		PrintUserCmdText(iClientID, L"ERR bounty cannot be less than 1,000,000 s.c");
		return true;
	}
	//get bounty 
	BountyTargetInfo BTIat = mapBountyTargets[ToLower(wscName)];
	//check if it is active
	if (!BTIat.active)
	{
		PrintUserCmdText(iClientID, L"ERR bounty not currently active");
		return true;
	}
	//check user has enough money for the bounty
	int iCash;
	HkGetCash(stows(ToLower(wstos((wchar_t*)Players.GetActiveCharacterName(iClientID)))), iCash);
	if (iCash < (stoi(wscCash) * stoi(BTIat.xTimes)))
	{
		PrintUserCmdText(iClientID, L"ERR Not enough cash for bounty.");
		return true;
	}
	HkAddCash((wchar_t*)Players.GetActiveCharacterName(iClientID), 0 - (stoi(wscCash) * stoi(BTIat.xTimes)));
	if (deleteBountyCfg(BTIat))
	{
		//ConPrint(L"bounty removed from cfg\n");
	}
	else
	{
		ConPrint(L"BOUNTYTRACKER: Err removing from cfg. is server admin?\n");
	}
	BTIat.Cash = itos(stoi(BTIat.Cash) + stoi(wscCash));//update cash bounty
	PrintUserCmdText(iClientID, L"Uploading to Neural Net...");
	mapBountyTargets[ToLower(wscName)] = BTIat;
	if (appendBountyCfg(BTIat))
	{
		//ConPrint(L"cfg saved\n");
	}
	else
	{
		ConPrint(L"BOUNTYTRACKER: Err saving to cfg. is serevr admin?\n");
	}
	PrintUserCmdText(iClientID, L"OK");
	return true;
}
Ejemplo n.º 25
0
bool UserCmd_BountyAdd(uint iClientID, const wstring &wscCmd, const wstring &wscParam, const wchar_t *usage)
{
	if (!bPluginEnabled)
	{
		PrintUserCmdText(iClientID, L"BountyTracker is disabled.");
		return true;
	}


	// Get the parameters from the user command.
	wstring wscName = GetParam(wscParam, L' ', 0);
	wstring wscCash = GetParam(wscParam, L' ', 1);
	wstring wscxTimes = GetParam(wscParam, L' ', 2);
	wscCash = ReplaceStr(wscCash, L".", L"");
	wscCash = ReplaceStr(wscCash, L",", L"");
	wscCash = ReplaceStr(wscCash, L"$", L"");
	wscCash = ReplaceStr(wscCash, L"e6", L"000000");//because scientific notation is cool
	int iOnlineSecs;
	HkGetOnLineTime((wchar_t*)Players.GetActiveCharacterName(iClientID), iOnlineSecs);
	if (iOnlineSecs < 7200)// 7200 = 2hrs
	{
		PrintUserCmdText(iClientID, L"ERR Char is too new");
		return true;
	}

	//you are not allowed to create a bounty. ERR rank too low (note, find out what a good rank should be to have access to this. no fresh chars can
	//create bounties. this way we can protect against creating random fresh accs, tranferring cash, and setting copious amounts of bounties.
	if (wscName == L"")
	{
		PrintUserCmdText(iClientID, L"ERR invalid name\n");
		return false;
	}
	if (HkGetAccountByCharname(wscName) == 0)
	{
		PrintUserCmdText(iClientID, L"ERR Player does not exist");
		return true;
	}
	if (mapBountyTargets[ToLower(wscName)].active)
	{
		PrintUserCmdText(iClientID, L"ERR Player already has an active bounty\n");
		return true;
	}
	if (mapBountyTargets[ToLower(wscName)].lastTime != "")
	{
		if ((stoi(mapBountyTargets[ToLower(wscName)].lastTime) + 3600) > (int)time(0))
		{
			PrintUserCmdText(iClientID, L"ERR Player is protected\n");
			PrintUserCmdText(iClientID, stows(itos((stoi(mapBountyTargets[ToLower(wscName)].lastTime) + 3600) - (int)time(0))) + L"'s remaining");
			return true;
		}
	}

	if (iClientID == HkGetClientIdFromCharname(stows(mapBountyTargets[ToLower(wscName)].lastIssuer)))//not too sure about this
	{
		PrintUserCmdText(iClientID, L"ERR You cannot double a bounty on this player\n");
		return true;
	}
	if (wscCash == L"")
	{
		PrintUserCmdText(iClientID, L"ERR invalid cash amount\n");
		return false;
	}
	if (wscxTimes == L"")
	{
		PrintUserCmdText(iClientID, L"ERR invalid contract limit\n");
		return false;
	}
	if (stoi(wscCash) < 1000000)
	{
		PrintUserCmdText(iClientID, L"ERR bounty cannot be less than 1,000,000 s.c");
		return true;
	}
	if (stoi(wscxTimes) < 0 || stoi(wscxTimes) > 5)
	{
		PrintUserCmdText(iClientID, L"ERR bounty contract limit cannot be less than 0 or more than 5");
		return true;
	}
	BountyTargetInfo BTIa = mapBountyTargets[ToLower(wscName)];
	//generate new bounty map values
	BTIa.Char = ToLower(wstos(wscName));
	BTIa.Cash = wstos(wscCash);
	BTIa.xTimes = wstos(wscxTimes);
	BTIa.issuer = ToLower(wstos((wchar_t*)Players.GetActiveCharacterName(iClientID)));
	BTIa.lastIssuer = BTIa.issuer;
	BTIa.active = true;
	BTIa.lastTime = "";
	BTIa.issueTime = itos((int)time(0));

	//check user has enough money for the bounty
	int iCash;
	HkGetCash(stows(BTIa.issuer), iCash);
	if (iCash < (stoi(BTIa.Cash) * stoi(BTIa.xTimes)))
	{
		PrintUserCmdText(iClientID, L"ERR Not enough cash for bounty.");
		return true;
	}
	HkAddCash((wchar_t*)Players.GetActiveCharacterName(iClientID), 0 - (stoi(BTIa.Cash) * stoi(BTIa.xTimes)));
	PrintUserCmdText(iClientID, L"Uploading to Neural Net...");
	mapBountyTargets[ToLower(wscName)] = BTIa;

	wstring PFwsTargetInfo;
	PFwsTargetInfo = L"Target: ";
	PFwsTargetInfo += ToLower(wscName);
	PFwsTargetInfo += L" Worth: ";
	PFwsTargetInfo += stows(BTIa.Cash);
	PFwsTargetInfo += L" Contracts Left: ";
	PFwsTargetInfo += stows(BTIa.xTimes);
	PFwsTargetInfo += L" Issuer: ";
	PFwsTargetInfo += stows(BTIa.issuer);
	PFwsTargetInfo += L" Issued: ";
	PFwsTargetInfo += stows(BTIa.issueTime);
	PrintUserCmdText(iClientID, PFwsTargetInfo);

	if (appendBountyCfg(BTIa))
	{
		ConPrint(L"cfg saved\n");
	}
	else
	{
		ConPrint(L"Err saving to cfg\n");
	}
	PrintUserCmdText(iClientID, L"OK");
	return true;
}
Ejemplo n.º 26
0
void LoadSettings()
{
	returncode = DEFAULT_RETURNCODE;

	string File_FLHook = "..\\exe\\flhook_plugins\\bountytracker.cfg";
	string File_FLHook_bounties = "..\\exe\\flhook_plugins\\bountytrackerbounties.cfg";
	int iLoaded = 0;

	INI_Reader ini;
	if (ini.open(File_FLHook.c_str(), false))
	{
		while (ini.read_header())
		{
			if (ini.is_header("config"))
			{
				while (ini.read_value())
				{
					if (ini.is_value("enabled"))
					{
						bPluginEnabled = ini.get_value_bool(0);
					}
					if (ini.is_value("CleanInterval"))
					{
						iCleanInterval = ini.get_value_int(0);
						conDebug(L"cleaning interval set to " + stows(itos(iCleanInterval)));
					}
					if (ini.is_value("BountyAge"))
					{
						iBountyAge = ini.get_value_int(0);
						conDebug(L"bounty age set to " + stows(itos(iBountyAge)));
						
					}
				}
			}
		}ini.close();
	}
	if (ini.open(File_FLHook_bounties.c_str(), false))
	{
		while (ini.read_header())
		{
			if (ini.is_header("bounty"))
			{
				while (ini.read_value())
				{
					if (ini.is_value("hit"))
					{
						string setTargetName = ini.get_value_string(0);
						wstring theTargetName = ToLower(stows(setTargetName));
						BTI.Char = ToLower(ini.get_value_string(0));
						BTI.Cash = ini.get_value_string(1);
						BTI.xTimes = ini.get_value_string(2);
						BTI.issuer = ToLower(ini.get_value_string(3));
						BTI.active = ini.get_value_bool(4);
						BTI.lastIssuer = ToLower(ini.get_value_string(5));
						BTI.lastTime = ini.get_value_string(6);
						BTI.issueTime = ini.get_value_string(7);
						mapBountyTargets[theTargetName] = BTI;
						++iLoaded;
					}
				}
			}
		}
		ini.close();
	}

	ConPrint(L"BOUNTYTRACKER: Loaded %u Bounties\n", iLoaded);
}
Ejemplo n.º 27
0
wstring HkGetSystemNickByID(uint iSystemID)
{
	char szSystemname[1024] = "";
	pub::GetSystemNickname(szSystemname, sizeof(szSystemname), iSystemID);
	return stows(szSystemname);
}
Ejemplo n.º 28
0
void __stdcall ShipDestroyed(DamageList *_dmg, DWORD *ecx, uint iKill)
{
	returncode = DEFAULT_RETURNCODE;
	if (iKill)
	{
		CShip *cship = (CShip*)ecx[4];
		//check the death was a player
		if (cship->is_player())
		{
			uint iDestroyedID = cship->GetOwnerPlayer();
			wstring wscDestroyedName = ToLower((wchar_t*)Players.GetActiveCharacterName(iDestroyedID));
			//check if they have a bounty
			BountyTargetInfo BTId = mapBountyTargets[wscDestroyedName];
			if (BTId.Char == wstos(wscDestroyedName) && stoi(BTId.xTimes) > 0 && BTId.active)
			{
				if (deleteBountyCfg(BTId))
				{
					///ConPrint(L"bounty removed from cfg\n");
				}
				else
				{
					ConPrint(L"BOUNTYTRACKER: Err removing from cfg. is server admin?\n");
				}
				// calls the killer the last one to damage the victim
				DamageList dmg;
				try { dmg = *_dmg; }
				catch (...) { return; }
				dmg = ClientInfo[iDestroyedID].dmgLast;

				//The killer's id
				uint iKillerID = HkGetClientIDByShip(dmg.get_inflictor_id());
				//The killer's name
				wstring wscKillerName = (wchar_t*)Players.GetActiveCharacterName(iKillerID);

				//check if player killed by ai
				if (stoi(wstos(HkGetAccountIDByClientID(iKillerID))) == -1)
				{
					///ConPrint(L"nevermind, ai got him");
					return;
				}
				if (iKillerID == iDestroyedID)
				{
					///ConPrint(L"killer and victim are the same");
					return;
				}
				if (ToLower(wscKillerName) == stows(BTId.issuer))
				{
					///ConPrint(L"killer was the issuer of the bounty");
					return;
				}
				// -1 to contracts left
				BTId.xTimes = itos(stoi(BTId.xTimes) - 1);
				if (stoi(BTId.xTimes) == 0)
				{
					//bounty has been fullfilled, clear all dataa
					BTId.active = false;
					BTId.Cash = "0";
					BTId.xTimes = "0";
					BTId.issuer = "n/a";
					BTId.lastTime = itos((int)time(0));
					BTId.issueTime = "0";
				}

				//upload into neural net
				mapBountyTargets[wscDestroyedName] = BTId;
				if (appendBountyCfg(BTId))
				{
					///ConPrint(L"cfg saved\n");
				}
				else
				{
					ConPrint(L"BOUNTYTRACKER: Err saving to cfg. is serevr admin?\n");
				}

				//Print Friendly Wide String TargetInfo
				wstring PFwsTargetInfo;
				PFwsTargetInfo = L"Target: ";
				PFwsTargetInfo += ToLower(wscDestroyedName);
				PFwsTargetInfo += L" Worth: ";
				PFwsTargetInfo += stows(BTId.Cash);
				PFwsTargetInfo += L" Contracts Left: ";
				PFwsTargetInfo += stows(BTId.xTimes);
				PFwsTargetInfo += L" Issuer: ";
				PFwsTargetInfo += stows(BTId.issuer);
				PFwsTargetInfo += L" Issued at: ";
				PFwsTargetInfo += stows(BTId.issueTime);

				//add bounty cash
				HkAddCash(wscKillerName, stoi(BTId.Cash));
				PrintUserCmdText(iKillerID, L"Successfully collected bounty on");
				PrintUserCmdText(iKillerID, PFwsTargetInfo);
				PrintUserCmdText(iKillerID, L"Alerting bounty issuer...");
				wstring IssuerMailMsg = L"Bounty Alert: " + wscKillerName + L" Has collected your bounty on " + wscDestroyedName + L". " + stows(BTId.xTimes) + L" Contracts remaining.";
				MailSend(stows(BTId.issuer), MSG_LOG, IssuerMailMsg);
				PrintUserCmdText(iKillerID, L"Saving record...");
				wstring KillerMailMsg = L"Bounty Alert: " + wscKillerName + L" Has collected a bounty on " + wscDestroyedName + L". " + stows(BTId.xTimes) + L" Contracts remaining.";
				MailSend(wscKillerName, MSG_LOG, KillerMailMsg);
				PrintUserCmdText(iKillerID, L"OK");
				return;
			}
			else
			{
				///ConPrint(L"bounty tracker found no name match, or no more contracts for name\n");//either the name didn't match, or they have exhaused the number of contracts left on them.
			}
		}
		else
		{
			///ConPrint(L"Bounty tracker found dead ai\n");//never mind, it's just an ai death
		}
	}
	return;
}
Ejemplo n.º 29
0
bool AdminCmd_ChangeSystem(uint iClientID, const wstring &wscCmd, const wstring &wscParam, const wchar_t *usage)
{
	wstring wscArg = ToLower(GetParam(wscParam, ' ', 0));
	//check master switch bruh
	if (!bPluginEnabled)
	{
		PrintUserCmdText(iClientID, L"ChangeSys is disabled.\n");
		return true;
	}
	if (wscArg.length()==0)
	{
		PrintUserCmdText(iClientID, L"ERR Incorrect Parameters <sys|list>");
		return true;
	}
	//check what the parameters are
	if (wcscmp(wscArg.c_str(), L"list") == 0)
	{
		//show list of systems
		PrintUserCmdText(iClientID, L"list of systems: ");
		/*for (vector<string>::iterator it = bPluginAllowedSystems.begin(); it != bPluginAllowedSystems.end(); ++it) 
		{
			PrintUserCmdText(iClientID, stows(*it));
		}*/
		PrintUserCmdText(iClientID, stows(bPluginAllowedSystemsFriendly));
		return true;
	}
	//assume player is trying to enter a system id
	uint ship;
	pub::Player::GetShip(iClientID, ship);
	if (!ship)
	{
		PrintUserCmdText(iClientID, L"ERR Not in space\n");
		return true;
	}
	
	//check if valid sys id from config vector
	if(find(bPluginAllowedSystems.begin(), bPluginAllowedSystems.end(), wstos(wscArg)) != bPluginAllowedSystems.end())
	{ 
		//its a match buddy!
		//do tha magic
		//get system id for server
		uint iTargetSystem = CreateID(wstos(wscArg).c_str());
		Vector pos;
		Matrix ornt;
		//get the pos and ornt of ship
		pub::SpaceObj::GetLocation(ship, pos, ornt);
		//move player
		SwitchSystem(iClientID, iTargetSystem, pos, ornt);
		PrintUserCmdText(iClientID, L"Moving to system: ");
		PrintUserCmdText(iClientID, wscArg.c_str());
		PrintUserCmdText(iClientID, L"OK\n");
		//done magic
	}
	else
	{
		//well f**k
		PrintUserCmdText(iClientID, L"ERR Invalid system id: ");
		PrintUserCmdText(iClientID, wscArg.c_str());
	}

	return true;
}
Ejemplo n.º 30
0
void Siege::SiegeGunDeploy(uint client, const wstring &args)
{
	// Abort processing if this is not a "heavy lifter"
	uint shiparch;
	pub::Player::GetShipID(client, shiparch);
	if (set_construction_shiparch != 0 && shiparch != set_construction_shiparch)
	{
		PrintUserCmdText(client, L"ERR Need deployment ship");
		return;
	}

	uint ship;
	pub::Player::GetShip(client, ship);
	if (!ship)
	{
		PrintUserCmdText(client, L"ERR Not in space");
		return;
	}

	// If the ship is moving, abort the processing.
	Vector dir1;
	Vector dir2;
	pub::SpaceObj::GetMotion(ship, dir1, dir2);
	if (dir1.x>5 || dir1.y>5 || dir1.z>5)
	{
		PrintUserCmdText(client, L"ERR Ship is moving");
		return;
	}

	int min = 100;
	int max = 5000;
	int randomsiegeint = min + (rand() % (int)(max - min + 1));

	string randomname = "Siege Cannon AX-" + randomsiegeint;

	// Check for conflicting base name
	if (GetPlayerBase(CreateID(PlayerBase::CreateBaseNickname(randomname).c_str())))
	{
		PrintUserCmdText(client, L"ERR Deployment error, please reiterate.");
		return;
	}

	// Check that the ship has the requires commodities.
	int hold_size;
	list<CARGO_INFO> cargo;
	HkEnumCargo((const wchar_t*)Players.GetActiveCharacterName(client), cargo, hold_size);
	for (map<uint, uint>::iterator i = construction_items.begin(); i != construction_items.end(); ++i)
	{
		bool material_available = false;
		uint good = i->first;
		uint quantity = i->second;
		for (list<CARGO_INFO>::iterator ci = cargo.begin(); ci != cargo.end(); ++ci)
		{
			if (ci->iArchID == good && ci->iCount >= (int)quantity)
			{
				material_available = true;
				pub::Player::RemoveCargo(client, ci->iID, quantity);
			}
		}
		if (material_available == false)
		{
			PrintUserCmdText(client, L"ERR Construction failed due to insufficient raw material.");
			for (i = construction_items.begin(); i != construction_items.end(); ++i)
			{
				const GoodInfo *gi = GoodList::find_by_id(i->first);
				if (gi)
				{
					PrintUserCmdText(client, L"|  %ux %s", i->second, HkGetWStringFromIDS(gi->iIDSName).c_str());
				}
			}
			return;
		}
	}

	wstring charname = (const wchar_t*)Players.GetActiveCharacterName(client);
	AddLog("NOTICE: Base created %s by %s (%s)",
		randomname.c_str(),
		wstos(charname).c_str(),
		wstos(HkGetAccountID(HkGetAccountByCharname(charname))).c_str());

	wstring password = L"hastesucks";
	wstring basename = stows(randomname);

	PlayerBase *newbase = new PlayerBase(client, password, basename);
	player_bases[newbase->base] = newbase;
	newbase->basetype = "siegegun";
	newbase->basesolar = "depot";
	newbase->baseloadout = "depot";
	newbase->defense_mode = 1;

	for (map<string, ARCHTYPE_STRUCT>::iterator iter = mapArchs.begin(); iter!=mapArchs.end(); iter++)
	{

		ARCHTYPE_STRUCT &thearch = iter->second;
		if (iter->first == newbase->basetype) 
		{					
			newbase->invulnerable = thearch.invulnerable;
			newbase->logic = thearch.logic;
		}
	}

	newbase->Spawn();
	newbase->Save();

	PrintUserCmdText(client, L"OK: Siege Cannon deployed");
	PrintUserCmdText(client, L"Default administration password is %s", password.c_str());
}