bool PlayerInfo::UserCmd_ShowInfo(uint iClientID, const wstring &wscCmd, const wstring &wscParam, const wchar_t *usage) { const wchar_t *wszTargetName = 0; const wstring &wscCommand = GetParam(wscParam, ' ', 0); if (wscCommand == L"me") { wszTargetName = Players.GetActiveCharacterName(iClientID); } else { uint iShip; pub::Player::GetShip(iClientID, iShip); uint iTargetShip; pub::SpaceObj::GetTarget(iShip, iTargetShip); uint iTargetClientID = HkGetClientIDByShip(iTargetShip); if (HkIsValidClientID(iTargetClientID)) wszTargetName = Players.GetActiveCharacterName(iTargetClientID); } if (!wszTargetName) { PrintUserCmdText(iClientID, L"ERR No target"); return true; } string scFilePath = GetUserFilePath(wszTargetName, "-info.ini"); wstring wscPlayerInfo = L"<RDL><PUSH/>"; for (int i = 1; i <= MAX_PARAGRAPHS; i++) { wstring wscXML = IniGetLongWS(scFilePath, "Info", itos(i), L""); if (wscXML.length()) wscPlayerInfo += L"<TEXT>" + wscXML + L"</TEXT><PARA/><PARA/>"; } wstring wscXML = IniGetLongWS(scFilePath, "Info", "AdminNote", L""); if (wscXML.length()) wscPlayerInfo += L"<TEXT>" + wscXML + L"</TEXT><PARA/><PARA/>"; wscPlayerInfo += L"<POP/></RDL>"; if (wscPlayerInfo.length() < 30) { PrintUserCmdText(iClientID, L"ERR No information available"); return true; } HkChangeIDSString(iClientID, RSRCID_PLAYERINFO_TITLE, wszTargetName); HkChangeIDSString(iClientID, RSRCID_PLAYERINFO_TEXT, wscPlayerInfo); FmtStr caption(0, 0); caption.begin_mad_lib(RSRCID_PLAYERINFO_TITLE); caption.end_mad_lib(); FmtStr message(0, 0); message.begin_mad_lib(RSRCID_PLAYERINFO_TEXT); message.end_mad_lib(); pub::Player::PopUpDialog(iClientID, caption, message, POPUPDIALOG_BUTTONS_CENTER_OK); return true; }
bool AP::AlleyCmd_Help(uint iClientID, const wstring &wscCmd, const wstring &wscParam, const wchar_t *usage) { wstring wscCharname = (const wchar_t*) Players.GetActiveCharacterName(iClientID); wstring rights; bool isAngel = false; // is it an admin if (HkGetAdmin((const wchar_t*)Players.GetActiveCharacterName(iClientID), rights) == HKE_OK) { //PrintUserCmdText(iClientID, L"You are a platinum level Admin. Use $help for a list of available commands."); isAngel = true; } // is it an angel list<wstring>::iterator iter = angels.begin(); while (iter != angels.end()) { if (*iter == wscCharname) isAngel = true; iter++; } if (isAngel == false) { PrintUserCmdText(iClientID, L"You are not an Angel. You will now be permabanned."); return true; } //PrintUserCmdText(iClientID, L"You are a platinum level Angel. Use $help for a list of available commands."); PrintUserCmdText(iClientID, L"The following commands are available to platinum level Angels:"); PrintUserCmdText(iClientID, L"Command: $chase <charname> - Teleports you through bob to the desired player"); return true; }
bool UserCmd_BountyHelp(uint iClientID, const wstring &wscCmd, const wstring &wscParam, const wchar_t *usage) { PrintUserCmdText(iClientID, L"Usage: /bounty add <target> <cash> <xContracts>\n"); PrintUserCmdText(iClientID, L"Usage: /bounty addto <target> <cash>\n"); PrintUserCmdText(iClientID, L"Usage: /bounty view <target>\n"); return true; }
/** Process a set the move char code command */ bool Rename::UserCmd_SetMoveCharCode(uint iClientID, const wstring &wscCmd, const wstring &wscParam, const wchar_t *usage) { // Don't indicate an error if moving is disabled. if (!set_bEnableMoveChar) return false; if (wscParam.size()==0) { PrintUserCmdText(iClientID, L"ERR Invalid parameters"); PrintUserCmdText(iClientID, usage); return true; } wstring wscCharname = (const wchar_t*) Players.GetActiveCharacterName(iClientID); string scFile; if (!GetUserFilePath(scFile, wscCharname, "-movechar.ini")) { PrintUserCmdText(iClientID, L"ERR Character does not exist"); return true; } wstring wscCode = Trim(GetParam(wscParam, L' ', 0)); if (wscCode==L"none") { IniWriteW(scFile, "Settings", "Code", L""); PrintUserCmdText(iClientID, L"OK Movechar code cleared"); } else { IniWriteW(scFile, "Settings", "Code", wscCode); PrintUserCmdText(iClientID, L"OK Movechar code set to "+wscCode); } return true; }
void __stdcall GFGoodSell(const struct SGFGoodSellInfo &gsi, unsigned int iClientID) { returncode = DEFAULT_RETURNCODE; uint iBase; pub::Player::GetBase(iClientID, iBase); multimap<uint, CARGO_MISSION>::iterator start = set_mapCargoMissions.lower_bound(iBase); multimap<uint, CARGO_MISSION>::iterator end = set_mapCargoMissions.upper_bound(iBase); for (; start != end; ++start) { if (start->second.item == gsi.iArchID) { if (start->second.curr_amount < start->second.required_amount) { int needed = start->second.required_amount - start->second.curr_amount; if (needed > gsi.iCount) { start->second.curr_amount += gsi.iCount; needed = start->second.required_amount - start->second.curr_amount; PrintUserCmdText(iClientID, L"%d units remaining to complete mission objective", needed); } else { PrintUserCmdText(iClientID, L"Mission objective completed",needed); } } } } }
// Make tag password bool UserCmd_SetTagPass(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 tag = GetParam(wscParam, ' ', 0); wstring master_password = GetParam(wscParam, ' ', 1); wstring rename_password = GetParam(wscParam, ' ', 2); // 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 && master_password == i->second.master_password) { i->second.rename_password = rename_password; SaveSettings(); PrintUserCmdText(iClientID, L"OK Created rename password %s for tag %s", rename_password.c_str(), tag.c_str()); return true; } } PrintUserCmdText(iClientID, L"ERR tag or master password are invalid"); return true; } return false; }
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; }
/** Process a set cash code command */ bool GiveCash::UserCmd_SetCashCode(uint iClientID, const wstring &wscCmd, const wstring &wscParam, const wchar_t *usage) { wstring wscCharname = (const wchar_t*) Players.GetActiveCharacterName(iClientID); string scFile; if (!GetUserFilePath(scFile, wscCharname, "-givecash.ini")) return true; wstring wscCode = GetParam(wscParam, L' ', 0); if (!wscCode.size()) { PrintUserCmdText(iClientID, L"ERR Invalid parameters"); PrintUserCmdText(iClientID, usage); } else if (wscCode==L"none") { IniWriteW(scFile, "Settings", "Code", L""); PrintUserCmdText(iClientID, L"OK Account code cleared"); } else { IniWriteW(scFile, "Settings", "Code", wscCode); PrintUserCmdText(iClientID, L"OK Account code set to "+wscCode); } return true; }
void AP::BaseEnter_AFTER(uint base, uint iClientID) { //PrintUserCmdText(iClientID, L"Base ID: %08x", base); // is it a base of terror if (bastillebase.find(base) != bastillebase.end()) { PrintUserCmdText(iClientID, L"You are in the prison system for violating the server rules."); PrintUserCmdText(iClientID, L"Head to the Sanction Notices section of the forums for more information."); PrintUserCmdText(iClientID, L"If there is no sanction for this ship, contact the administration team on the forums."); PrintUserCmdText(iClientID, L"Forums: http://www.discoverygc.com/forums/"); } }
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; }
void SwitchSystem(uint iClientID, uint system, Vector pos, Matrix ornt) { mapDeferredJumps[iClientID].system = system; mapDeferredJumps[iClientID].pos = pos; mapDeferredJumps[iClientID].ornt = ornt; // Force a launch to put the ship in the right location in the current system so that // when the change system command arrives (hopefully) a fraction of a second later // the ship will appear at the right location. HkRelocateClient(iClientID, pos, ornt); // Send the jump command to the client. The client will send a system switch out complete // event which we intercept to set the new starting positions. PrintUserCmdText(iClientID, L" ChangeSys %u", system); }
/** Show five messages from the specified starting position. */ void MailShow(const wstring &wscCharname, const string &scExtension, int iFirstMsg) { // Make sure the character is logged in. uint iClientID = HkGetClientIdFromCharname(wscCharname); if (iClientID==-1) return; // Get the target player's message file. string scFilePath = GetUserFilePath(wscCharname, scExtension); if (scFilePath.length()==0) return; int iLastMsg = iFirstMsg; for (int iMsgSlot = iFirstMsg, iMsgCount = 0; iMsgSlot<MAX_MAIL_MSGS && iMsgCount<5; iMsgSlot++, iMsgCount++) { wstring wscTmpMsg = IniGetWS(scFilePath, "Msgs", itos(iMsgSlot), L""); if (wscTmpMsg.length()==0) break; PrintUserCmdText(iClientID, L"#%02d %s", iMsgSlot, wscTmpMsg.c_str()); IniWrite(scFilePath, "MsgsRead", itos(iMsgSlot), "yes"); iLastMsg = iMsgSlot; } PrintUserCmdText(iClientID, L"Viewing #%02d-#%02d of %02d messages", iFirstMsg, iLastMsg, MailCount(wscCharname, scExtension)); }
void __stdcall PlayerLaunch_AFTER(unsigned int ship, unsigned int client) { returncode = DEFAULT_RETURNCODE; if (transferFlags[client] == CLIENT_STATE_TRANSFER) { if (!ValidateCargo(client)) { PrintUserCmdText(client, STR_INFO2); return; } transferFlags[client] = CLIENT_STATE_NONE; MoveClient(client, set_iTargetBaseID); return; } if (transferFlags[client] == CLIENT_STATE_RETURN) { if (!ValidateCargo(client)) { PrintUserCmdText(client, STR_INFO2); return; } transferFlags[client] = CLIENT_STATE_NONE; unsigned int returnPoint = ReadReturnPointForClient(client); if (!returnPoint) return; MoveClient(client, returnPoint); HookExt::IniSetI(client, "conn.retbase", 0); return; } }
/** Check for new or unread messages. */ void MailCheckLog(const wstring &wscCharname, const string &scExtension) { // Make sure the character is logged in. uint iClientID = HkGetClientIdFromCharname(wscCharname); if (iClientID==-1) return; // Get the target player's message file. string scFilePath = GetUserFilePath(wscCharname, scExtension); if (scFilePath.length()==0) return; // If there are unread messaging then inform the player int iUnreadMsgs = MailCountUnread(wscCharname, scExtension); if (iUnreadMsgs>0) { PrintUserCmdText(iClientID, L"You have %d unread messages. Type /mail to see your messages", iUnreadMsgs); } }
wstring GetLocation(unsigned int client) { uint iSystemID = 0; uint iShip = 0; pub::Player::GetSystem(client, iSystemID); pub::Player::GetShip(client, iShip); if (!iSystemID || !iShip) { PrintUserCmdText(client, L"ERR Not in space"); return false; } Vector pos; Matrix rot; pub::SpaceObj::GetLocation(iShip, pos, rot); float scale = 1.0; const Universe::ISystem *iSystem = Universe::get_system(iSystemID); if (iSystem) scale = iSystem->NavMapScale; float fGridsize = 34000.0f / scale; int gridRefX = (int)((pos.x + (fGridsize * 5)) / fGridsize) - 1; int gridRefZ = (int)((pos.z + (fGridsize * 5)) / fGridsize) - 1; wstring wscXPos = L"X"; if (gridRefX >= 0 && gridRefX < 8) { wchar_t* gridXLabel[] = {L"A", L"B", L"C", L"D", L"E", L"F", L"G", L"H"}; wscXPos = gridXLabel[gridRefX]; } wstring wscZPos = L"X"; if (gridRefZ >= 0 && gridRefZ < 8) { wchar_t* gridZLabel[] = {L"1", L"2", L"3", L"4", L"5", L"6", L"7", L"8"}; wscZPos = gridZLabel[gridRefZ]; } wchar_t wszCurrentLocation[100]; _snwprintf(wszCurrentLocation, sizeof(wszCurrentLocation), L"%s-%s", wscXPos.c_str(), wscZPos.c_str()); return wszCurrentLocation; }
/** Process a show cash command **/ bool GiveCash::UserCmd_ShowCash(uint iClientID, const wstring &wscCmd, const wstring &wscParam, const wchar_t *usage) { // The last error. HK_ERROR err; // Get the current character name wstring wscCharname = (const wchar_t*) Players.GetActiveCharacterName(iClientID); // Get the parameters from the user command. wstring wscTargetCharname = GetParam(wscParam, L' ', 0); wstring wscCode = GetParam(wscParam, L' ', 1); if (!wscTargetCharname.length() || !wscCode.length()) { PrintUserCmdText(iClientID, L"ERR Invalid parameters"); PrintUserCmdText(iClientID, usage); return true; } CAccount *acc=HkGetAccountByCharname(wscTargetCharname); if (acc==0) { PrintUserCmdText(iClientID, L"ERR char does not exist"); return true; } string scFile; if (!GetUserFilePath(scFile, wscTargetCharname, "-givecash.ini")) return true; wstring wscTargetCode = IniGetWS(scFile, "Settings", "Code", L""); if (!wscTargetCode.length() || wscTargetCode!=wscCode) { PrintUserCmdText(iClientID, L"ERR cash account access denied"); return true; } int iCash = 0; if ((err = HkGetCash(wscTargetCharname, iCash)) != HKE_OK) { PrintUserCmdText(iClientID, L"ERR "+HkErrGetText(err)); return true; } PrintUserCmdText(iClientID, L"OK Account "+wscTargetCharname+L" has " + ToMoneyStr(iCash) + L" credits"); return true; }
bool UserCmd_Process(uint iClientID, const wstring &wscCmd) { returncode = DEFAULT_RETURNCODE; wstring wscCmdLineLower = ToLower(wscCmd); // If the chat string does not match the USER_CMD then we do not handle the // command, so let other plugins or FLHook kick in. We require an exact match for (uint i = 0; (i < sizeof(UserCmds) / sizeof(USERCMD)); i++) { if (wscCmdLineLower.find(UserCmds[i].wszCmd) == 0) { // Extract the parameters string from the chat string. It should // be immediately after the command and a space. wstring wscParam = L""; if (wscCmd.length() > wcslen(UserCmds[i].wszCmd)) { if (wscCmd[wcslen(UserCmds[i].wszCmd)] != ' ') continue; wscParam = wscCmd.substr(wcslen(UserCmds[i].wszCmd) + 1); } // Dispatch the command to the appropriate processing function. if (UserCmds[i].proc(iClientID, wscCmd, wscParam, UserCmds[i].usage)) { // We handled the command tell FL hook to stop processing this // chat string. returncode = SKIPPLUGINS_NOFUNCTIONCALL; // we handled the command, return immediatly return true; } else { PrintUserCmdText(iClientID, UserCmds[i].usage); return true; } } } return false; }
/// Print message to all ships within the specific number of meters of the player. void PrintLocalUserCmdText(uint client, const wstring &wscMsg, float fDistance) { uint iShip; pub::Player::GetShip(client, iShip); Vector pos; Matrix rot; pub::SpaceObj::GetLocation(iShip, pos, rot); uint iSystem; pub::Player::GetSystem(client, iSystem); // For all players in system... struct PlayerData *pPD = 0; while(pPD = Players.traverse_active(pPD)) { // Get the this player's current system and location in the system. uint client2 = HkGetClientIdFromPD(pPD); uint iSystem2 = 0; pub::Player::GetSystem(client2, iSystem2); if (iSystem != iSystem2) continue; uint iShip2; pub::Player::GetShip(client2, iShip2); Vector pos2; Matrix rot2; pub::SpaceObj::GetLocation(iShip2, pos2, rot2); // Is player within the specified range of the sending char. if (HkDistance3D(pos, pos2) > fDistance) continue; PrintUserCmdText(client2, L"%s", wscMsg.c_str()); } }
bool PlayerInfo::UserCmd_SetInfo(uint iClientID, const wstring &wscCmd, const wstring &wscParam, const wchar_t *usage) { uint iPara = ToInt(GetParam(wscParam, ' ', 0)); const wstring &wscCommand = GetParam(wscParam, ' ', 1); const wstring &wscMsg = GetParamToEnd(wscParam, ' ', 2); string scFilePath = GetUserFilePath(Players.GetActiveCharacterName(iClientID), "-info.ini"); if (scFilePath.length()==0) return false; if (iPara > 0 && iPara <= MAX_PARAGRAPHS && wscCommand == L"a") { int length = CurrLength(scFilePath) + wscMsg.length(); if (length > MAX_CHARACTERS) { PrintUserCmdText(iClientID, L"ERR Too many characters. Limit is %d", MAX_CHARACTERS); return false; } wstring wscNewMsg = IniGetLongWS(scFilePath, "Info", itos(iPara), L"") + XMLText(wscMsg); IniWriteW(scFilePath, "Info", itos(iPara), wscNewMsg); PrintUserCmdText(iClientID, L"OK %d/%d characters used", length, MAX_CHARACTERS); } else if (iPara > 0 && iPara <= MAX_PARAGRAPHS && wscCommand == L"d") { IniWriteW(scFilePath, "Info", itos(iPara), L""); PrintUserCmdText(iClientID, L"OK"); } else { PrintUserCmdText(iClientID, L"ERR Invalid parameters"); PrintUserCmdText(iClientID, L"/setinfo <paragraph> <command> <text>"); PrintUserCmdText(iClientID, L"| <paragraph> The paragraph number in the range 1-%d", MAX_PARAGRAPHS); PrintUserCmdText(iClientID, L"| <command> The command to perform on the paragraph, 'a' for append, 'd' for delete"); } return true; }
void UserCmd_Help(uint iClientID, const wstring &wscParam) { returncode = DEFAULT_RETURNCODE; PrintUserCmdText(iClientID, L"Change SyS"); }
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; }
/** Move a character from a remote account into this one. */ bool Rename::UserCmd_MoveChar(uint iClientID, const wstring &wscCmd, const wstring &wscParam, const wchar_t *usage) { HK_ERROR err; // Don't indicate an error if moving is disabled. if (!set_bEnableMoveChar) return false; // 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; } // Get the target account directory. string scFile; wstring wscMovingCharname = Trim(GetParam(wscParam, L' ', 0)); if (!GetUserFilePath(scFile, wscMovingCharname, "-movechar.ini")) { PrintUserCmdText(iClientID, L"ERR Character does not exist"); return true; } // Check the move char code. wstring wscCode = Trim(GetParam(wscParam, L' ', 1)); wstring wscTargetCode = IniGetWS(scFile, "Settings", "Code", L""); if (!wscTargetCode.length() || wscTargetCode!=wscCode) { PrintUserCmdText(iClientID, L"ERR Move character access denied"); return true; } // Get the character name for this connection. wstring wscCharname = (const wchar_t*)Players.GetActiveCharacterName(iClientID); for (map<wstring, LockedShipsStruct>::iterator i = MapLockedShips.begin(); i != MapLockedShips.end(); ++i) { if ((i->first == wscMovingCharname) && (i->second.LockLevel > 0)) { PrintUserCmdText(iClientID, L"ERR This ship is locked. The FBI has been notified."); wstring spurdoip; HkGetPlayerIP(iClientID, spurdoip); AddLog("SHIPLOCK: Attempt to movechar locked ship %s from IP %s", wstos(wscMovingCharname).c_str(), wstos(spurdoip).c_str()); ConPrint(L"SHIPLOCK: Attempt to movechar locked ship %s from IP %s\n", wscMovingCharname.c_str(), spurdoip.c_str()); return true; } } // Prevent ships from banned accounts from being moved. if (IsBanned(wscMovingCharname)) { PrintUserCmdText(iClientID, L"ERR not permitted"); return true; } // Saving the characters forces an anti-cheat checks and fixes // up a multitude of other problems. HkSaveChar(wscCharname); HkSaveChar(wscMovingCharname); // Read the current number of credits for the player // and check that the character has enough cash. int iCash = 0; if ((err = HkGetCash(wscCharname, iCash)) != HKE_OK) { PrintUserCmdText(iClientID, L"ERR "+HkErrGetText(err)); return true; } if (set_iMoveCost>0 && iCash<set_iMoveCost) { PrintUserCmdText(iClientID, L"ERR Insufficient credits"); return true; } // Check there is room in this account. CAccount *acc=Players.FindAccountFromClientID(iClientID); if (acc->iNumberOfCharacters >= 7) { PrintUserCmdText(iClientID, L"ERR Too many characters in account"); return true; } // Copy character file into this account with a temp name. char szDataPath[MAX_PATH]; GetUserDataPath(szDataPath); string scAcctPath = string(szDataPath) + "\\Accts\\MultiPlayer\\"; wstring wscDir; wstring wscSourceDir; wstring wscSourceFile; if ((err = HkGetAccountDirName(wscCharname, wscDir))!=HKE_OK) { PrintUserCmdText(iClientID, L"ERR "+HkErrGetText(err)); return true; } if ((err = HkGetAccountDirName(wscMovingCharname, wscSourceDir))!=HKE_OK) { PrintUserCmdText(iClientID, L"ERR "+HkErrGetText(err)); return true; } if ((err = HkGetCharFileName(wscMovingCharname, wscSourceFile))!=HKE_OK) { PrintUserCmdText(iClientID, L"ERR "+HkErrGetText(err)); return true; } // Remove cash if we're charging for it. if (set_iMoveCost>0) HkAddCash(wscCharname, 0-set_iMoveCost); HkSaveChar(wscCharname); // Schedule the move MOVE o; o.wscDestinationCharname = wscCharname; o.wscMovingCharname = wscMovingCharname; o.scSourceFile = scAcctPath + wstos(wscSourceDir) + "\\" + wstos(wscSourceFile) + ".fl"; o.scDestFile = scAcctPath + wstos(wscDir) + "\\" + wstos(wscSourceFile) + ".fl"; o.scDestFileTemp = scAcctPath + wstos(wscDir) + "\\" + wstos(wscSourceFile) + ".fl.moving"; pendingMoves.push_back(o); // Delete the move code ::DeleteFileA(scFile.c_str()); // Kick HkKickReason(o.wscDestinationCharname, L"Moving character, please wait 10 seconds before reconnecting"); HkKickReason(o.wscMovingCharname, L"Moving character, please wait 10 seconds before reconnecting"); return true; }
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 AP::AlleyCmd_Chase(uint iClientID, const wstring &wscCmd, const wstring &wscParam, const wchar_t *usage) { wstring wscCharname = (const wchar_t*) Players.GetActiveCharacterName(iClientID); wstring rights; bool isAngel = false; // is it an admin if (HkGetAdmin((const wchar_t*)Players.GetActiveCharacterName(iClientID), rights) == HKE_OK) { //PrintUserCmdText(iClientID, L"You are a platinum level Admin. Use $help for a list of available commands."); isAngel = true; } // is it an angel list<wstring>::iterator iter = angels.begin(); while (iter != angels.end()) { if (*iter == wscCharname) isAngel = true; iter++; } if (isAngel == false) { PrintUserCmdText(iClientID, L"You are not an Angel. You will now be permabanned."); return true; } wstring wscTargetCharname = GetParam(wscParam, ' ', 0); if (!wscTargetCharname.length()) { PrintUserCmdText(iClientID, L"ERR Invalid parameters"); PrintUserCmdText(iClientID, usage); return true; } HKPLAYERINFO adminPlyr; if (HkGetPlayerInfo(wscCharname, adminPlyr, false)!=HKE_OK) { PrintUserCmdText(iClientID, L"ERR Not in space\n"); return true; } HKPLAYERINFO targetPlyr; if (HkGetPlayerInfo(wscTargetCharname, targetPlyr, false)!=HKE_OK || targetPlyr.iShip==0) { PrintUserCmdText(iClientID, L"ERR Player not found or not in space\n"); return true; } Vector pos; Matrix ornt; pub::SpaceObj::GetLocation(targetPlyr.iShip, pos, ornt); pos.y += 100; PrintUserCmdText(iClientID, L"Jump to system=%s x=%0.0f y=%0.0f z=%0.0f\n", targetPlyr.wscSystem.c_str(), pos.x, pos.y, pos.z); SwitchSystem(adminPlyr.iClientID, targetPlyr.iSystem, pos, ornt); return true; }
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; }
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()); }
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; }
/** Process a draw cash command **/ bool GiveCash::UserCmd_DrawCash(uint iClientID, const wstring &wscCmd, const wstring &wscParam, const wchar_t *usage) { // The last error. HK_ERROR err; // Get the current character name wstring wscCharname = (const wchar_t*) Players.GetActiveCharacterName(iClientID); // Get the parameters from the user command. wstring wscTargetCharname = GetParam(wscParam, L' ', 0); wstring wscCode = GetParam(wscParam, L' ', 1); wstring wscCash = GetParam(wscParam, L' ', 2); wscCash = ReplaceStr(wscCash, L".", L""); wscCash = ReplaceStr(wscCash, L",", L""); wscCash = ReplaceStr(wscCash, L"$", L""); int cash = ToInt(wscCash); if (!wscTargetCharname.length() || !wscCode.length() || cash<=0) { PrintUserCmdText(iClientID, L"ERR Invalid parameters"); PrintUserCmdText(iClientID, usage); return true; } CAccount *iTargetAcc=HkGetAccountByCharname(wscTargetCharname); if (iTargetAcc==0) { PrintUserCmdText(iClientID, L"ERR char does not exist"); return true; } int secs = 0; HkGetOnLineTime(wscTargetCharname, secs); if (secs<set_iMinTime) { PrintUserCmdText(iClientID, L"ERR insufficient time online"); return true; } if (InBlockedSystem(wscCharname) || InBlockedSystem(wscTargetCharname)) { PrintUserCmdText(iClientID, L"ERR cash transfer blocked"); return true; } string scFile; if (!GetUserFilePath(scFile, wscTargetCharname, "-givecash.ini")) return true; wstring wscTargetCode = IniGetWS(scFile, "Settings", "Code", L""); if (!wscTargetCode.length() || wscTargetCode!=wscCode) { PrintUserCmdText(iClientID, L"ERR cash account access denied"); return true; } if (cash<set_iMinTransfer || cash<0) { PrintUserCmdText(iClientID, L"ERR Transfer too small, minimum transfer "+ToMoneyStr(set_iMinTransfer)+L" credits"); return true; } int tCash = 0; if ((err = HkGetCash(wscTargetCharname, tCash)) != HKE_OK) { PrintUserCmdText(iClientID, L"ERR "+HkErrGetText(err)); return true; } if (tCash<cash) { PrintUserCmdText(iClientID, L"ERR Insufficient credits"); return true; } // Check the adding this cash to this player will not // exceed the maximum ship value. float fTargetValue = 0.0f; if (HKGetShipValue(wscCharname, fTargetValue) != HKE_OK) { PrintUserCmdText(iClientID, L"ERR "+HkErrGetText(err)); return true; } if ((fTargetValue + cash) > 2000000000.0f) { PrintUserCmdText(iClientID, L"ERR Transfer will exceed credit limit"); return true; } // Calculate the new cash int iExpectedCash = 0; if ((err = HkGetCash(wscCharname, iExpectedCash)) != HKE_OK) { PrintUserCmdText(iClientID, L"ERR "+HkErrGetText(err)); return true; } iExpectedCash += cash; // Do an anticheat check on the receiving ship first. if (HkAntiCheat(iClientID) != HKE_OK) { PrintUserCmdText(iClientID, L"ERR Transfer failed"); AddLog("NOTICE: Possible cheating when drawing %s credits from %s (%s) to %s (%s)", wstos(ToMoneyStr(cash)).c_str(), wstos(wscTargetCharname).c_str(), wstos(HkGetAccountID(HkGetAccountByCharname(wscTargetCharname))).c_str(), wstos(wscCharname).c_str(), wstos(HkGetAccountID(HkGetAccountByCharname(wscCharname))).c_str()); return true; } HkSaveChar(iClientID); uint targetClientId = HkGetClientIdFromCharname(wscTargetCharname); if (targetClientId != -1) { if (ClientInfo[iClientID].iTradePartner || ClientInfo[targetClientId].iTradePartner) { PrintUserCmdText(iClientID, L"ERR Trade window open"); AddLog("NOTICE: Trade window open when drawing %s credits from %s (%s) to %s (%s) %u %u", wstos(ToMoneyStr(cash)).c_str(), wstos(wscTargetCharname).c_str(), wstos(HkGetAccountID(HkGetAccountByCharname(wscTargetCharname))).c_str(), wstos(wscCharname).c_str(), wstos(HkGetAccountID(HkGetAccountByCharname(wscCharname))).c_str(), iClientID, targetClientId); return true; } } // Remove cash from target character if ((err = HkAddCash(wscTargetCharname, 0-cash)) != HKE_OK) { PrintUserCmdText(iClientID, L"ERR "+HkErrGetText(err)); return true; } if (targetClientId!=-1 && !HkIsInCharSelectMenu(targetClientId)) { if (HkAntiCheat(targetClientId) != HKE_OK) { PrintUserCmdText(iClientID, L"ERR Transfer failed"); AddLog("NOTICE: Possible cheating when drawing %s credits from %s (%s) to %s (%s)", wstos(ToMoneyStr(cash)).c_str(), wstos(wscTargetCharname).c_str(), wstos(HkGetAccountID(HkGetAccountByCharname(wscTargetCharname))).c_str(), wstos(wscCharname).c_str(), wstos(HkGetAccountID(HkGetAccountByCharname(wscCharname))).c_str()); return true; } HkSaveChar(targetClientId); } // Add cash to this player if ((err = HkAddCash(wscCharname, cash)) != HKE_OK) { PrintUserCmdText(iClientID, L"ERR "+HkErrGetText(err)); return true; } if (HkAntiCheat(iClientID) != HKE_OK) { PrintUserCmdText(iClientID, L"ERR Transfer failed"); AddLog("NOTICE: Possible cheating when drawing %s credits from %s (%s) to %s (%s)", wstos(ToMoneyStr(cash)).c_str(), wstos(wscTargetCharname).c_str(), wstos(HkGetAccountID(HkGetAccountByCharname(wscTargetCharname))).c_str(), wstos(wscCharname).c_str(), wstos(HkGetAccountID(HkGetAccountByCharname(wscCharname))).c_str()); return true; } HkSaveChar(iClientID); // Check that receiving player has the correct ammount of cash. int iCurrCash; if ((err = HkGetCash(wscCharname, iCurrCash)) != HKE_OK || iCurrCash != iExpectedCash) { AddLog("ERROR: Cash transfer error when drawing %s credits from %s (%s) to %s (%s) current %s credits expected %s credits ", wstos(ToMoneyStr(cash)).c_str(), wstos(wscTargetCharname).c_str(), wstos(HkGetAccountID(HkGetAccountByCharname(wscTargetCharname))).c_str(), wstos(wscCharname).c_str(), wstos(HkGetAccountID(HkGetAccountByCharname(wscCharname))).c_str(), wstos(ToMoneyStr(iCurrCash)).c_str(), wstos(ToMoneyStr(iExpectedCash)).c_str()); PrintUserCmdText(iClientID, L"ERR Transfer failed"); } // If the target player is online then send them a message saying // telling them that they've received transfered cash. wstring msg = L"You have transferred " + ToMoneyStr(cash) + L" credits to " + wscCharname; if (targetClientId!=-1 && !HkIsInCharSelectMenu(targetClientId)) { PrintUserCmdText(targetClientId, L"%s", msg.c_str()); } // Otherwise we assume that the character is offline so we record an entry // in the character's givecash.ini. When they come online we inform them // of the transfer. The ini is cleared when ever the character logs in. else { LogTransfer(wscTargetCharname, msg); } AddLog("NOTICE: Draw %s credits from %s (%s) to %s (%s)", wstos(ToMoneyStr(cash)).c_str(), wstos(wscTargetCharname).c_str(), wstos(HkGetAccountID(HkGetAccountByCharname(wscTargetCharname))).c_str(), wstos(wscCharname).c_str(), wstos(HkGetAccountID(HkGetAccountByCharname(wscCharname))).c_str()); // A friendly message explaining the transfer. msg = GetTimeString(set_bLocalTime) + L": You have drawn " + ToMoneyStr(cash) + L" credits from " + wscTargetCharname; PrintUserCmdText(iClientID, L"%s", msg.c_str()); return true; }
bool UserCmd_Process(uint client, const wstring &cmd) { returncode = DEFAULT_RETURNCODE; if (!cmd.compare(L"/conn")) { // Prohibit jump if in a restricted system or in the target system uint system = 0; pub::Player::GetSystem(client, system); if (system == set_iRestrictedSystemID || system == set_iTargetSystemID || GetCustomBaseForClient(client)) { PrintUserCmdText(client, L"ERR Cannot use command in this system or base"); return true; } if (!IsDockedClient(client)) { PrintUserCmdText(client, STR_INFO1); return true; } if (!ValidateCargo(client)) { PrintUserCmdText(client, STR_INFO2); return true; } StoreReturnPointForClient(client); PrintUserCmdText(client, L"Redirecting undock to Connecticut."); transferFlags[client] = CLIENT_STATE_TRANSFER; return true; } else if (!cmd.compare(L"/return")) { if (!ReadReturnPointForClient(client)) { PrintUserCmdText(client, L"No return possible"); return true; } if (!IsDockedClient(client)) { PrintUserCmdText(client, STR_INFO1); return true; } if (!CheckReturnDock(client, set_iTargetBaseID)) { PrintUserCmdText(client, L"Not in correct base"); return true; } if (!ValidateCargo(client)) { PrintUserCmdText(client, STR_INFO2); return true; } PrintUserCmdText(client, L"Redirecting undock to previous base"); transferFlags[client] = CLIENT_STATE_RETURN; return true; } return false; }
/** Process a give cash command */ bool GiveCash::UserCmd_GiveCash(uint iClientID, const wstring &wscCmd, const wstring &wscParam, const wchar_t *usage) { // The last error. HK_ERROR err; // Get the current character name wstring wscCharname = (const wchar_t*) Players.GetActiveCharacterName(iClientID); // Get the parameters from the user command. wstring wscTargetCharname = GetParam(wscParam, L' ', 0); wstring wscCash = GetParam(wscParam, L' ', 1); wstring wscAnon = GetParam(wscParam, L' ', 2); wscCash = ReplaceStr(wscCash, L".", L""); wscCash = ReplaceStr(wscCash, L",", L""); wscCash = ReplaceStr(wscCash, L"$", L""); int cash = ToInt(wscCash); if ((!wscTargetCharname.length() || cash<=0) || (wscAnon.size() && wscAnon!=L"anon")) { PrintUserCmdText(iClientID, L"ERR Invalid parameters"); PrintUserCmdText(iClientID, usage); return true; } bool bAnon = false; if (wscAnon==L"anon") bAnon = true; if (HkGetAccountByCharname(wscTargetCharname)==0) { PrintUserCmdText(iClientID, L"ERR char does not exist"); return true; } int secs = 0; HkGetOnLineTime(wscCharname, secs); if (secs<set_iMinTime) { PrintUserCmdText(iClientID, L"ERR insufficient time online"); return true; } if (InBlockedSystem(wscCharname) || InBlockedSystem(wscTargetCharname)) { PrintUserCmdText(iClientID, L"ERR cash transfer blocked"); return true; } // Read the current number of credits for the player // and check that the character has enough cash. int iCash = 0; if ((err = HkGetCash(wscCharname, iCash)) != HKE_OK) { PrintUserCmdText(iClientID, L"ERR "+HkErrGetText(err)); return true; } if (cash<set_iMinTransfer || cash<0) { PrintUserCmdText(iClientID, L"ERR Transfer too small, minimum transfer "+ToMoneyStr(set_iMinTransfer)+L" credits"); return true; } if (iCash<cash) { PrintUserCmdText(iClientID, L"ERR Insufficient credits"); return true; } // Prevent target ship from becoming corrupt. float fTargetValue = 0.0f; if (HKGetShipValue(wscTargetCharname, fTargetValue) != HKE_OK) { PrintUserCmdText(iClientID, L"ERR "+HkErrGetText(err)); return true; } if ((fTargetValue + cash) > 2000000000.0f) { PrintUserCmdText(iClientID, L"ERR Transfer will exceed credit limit"); return true; } // Calculate the new cash int iExpectedCash = 0; if ((err = HkGetCash(wscTargetCharname, iExpectedCash)) != HKE_OK) { PrintUserCmdText(iClientID, L"ERR Get cash failed err="+HkErrGetText(err)); return true; } iExpectedCash += cash; // Do an anticheat check on the receiving character first. uint targetClientId = HkGetClientIdFromCharname(wscTargetCharname); if (targetClientId!=-1 && !HkIsInCharSelectMenu(targetClientId)) { if (HkAntiCheat(targetClientId) != HKE_OK) { PrintUserCmdText(iClientID, L"ERR Transfer failed"); AddLog("NOTICE: Possible cheating when sending %s credits from %s (%s) to %s (%s)", wstos(ToMoneyStr(cash)).c_str(), wstos(wscCharname).c_str(), wstos(HkGetAccountID(HkGetAccountByCharname(wscCharname))).c_str(), wstos(wscTargetCharname).c_str(), wstos(HkGetAccountID(HkGetAccountByCharname(wscTargetCharname))).c_str()); return true; } HkSaveChar(targetClientId); } if (targetClientId != -1) { if (ClientInfo[iClientID].iTradePartner || ClientInfo[targetClientId].iTradePartner) { PrintUserCmdText(iClientID, L"ERR Trade window open"); AddLog("NOTICE: Trade window open when sending %s credits from %s (%s) to %s (%s) %u %u", wstos(ToMoneyStr(cash)).c_str(), wstos(wscCharname).c_str(), wstos(HkGetAccountID(HkGetAccountByCharname(wscCharname))).c_str(), wstos(wscTargetCharname).c_str(), wstos(HkGetAccountID(HkGetAccountByCharname(wscTargetCharname))).c_str(), iClientID, targetClientId); return true; } } // Remove cash from current character and save it checking that the // save completes before allowing the cash to be added to the target ship. if ((err = HkAddCash(wscCharname, 0-cash)) != HKE_OK) { PrintUserCmdText(iClientID, L"ERR Remove cash failed err="+HkErrGetText(err)); return true; } if (HkAntiCheat(iClientID) != HKE_OK) { PrintUserCmdText(iClientID, L"ERR Transfer failed"); AddLog("NOTICE: Possible cheating when sending %s credits from %s (%s) to %s (%s)", wstos(ToMoneyStr(cash)).c_str(), wstos(wscCharname).c_str(), wstos(HkGetAccountID(HkGetAccountByCharname(wscCharname))).c_str(), wstos(wscTargetCharname).c_str(), wstos(HkGetAccountID(HkGetAccountByCharname(wscTargetCharname))).c_str()); return true; } HkSaveChar(iClientID); // Add cash to target character if ((err = HkAddCash(wscTargetCharname, cash)) != HKE_OK) { PrintUserCmdText(iClientID, L"ERR Add cash failed err="+HkErrGetText(err)); return true; } targetClientId = HkGetClientIdFromCharname(wscTargetCharname); if (targetClientId!=-1 && !HkIsInCharSelectMenu(targetClientId)) { if (HkAntiCheat(targetClientId) != HKE_OK) { PrintUserCmdText(iClientID, L"ERR Transfer failed"); AddLog("NOTICE: Possible cheating when sending %s credits from %s (%s) to %s (%s)", wstos(ToMoneyStr(cash)).c_str(), wstos(wscCharname).c_str(), wstos(HkGetAccountID(HkGetAccountByCharname(wscCharname))).c_str(), wstos(wscTargetCharname).c_str(), wstos(HkGetAccountID(HkGetAccountByCharname(wscTargetCharname))).c_str()); return true; } HkSaveChar(targetClientId); } // Check that receiving character has the correct ammount of cash. int iCurrCash; if ((err = HkGetCash(wscTargetCharname, iCurrCash)) != HKE_OK || iCurrCash != iExpectedCash) { AddLog("ERROR: Cash transfer error when sending %s credits from %s (%s) to %s (%s) current %s credits expected %s credits ", wstos(ToMoneyStr(cash)).c_str(), wstos(wscCharname).c_str(), wstos(HkGetAccountID(HkGetAccountByCharname(wscCharname))).c_str(), wstos(wscTargetCharname).c_str(), wstos(HkGetAccountID(HkGetAccountByCharname(wscTargetCharname))).c_str(), wstos(ToMoneyStr(iCurrCash)).c_str(), wstos(ToMoneyStr(iExpectedCash)).c_str()); PrintUserCmdText(iClientID, L"ERR Transfer failed"); return true; } // If the target player is online then send them a message saying // telling them that they've received the cash. wstring msg = L"You have received " + ToMoneyStr(cash) + L" credits from " + ((bAnon)?L"anonymous":wscCharname); if (targetClientId!=-1 && !HkIsInCharSelectMenu(targetClientId)) { PrintUserCmdText(targetClientId, L"%s", msg.c_str()); } // Otherwise we assume that the character is offline so we record an entry // in the character's givecash.ini. When they come online we inform them // of the transfer. The ini is cleared when ever the character logs in. else { wstring msg = L"You have received " + ToMoneyStr(cash) + L" credits from " + ((bAnon)?L"anonymous":wscCharname); LogTransfer(wscTargetCharname, msg); } AddLog("NOTICE: Send %s credits from %s (%s) to %s (%s)", wstos(ToMoneyStr(cash)).c_str(), wstos(wscCharname).c_str(), wstos(HkGetAccountID(HkGetAccountByCharname(wscCharname))).c_str(), wstos(wscTargetCharname).c_str(), wstos(HkGetAccountID(HkGetAccountByCharname(wscTargetCharname))).c_str()); // A friendly message explaining the transfer. msg = L"You have sent " + ToMoneyStr(cash) + L" credits to " + wscTargetCharname; if (bAnon) msg += L" anonymously"; PrintUserCmdText(iClientID, L"%s", msg.c_str()); return true; }