bool UserCmd_DropTag(uint iClientID, const wstring &wscCmd, const wstring &wscParam, const wchar_t *usage) { if (set_bCharnameTags) { // Indicate an error if the command does not appear to be formatted correctly // and stop processing but tell FLHook that we processed the command. if (wscParam.size()==0) { PrintUserCmdText(iClientID, L"ERR Invalid parameters"); PrintUserCmdText(iClientID, usage); return true; } wstring wscCharname = (const wchar_t*)Players.GetActiveCharacterName(iClientID); wstring tag = GetParam(wscParam, ' ', 0); wstring pass = GetParam(wscParam, ' ', 1); // If this tag is in use then reject the request. for (std::map<wstring, TAG_DATA>::iterator i = mapTagToPassword.begin(); i != mapTagToPassword.end(); ++i) { if (tag == i->second.tag && pass == i->second.master_password) { mapTagToPassword.erase(tag); SaveSettings(); PrintUserCmdText(iClientID, L"OK Tag dropped"); AddLog("NOTICE: Tag %s dropped by %s (%s)", wstos(tag).c_str(), wstos(wscCharname).c_str(), wstos(HkGetAccountIDByClientID(iClientID)).c_str()); return true; } } PrintUserCmdText(iClientID, L"ERR tag or master password are invalid"); return true; } return false; }
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; }
bool UserCmd_MakeTag(uint iClientID, const wstring &wscCmd, const wstring &wscParam, const wchar_t *usage) { if (set_bCharnameTags) { // Indicate an error if the command does not appear to be formatted correctly // and stop processing but tell FLHook that we processed the command. if (wscParam.size()==0) { PrintUserCmdText(iClientID, L"ERR Invalid parameters"); PrintUserCmdText(iClientID, usage); return true; } uint iBaseID; pub::Player::GetBase(iClientID, iBaseID); if (!iBaseID) { PrintUserCmdText(iClientID, L"ERR Not in base"); return true; } wstring tag = GetParam(wscParam, ' ', 0); wstring pass = GetParam(wscParam, ' ', 1); wstring description = GetParamToEnd(wscParam, ' ', 2); if (tag.size() < MIN_CHAR_TAG_LEN) { PrintUserCmdText(iClientID, L"ERR Tag too short"); PrintUserCmdText(iClientID, usage); return true; } if (!pass.size()) { PrintUserCmdText(iClientID, L"ERR Password not set"); PrintUserCmdText(iClientID, usage); return true; } if (!description.size()) { PrintUserCmdText(iClientID, L"ERR Description not set"); PrintUserCmdText(iClientID, usage); return true; } // If this tag is in use then reject the request. for (std::map<wstring, TAG_DATA>::iterator i = mapTagToPassword.begin(); i != mapTagToPassword.end(); ++i) { if (tag.find(i->second.tag)==0 || i->second.tag.find(tag)==0) { PrintUserCmdText(iClientID, L"ERR Tag already exists or conflicts with existing tag"); return true; } } // Save character and exit if kicked on save. wstring wscCharname = (const wchar_t*)Players.GetActiveCharacterName(iClientID); HkSaveChar(wscCharname); if (HkGetClientIdFromCharname(wscCharname)==-1) return false; int iCash; HK_ERROR err; if ((err = HkGetCash(wscCharname, iCash)) != HKE_OK) { PrintUserCmdText(iClientID, L"ERR "+HkErrGetText(err)); return true; } if (set_iMakeTagCost>0 && iCash<set_iMakeTagCost) { PrintUserCmdText(iClientID, L"ERR Insufficient credits"); return true; } HkAddCash(wscCharname, 0-set_iMakeTagCost); // TODO: Try to check if any player is using this tag mapTagToPassword[tag].tag = tag; mapTagToPassword[tag].master_password = pass; mapTagToPassword[tag].rename_password = L""; mapTagToPassword[tag].last_access = (uint)time(0); mapTagToPassword[tag].description = description; PrintUserCmdText(iClientID, L"Created faction tag %s with master password %s", tag.c_str(), pass.c_str()); AddLog("NOTICE: Tag %s created by %s (%s)", wstos(tag).c_str(), wstos(wscCharname).c_str(), wstos(HkGetAccountIDByClientID(iClientID)).c_str()); SaveSettings(); return true; } return false; }